private FunctionImport clone(FunctionImport functionImport) { if (functionImport == null) { return null; } FunctionImport newFunctionImport = new FunctionImport(); newFunctionImport.setAnnotationAttributes(functionImport .getAnnotationAttributes()); newFunctionImport.setAnnotationElements(functionImport .getAnnotationElements()); newFunctionImport.setDocumentation(functionImport.getDocumentation()); newFunctionImport.setEntitySet(functionImport.getEntitySet()); newFunctionImport.setHttpMethod(functionImport.getHttpMethod()); newFunctionImport.setMapping(functionImport.getMapping()); newFunctionImport.setName(functionImport.getName()); newFunctionImport.setParameters(functionImport.getParameters()); newFunctionImport.setReturnType(clone(functionImport.getReturnType())); return newFunctionImport; }
@Override public EdmAnnotations getAnnotations() throws EdmException { if (annotations == null) { annotations = new EdmAnnotationsImplProv(functionImport.getAnnotationAttributes(), functionImport.getAnnotationElements()); } return annotations; }
@Override public EdmTyped getReturnType() throws EdmException { final ReturnType returnType = functionImport.getReturnType(); return new EdmTypedImplProv(edm, functionImport.getName(), returnType.getTypeName(), returnType.getMultiplicity()); }
private FunctionImport readFunctionImport(final XMLStreamReader reader) throws XMLStreamException, EntityProviderException { reader.require(XMLStreamConstants.START_ELEMENT, edmNamespace, XmlMetadataConstants.EDM_FUNCTION_IMPORT); FunctionImport function = new FunctionImport(); List<FunctionImportParameter> functionParameters = new ArrayList<FunctionImportParameter>(); List<AnnotationElement> annotationElements = new ArrayList<AnnotationElement>(); FullQualifiedName fqName; function.setName(reader.getAttributeValue(null, XmlMetadataConstants.EDM_NAME)); function.setHttpMethod(reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, XmlMetadataConstants.EDM_FUNCTION_IMPORT_HTTP_METHOD)); function.setEntitySet(reader.getAttributeValue(null, XmlMetadataConstants.EDM_ENTITY_SET)); function.setReturnType(returnType); function.setAnnotationAttributes(readAnnotationAttribute(reader)); while (reader.hasNext() && !(reader.isEndElement() && edmNamespace.equals(reader.getNamespaceURI()) function.setAnnotationElements(annotationElements); function.setParameters(functionParameters); return function;
for (FunctionImport functionImport : functionImports) { xmlStreamWriter.writeStartElement(XmlMetadataConstants.EDM_FUNCTION_IMPORT); xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_NAME, functionImport.getName()); if (functionImport.getReturnType() != null) { xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_FUNCTION_IMPORT_RETURN, functionImport .getReturnType().toString()); if (functionImport.getEntitySet() != null) { xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_ENTITY_SET, functionImport.getEntitySet()); if (functionImport.getHttpMethod() != null) { xmlStreamWriter.writeAttribute(Edm.PREFIX_M, Edm.NAMESPACE_M_2007_08, XmlMetadataConstants.EDM_FUNCTION_IMPORT_HTTP_METHOD, functionImport.getHttpMethod()); writeAnnotationAttributes(functionImport.getAnnotationAttributes(), predefinedNamespaces, null, xmlStreamWriter); writeDocumentation(functionImport.getDocumentation(), predefinedNamespaces, xmlStreamWriter); Collection<FunctionImportParameter> functionImportParameters = functionImport.getParameters(); if (functionImportParameters != null) { for (FunctionImportParameter functionImportParameter : functionImportParameters) { writeAnnotationElements(functionImport.getAnnotationElements(), predefinedNamespaces, xmlStreamWriter);
public EdmFunctionImportImplProv(final EdmImplProv edm, final FunctionImport functionImport, final EdmEntityContainer edmEntityContainer) throws EdmException { super(edm, functionImport.getName()); this.functionImport = functionImport; this.edmEntityContainer = edmEntityContainer; buildFunctionImportParametersInternal(); edmParameters = new HashMap<String, EdmParameter>(); }
private FunctionImport buildEdmFunctionImport(final Method method, final EdmFunctionImport edmAnnotationFunctionImport) throws ODataJPAModelException { if (edmAnnotationFunctionImport != null && edmAnnotationFunctionImport.returnType() != null) { FunctionImport functionImport = new FunctionImport(); if ("".equals(edmAnnotationFunctionImport.name())) { functionImport.setName(method.getName()); } else { functionImport.setName(edmAnnotationFunctionImport.name()); } JPAEdmMapping mapping = new JPAEdmMappingImpl(); ((Mapping) mapping).setInternalName(method.getName()); mapping.setJPAType(method.getDeclaringClass()); functionImport.setMapping((Mapping) mapping); functionImport.setHttpMethod(edmAnnotationFunctionImport.httpMethod().name().toString()); buildEdmReturnType(functionImport, method, edmAnnotationFunctionImport); buildEdmParameter(functionImport, method); return functionImport; } return null; }
private void validateFunctionImport() throws EntityProviderException { for (FunctionImport functionImport : edmFunctionImportList) { ReturnType returnType = functionImport.getReturnType(); if (returnType != null) { String entitySet = functionImport.getEntitySet(); FullQualifiedName fqn = returnType.getTypeName(); if (returnType.getMultiplicity() == EdmMultiplicity.MANY && entitySet == null && entityTypesMap.get( fqn) != null) { throw new EntityProviderException(EntityProviderException.MISSING_ATTRIBUTE.addContent("EntitySet = " + entitySet, XmlMetadataConstants.EDM_FUNCTION_IMPORT + " = " + functionImport.getName())); } else if (returnType.getMultiplicity() != EdmMultiplicity.MANY && entitySet != null && entityTypesMap.get( fqn) == null) { throw new EntityProviderException(EntityProviderException.INVALID_ATTRIBUTE.addContent("EntitySet = " + entitySet, XmlMetadataConstants.EDM_FUNCTION_IMPORT + " = " + functionImport.getName())); } } } } /* This method gets the last base type of the EntityType
throw ODataJPAModelException.throwException(ODataJPAModelException.FUNC_ENTITYSET_EXP, null); functionImport.setEntitySet(entitySet); break; functionImport.setReturnType(functionReturnType);
functionImport.setParameters(funcImpList);
private FunctionImport readFunctionImport(final XMLStreamReader reader) throws XMLStreamException, EntityProviderException { reader.require(XMLStreamConstants.START_ELEMENT, edmNamespace, XmlMetadataConstants.EDM_FUNCTION_IMPORT); FunctionImport function = new FunctionImport(); List<FunctionImportParameter> functionParameters = new ArrayList<FunctionImportParameter>(); List<AnnotationElement> annotationElements = new ArrayList<AnnotationElement>(); function.setName(reader.getAttributeValue(null, XmlMetadataConstants.EDM_NAME)); function.setHttpMethod(reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, XmlMetadataConstants.EDM_FUNCTION_IMPORT_HTTP_METHOD)); function.setEntitySet(reader.getAttributeValue(null, XmlMetadataConstants.EDM_ENTITY_SET)); ReturnType returnType = new ReturnType(); String returnTypeString = reader.getAttributeValue(null, XmlMetadataConstants.EDM_FUNCTION_IMPORT_RETURN); function.setReturnType(returnType); function.setAnnotationAttributes(readAnnotationAttribute(reader)); while (reader.hasNext() && !(reader.isEndElement() && edmNamespace.equals(reader.getNamespaceURI()) function.setAnnotationElements(annotationElements); function.setParameters(functionParameters); return function;
for (FunctionImport functionImport : functionImports) { xmlStreamWriter.writeStartElement(XmlMetadataConstants.EDM_FUNCTION_IMPORT); xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_NAME, functionImport.getName()); if (functionImport.getReturnType() != null) { xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_FUNCTION_IMPORT_RETURN, functionImport .getReturnType().toString()); if (functionImport.getEntitySet() != null) { xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_ENTITY_SET, functionImport.getEntitySet()); if (functionImport.getHttpMethod() != null) { xmlStreamWriter.writeAttribute(Edm.PREFIX_M, Edm.NAMESPACE_M_2007_08, XmlMetadataConstants.EDM_FUNCTION_IMPORT_HTTP_METHOD, functionImport.getHttpMethod()); writeAnnotationAttributes(functionImport.getAnnotationAttributes(), predefinedNamespaces, null, xmlStreamWriter); writeDocumentation(functionImport.getDocumentation(), predefinedNamespaces, xmlStreamWriter); Collection<FunctionImportParameter> functionImportParameters = functionImport.getParameters(); if (functionImportParameters != null) { for (FunctionImportParameter functionImportParameter : functionImportParameters) { writeAnnotationElements(functionImport.getAnnotationElements(), predefinedNamespaces, xmlStreamWriter);
public EdmFunctionImportImplProv(final EdmImplProv edm, final FunctionImport functionImport, final EdmEntityContainer edmEntityContainer) throws EdmException { super(edm, functionImport.getName()); this.functionImport = functionImport; this.edmEntityContainer = edmEntityContainer; buildFunctionImportParametersInternal(); edmParameters = new HashMap<String, EdmParameter>(); }
private FunctionImport buildEdmFunctionImport(final Method method, final EdmFunctionImport edmAnnotationFunctionImport) throws ODataJPAModelException { if (edmAnnotationFunctionImport != null && edmAnnotationFunctionImport.returnType() != null) { FunctionImport functionImport = new FunctionImport(); if ("".equals(edmAnnotationFunctionImport.name())) { functionImport.setName(method.getName()); } else { functionImport.setName(edmAnnotationFunctionImport.name()); } JPAEdmMapping mapping = new JPAEdmMappingImpl(); ((Mapping) mapping).setInternalName(method.getName()); mapping.setJPAType(method.getDeclaringClass()); functionImport.setMapping((Mapping) mapping); functionImport.setHttpMethod(edmAnnotationFunctionImport.httpMethod().name().toString()); buildEdmReturnType(functionImport, method, edmAnnotationFunctionImport); buildEdmParameter(functionImport, method); return functionImport; } return null; }
@Override public EdmTyped getReturnType() throws EdmException { if (edmReturnType == null) { final ReturnType returnType = functionImport.getReturnType(); if (returnType != null) { edmReturnType = new EdmTypedImplProv(edm, functionImport.getName(), returnType.getTypeName(), returnType.getMultiplicity()); } } return edmReturnType; }
throw ODataJPAModelException.throwException(ODataJPAModelException.FUNC_ENTITYSET_EXP, null); functionImport.setEntitySet(entitySet); break; functionImport.setReturnType(functionReturnType);
@Override public EdmAnnotations getAnnotations() throws EdmException { if (annotations == null) { annotations = new EdmAnnotationsImplProv(functionImport.getAnnotationAttributes(), functionImport.getAnnotationElements()); } return annotations; }
functionImport.setParameters(funcImpList);
private FunctionImport readFunctionImport(final XMLStreamReader reader) throws XMLStreamException, EntityProviderException { reader.require(XMLStreamConstants.START_ELEMENT, edmNamespace, XmlMetadataConstants.EDM_FUNCTION_IMPORT); FunctionImport function = new FunctionImport(); List<FunctionImportParameter> functionParameters = new ArrayList<FunctionImportParameter>(); List<AnnotationElement> annotationElements = new ArrayList<AnnotationElement>(); function.setName(reader.getAttributeValue(null, XmlMetadataConstants.EDM_NAME)); function.setHttpMethod(reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, XmlMetadataConstants.EDM_FUNCTION_IMPORT_HTTP_METHOD)); function.setEntitySet(reader.getAttributeValue(null, XmlMetadataConstants.EDM_ENTITY_SET)); function.setReturnType(returnType); function.setAnnotationAttributes(readAnnotationAttribute(reader)); while (reader.hasNext() && !(reader.isEndElement() && edmNamespace.equals(reader.getNamespaceURI()) function.setAnnotationElements(annotationElements); function.setParameters(functionParameters); return function;
for (FunctionImport functionImport : functionImports) { xmlStreamWriter.writeStartElement(XmlMetadataConstants.EDM_FUNCTION_IMPORT); xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_NAME, functionImport.getName()); if (functionImport.getReturnType() != null) { xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_FUNCTION_IMPORT_RETURN, functionImport .getReturnType().toString()); if (functionImport.getEntitySet() != null) { xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_ENTITY_SET, functionImport.getEntitySet()); if (functionImport.getHttpMethod() != null) { xmlStreamWriter.writeAttribute(Edm.PREFIX_M, Edm.NAMESPACE_M_2007_08, XmlMetadataConstants.EDM_FUNCTION_IMPORT_HTTP_METHOD, functionImport.getHttpMethod()); writeAnnotationAttributes(functionImport.getAnnotationAttributes(), predefinedNamespaces, null, xmlStreamWriter); writeDocumentation(functionImport.getDocumentation(), predefinedNamespaces, xmlStreamWriter); Collection<FunctionImportParameter> functionImportParameters = functionImport.getParameters(); if (functionImportParameters != null) { for (FunctionImportParameter functionImportParameter : functionImportParameters) { writeAnnotationElements(functionImport.getAnnotationElements(), predefinedNamespaces, xmlStreamWriter);