Examples of JPAEdmMapping


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

        String[] nameParts = name.split("\\.");
        if (nameParts.length > 1) {
          embeddableKey.put(propertyName, name);
        } else {
          if (accessModifier.equals(ACCESS_MODIFIER_SET)) {
            JPAEdmMapping jpaEdmMapping = (JPAEdmMapping) property.getMapping();
            accessModifierMap.put(
                propertyName,
                jpaEntity.getClass().getMethod(name, new Class<?>[] { jpaEdmMapping.getJPAType() }));
          } else {
            accessModifierMap.put(
                propertyName,
                jpaEntity.getClass().getMethod(name,
                    (Class<?>[]) null));
View Full Code Here

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

    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

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

    return edmComplexType;
  }

  public static JPAEdmMapping mockEdmMapping(final String entityName, final String propertyName,
      final String navigationPropertyName) {
    JPAEdmMapping mapping = new JPAEdmMappingImpl();

    if (propertyName == null && entityName != null) {
      if (entityName.equals(JPATypeMock.ENTITY_NAME)) {
        mapping.setJPAType(JPATypeMock.class);
      } else if (entityName.equals(JPARelatedTypeMock.ENTITY_NAME)) {
        mapping.setJPAType(JPARelatedTypeMock.class);
      } else if (entityName.equals(JPATypeEmbeddableMock.ENTITY_NAME)) {
        mapping.setJPAType(JPATypeEmbeddableMock.class);
      } else if (entityName.equals(JPATypeEmbeddableMock2.ENTITY_NAME)) {
        mapping.setJPAType(JPATypeEmbeddableMock2.class);
      }
    } else if (entityName == null && navigationPropertyName != null) {
      mapping.setJPAType(JPARelatedTypeMock.class);
      mapping.setJPAColumnName(JPATypeMock.NAVIGATION_PROPERTY_X);
    } else if (propertyName.equals(JPATypeMock.PROPERTY_NAME_MINT)) {
      mapping.setJPAType(int.class);
      ((Mapping) mapping).setInternalName(JPATypeMock.PROPERTY_NAME_MINT);
    } else if (propertyName.equals(JPATypeMock.PROPERTY_NAME_MSTRING)) {
      mapping.setJPAType(String.class);
      ((Mapping) mapping).setInternalName(JPATypeMock.PROPERTY_NAME_MSTRING);
    else if (propertyName.equals(JPATypeMock.PROPERTY_NAME_MDATETIME)) {
      mapping.setJPAType(Calendar.class);
      ((Mapping) mapping).setInternalName(JPATypeMock.PROPERTY_NAME_MDATETIME);
    else if (propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MLONG)) {
      mapping.setJPAType(long.class);
      ((Mapping) mapping).setInternalName(JPARelatedTypeMock.PROPERTY_NAME_MLONG);
    else if (propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MDOUBLE)) {
      mapping.setJPAType(double.class);
      ((Mapping) mapping).setInternalName(JPARelatedTypeMock.PROPERTY_NAME_MDOUBLE);
    else if (propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MBYTE)) {
      mapping.setJPAType(byte.class);
      ((Mapping) mapping).setInternalName(JPARelatedTypeMock.PROPERTY_NAME_MBYTE);
    else if (propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MBYTEARRAY)) {
      mapping.setJPAType(byte[].class);
      ((Mapping) mapping).setInternalName(JPARelatedTypeMock.PROPERTY_NAME_MBYTEARRAY);
    else if (propertyName.equals(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MSHORT)) {
      mapping.setJPAType(Short.TYPE);
      ((Mapping) mapping).setInternalName(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MSHORT);
    else if (propertyName.equals(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MFLOAT)) {
      mapping.setJPAType(Float.TYPE);
      ((Mapping) mapping).setInternalName(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MFLOAT);
    else if (propertyName.equals(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MUUID)) {
      mapping.setJPAType(UUID.class);
      ((Mapping) mapping).setInternalName(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MUUID);
    else if (propertyName.equals(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MEMBEDDABLE)) {
      mapping.setJPAType(JPATypeEmbeddableMock2.class);
      ((Mapping) mapping).setInternalName(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MEMBEDDABLE);
    } else if (propertyName.equals(JPATypeMock.PROPERTY_NAME_MCOMPLEXTYPE)) {
      mapping.setJPAType(JPATypeEmbeddableMock.class);
      ((Mapping) mapping).setInternalName(JPATypeMock.PROPERTY_NAME_MCOMPLEXTYPE);
    }
    return mapping;
  }
View Full Code Here

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

          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

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

        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

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

        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.setMimeType(mapping.getMimeType());
        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

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

    String edmEntityTypeName = null;
    if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()) {
      edmEntityTypeName = mappingModelAccess.mapJPAEntityType(jpaEntityName);
    }

    JPAEdmMapping mapping = new JPAEdmMappingImpl();
    mapping.setJPAType(view.getJPAEntityType().getJavaType());

    if (edmEntityTypeName == null) {
      edmEntityTypeName = jpaEntityName;
    }
    // Setting the mapping object
View Full Code Here

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

      propertyName = Character.toUpperCase(jpaAttributeName.charAt(0)) + jpaAttributeName.substring(1);
    }

    view.getEdmSimpleProperty().setName(propertyName);

    JPAEdmMapping mapping = new JPAEdmMappingImpl();
    ((Mapping) mapping).setInternalName(jpaAttributeName);
    mapping.setJPAType(jpaAttribute.getJavaType());

    AnnotatedElement annotatedElement = (AnnotatedElement) jpaAttribute.getJavaMember();
    if (annotatedElement != null) {
      Column column = annotatedElement.getAnnotation(Column.class);
      if (column != null) {
        mapping.setJPAColumnName(column.name());
      }
    } else {
      ManagedType<?> managedType = jpaAttribute.getDeclaringType();
      if (managedType != null) {
        Class<?> clazz = managedType.getJavaType();
        try {
          Field field = clazz.getDeclaredField(jpaAttributeName);
          Column column = field.getAnnotation(Column.class);
          if (column != null) {
            mapping.setJPAColumnName(column.name());
          }
        } catch (SecurityException e) {

        } catch (NoSuchFieldException e) {
View Full Code Here

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

    }

    view.getEdmComplexType().setName(edmComplexTypeName);
    ComplexType complexType = view.getEdmComplexType();
    complexType.setName(edmComplexTypeName);
    JPAEdmMapping mapping = new JPAEdmMappingImpl();
    mapping.setJPAType(view.getJPAEmbeddableType().getJavaType());
    complexType.setMapping((Mapping) mapping);

  }
View Full Code Here

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

    if (propertyName == null) {
      propertyName = Character.toUpperCase(jpaAttributeName.charAt(0)) + jpaAttributeName.substring(1);
    }
    // change for navigation property issue
    JPAEdmMapping mapping = new JPAEdmMappingImpl();
    ((Mapping) mapping).setInternalName(jpaAttributeName);
    mapping.setJPAType(propertyView.getJPAAttribute().getJavaType());
    complexProperty.setMapping((Mapping) mapping);

    complexProperty.setName(propertyName);

  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.