Package org.apache.olingo.odata2.jpa.processor.api.model

Examples of org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmMapping


    private void buildEdmParameter(final FunctionImport functionImport, final Method method)
        throws ODataJPAModelException {
      Annotation[][] annotations = method.getParameterAnnotations();
      Class<?>[] parameterTypes = method.getParameterTypes();
      List<FunctionImportParameter> funcImpList = new ArrayList<FunctionImportParameter>();
      JPAEdmMapping mapping = null;
      int j = 0;
      for (Annotation[] annotationArr : annotations) {
        Class<?> parameterType = parameterTypes[j++];

        for (Annotation element : annotationArr) {
          if (element instanceof EdmFunctionImportParameter) {
            EdmFunctionImportParameter annotation = (EdmFunctionImportParameter) element;
            FunctionImportParameter functionImportParameter = new FunctionImportParameter();
            if (annotation.name().equals("")) {
              throw ODataJPAModelException.throwException(ODataJPAModelException.FUNC_PARAM_NAME_EXP.addContent(method
                  .getDeclaringClass().getName(), method.getName()), null);
            } else {
              functionImportParameter.setName(annotation.name());
            }

            functionImportParameter.setType(JPATypeConvertor.convertToEdmSimpleType(parameterType, null));

            Facets facets = new Facets();
            if (annotation.facets().maxLength() > 0) {
              facets.setMaxLength(annotation.facets().maxLength());
            }
            if (annotation.facets().nullable() == false) {
              facets.setNullable(false);
            } else {
              facets.setNullable(true);
            }

            if (annotation.facets().precision() > 0) {
              facets.setPrecision(annotation.facets().precision());
            }
            if (annotation.facets().scale() >= 0) {
              facets.setScale(annotation.facets().scale());
            }

            functionImportParameter.setFacets(facets);
            mapping = new JPAEdmMappingImpl();
            mapping.setJPAType(parameterType);
            functionImportParameter.setMapping((Mapping) mapping);
            funcImpList.add(functionImportParameter);
          }
        }
      }
View Full Code Here


      final ODataJPAContext context) {
    this.oDataEntityType = oDataEntityType;
    this.oDataEntitySet = oDataEntitySet;
    oDataJPAContext = context;
    try {
      JPAEdmMapping mapping = (JPAEdmMapping) oDataEntityType.getMapping();
      jpaType = mapping.getJPAType();
    } catch (EdmException e) {
      return;
    }
    jpaEntityParser = new JPAEntityParser();
  }
View Full Code Here

  protected void setComplexProperty(Method accessModifier, final Object jpaEntity,
      final EdmStructuralType edmComplexType, final HashMap<String, Object> propertyValue)
      throws EdmException, IllegalAccessException, IllegalArgumentException, InvocationTargetException,
      InstantiationException, ODataJPARuntimeException {

    JPAEdmMapping mapping = (JPAEdmMapping) edmComplexType.getMapping();
    Object embeddableObject = mapping.getJPAType().newInstance();
    accessModifier.invoke(jpaEntity, embeddableObject);

    HashMap<String, Method> accessModifiers =
        jpaEntityParser.getAccessModifiers(embeddableObject, edmComplexType, JPAEntityParser.ACCESS_MODIFIER_SET);
View Full Code Here

        newSimpleProperty.setMimeType(oldSimpleProperty.getMimeType());
        newSimpleProperty.setName(oldSimpleProperty.getName());
        newSimpleProperty.setType(oldSimpleProperty.getType());
        JPAEdmMappingImpl newMapping = new JPAEdmMappingImpl();
        Mapping mapping = oldSimpleProperty.getMapping();
        JPAEdmMapping oldMapping = (JPAEdmMapping) mapping;
        newMapping.setJPAColumnName(oldMapping.getJPAColumnName());
        newMapping.setInternalName(embeddablePropertyName + "." + mapping.getInternalName());
        newMapping.setObject(mapping.getObject());
        newMapping.setJPAType(oldMapping.getJPAType());
        newSimpleProperty.setMapping(newMapping);
        expandedList.add(newSimpleProperty);
      } catch (ClassCastException e) {
        ComplexProperty complexProperty = (ComplexProperty) property;
        String name = embeddablePropertyName + "." + complexProperty.getMapping().getInternalName();
View Full Code Here

        functionImport.setName(method.getName());
      } else {
        functionImport.setName(annotation.name());
      }

      JPAEdmMapping mapping = new JPAEdmMappingImpl();
      ((Mapping) mapping).setInternalName(method.getName());
      mapping.setJPAType(method.getDeclaringClass());
      functionImport.setMapping((Mapping) mapping);

      functionImport.setHttpMethod(annotation.httpMethod().name().toString());

      buildReturnType(functionImport, method, annotation);
View Full Code Here

      throws ODataJPAModelException {

    Annotation[][] annotations = method.getParameterAnnotations();
    Class<?>[] parameterTypes = method.getParameterTypes();
    List<FunctionImportParameter> funcImpList = new ArrayList<FunctionImportParameter>();
    JPAEdmMapping mapping = null;
    int j = 0;
    for (Annotation[] annotationArr : annotations) {
      Class<?> parameterType = parameterTypes[j++];

      for (Annotation element : annotationArr) {
        if (element instanceof Parameter) {
          Parameter annotation = (Parameter) element;
          FunctionImportParameter functionImportParameter = new FunctionImportParameter();
          if (annotation.name().equals("")) {
            throw ODataJPAModelException.throwException(ODataJPAModelException.FUNC_PARAM_NAME_EXP.addContent(method
                .getDeclaringClass().getName(), method.getName()), null);
          } else {
            functionImportParameter.setName(annotation.name());
          }

          functionImportParameter.setType(JPATypeConvertor.convertToEdmSimpleType(parameterType, null));
          functionImportParameter.setMode(annotation.mode().toString());

          Facets facets = new Facets();
          if (annotation.facets().maxLength() > 0) {
            facets.setMaxLength(annotation.facets().maxLength());
          }
          if (annotation.facets().nullable() == false) {
            facets.setNullable(false);
          } else {
            facets.setNullable(true);
          }

          if (annotation.facets().precision() > 0) {
            facets.setPrecision(annotation.facets().precision());
          }
          if (annotation.facets().scale() >= 0) {
            facets.setScale(annotation.facets().scale());
          }

          functionImportParameter.setFacets(facets);
          mapping = new JPAEdmMappingImpl();
          mapping.setJPAType(parameterType);
          functionImportParameter.setMapping((Mapping) mapping);
          funcImpList.add(functionImportParameter);
        }
      }
    }
View Full Code Here

          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);
View Full Code Here

    private void buildEdmParameter(final FunctionImport functionImport, final Method method)
        throws ODataJPAModelException {
      Annotation[][] annotations = method.getParameterAnnotations();
      Class<?>[] parameterTypes = method.getParameterTypes();
      List<FunctionImportParameter> funcImpList = new ArrayList<FunctionImportParameter>();
      JPAEdmMapping mapping = null;
      int j = 0;
      for (Annotation[] annotationArr : annotations) {
        Class<?> parameterType = parameterTypes[j++];

        for (Annotation element : annotationArr) {
          if (element instanceof EdmFunctionImportParameter) {
            EdmFunctionImportParameter annotation = (EdmFunctionImportParameter) element;
            FunctionImportParameter functionImportParameter = new FunctionImportParameter();
            if (annotation.name().equals("")) {
              throw ODataJPAModelException.throwException(ODataJPAModelException.FUNC_PARAM_NAME_EXP.addContent(method
                  .getDeclaringClass().getName(), method.getName()), null);
            } else {
              functionImportParameter.setName(annotation.name());
            }

            functionImportParameter.setType(JPATypeConvertor.convertToEdmSimpleType(parameterType, null));

            Facets facets = new Facets();
            if (annotation.facets().maxLength() > 0) {
              facets.setMaxLength(annotation.facets().maxLength());
            }
            if (annotation.facets().nullable() == false) {
              facets.setNullable(false);
            } else {
              facets.setNullable(true);
            }

            if (annotation.facets().precision() > 0) {
              facets.setPrecision(annotation.facets().precision());
            }
            if (annotation.facets().scale() >= 0) {
              facets.setScale(annotation.facets().scale());
            }

            functionImportParameter.setFacets(facets);
            mapping = new JPAEdmMappingImpl();
            mapping.setJPAType(parameterType);
            functionImportParameter.setMapping((Mapping) mapping);
            funcImpList.add(functionImportParameter);
          }
        }
      }
View Full Code Here

    assertEquals(functionImportList.size(), 1);

    FunctionImport functionImport = functionImportList.get(0);
    assertEquals(functionImport.getName(), "method7");
    assertNotNull(functionImport.getMapping());
    JPAEdmMapping mapping = (JPAEdmMapping) functionImport.getMapping();
    assertEquals(_JPACustomProcessorMock.class, mapping.getJPAType());

    ReturnType returnType = functionImport.getReturnType();
    assertNotNull(returnType);
    assertEquals(EdmMultiplicity.ONE, returnType.getMultiplicity());
    assertEquals(returnType.getTypeName().toString(), ODataJPAContextMock.PERSISTENCE_UNIT_NAME + "."
View Full Code Here

    assertEquals(functionImportList.size(), 1);

    FunctionImport functionImport = functionImportList.get(0);
    assertEquals(functionImport.getName(), "method7");
    assertNotNull(functionImport.getMapping());
    JPAEdmMapping mapping = (JPAEdmMapping) functionImport.getMapping();
    assertEquals(JPACustomProcessorMock.class, mapping.getJPAType());

    ReturnType returnType = functionImport.getReturnType();
    assertNotNull(returnType);
    assertEquals(EdmMultiplicity.ONE, returnType.getMultiplicity());
    assertEquals(returnType.getTypeName().toString(), ODataJPAContextMock.PERSISTENCE_UNIT_NAME + "."
View Full Code Here

TOP

Related Classes of org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmMapping

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.