Examples of JPAEdmMapping


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

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

      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

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

  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

Examples of org.apache.olingo.odata2.jpa.processor.api.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.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

  private static List<Property> createComplexTypePropertiesTwo() {
    List<Property> properties = new ArrayList<Property>();
    SimpleProperty property = new SimpleProperty();
    property.setName("SoId");
    property.setType(EdmSimpleTypeKind.Int64);
    JPAEdmMapping mapping = new JPAEdmMappingImpl();
    mapping.setJPAColumnName("Sales_Order_Id");
    ((Mapping) mapping).setInternalName("SalesOrderItemKey.SoId");
    property.setMapping((Mapping) mapping);
    properties.add(property);
    property = new SimpleProperty();
    property.setName("LiId");
    property.setType(EdmSimpleTypeKind.Int64);
    mapping = new JPAEdmMappingImpl();
    mapping.setJPAColumnName("Sales_Order_Item_Id");
    property.setMapping((Mapping) mapping);
    properties.add(property);
    return properties;

  }
View Full Code Here

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

  private static List<Property> createComplexTypePropertiesOne() {
    List<Property> properties = new ArrayList<Property>();
    SimpleProperty property = new SimpleProperty();
    property.setName("StreetName");
    property.setType(EdmSimpleTypeKind.String);
    JPAEdmMapping mapping = new JPAEdmMappingImpl();
    mapping.setJPAColumnName("STREET_NAME");
    property.setMapping((Mapping) mapping);
    properties.add(property);
    property = new SimpleProperty();
    property.setName("City");
    property.setType(EdmSimpleTypeKind.String);
    mapping = new JPAEdmMappingImpl();
    mapping.setJPAColumnName("CITY");
    property.setMapping((Mapping) mapping);
    properties.add(property);
    return properties;
  }
View Full Code Here

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

  public JPAEntity(final EdmEntityType oDataEntityType, final EdmEntitySet oDataEntitySet) {
    this.oDataEntityType = oDataEntityType;
    this.oDataEntitySet = oDataEntitySet;
    try {
      JPAEdmMapping mapping = (JPAEdmMapping) oDataEntityType.getMapping();
      jpaType = mapping.getJPAType();
    } catch (EdmException e) {
      return;
    }
    jpaEntityParser = new JPAEntityParser();
  }
View Full Code Here

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

  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

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

  @Test
  public void testExpandEdmComplexType() {
    ComplexType complexType = new ComplexType();
    List<Property> properties = new ArrayList<Property>();
    JPAEdmMapping mapping1 = new JPAEdmMappingImpl();
    mapping1.setJPAColumnName("LINEITEMID");
    ((Mapping) mapping1).setInternalName("LineItemKey.LiId");
    JPAEdmMapping mapping2 = new JPAEdmMappingImpl();
    mapping2.setJPAColumnName("LINEITEMNAME");
    ((Mapping) mapping2).setInternalName("LineItemKey.LiName");
    properties.add(new SimpleProperty().setName("LIID").setMapping((Mapping) mapping1));
    properties.add(new SimpleProperty().setName("LINAME").setMapping((Mapping) mapping2));
    complexType.setProperties(properties);
    List<Property> expandedList = null;
View Full Code Here

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

        Object[] args = new Object[edmArguements.size()];
        int i = 0;
        for (String paramName : functionImport.getParameterNames()) {
          EdmLiteral literal = edmArguements.get(paramName);
          EdmParameter parameter = functionImport.getParameter(paramName);
          JPAEdmMapping mapping = (JPAEdmMapping) parameter.getMapping();
          args[i] = convertArguement(literal, parameter.getFacets(), mapping.getJPAType());
          i++;
        }
        return args;
      }
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.