Package org.apache.olingo.odata2.api.edm.provider

Examples of org.apache.olingo.odata2.api.edm.provider.EntityType


   * EDM Entity Type Name - RULES
   * ************************************************************************
   */
  public static void build(final JPAEdmEntityTypeView view) {

    EntityType edmEntityType = view.getEdmEntityType();
    String jpaEntityName = view.getJPAEntityType().getName();
    JPAEdmMappingModelAccess mappingModelAccess = view.getJPAEdmMappingModelAccess();
    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
    edmEntityType.setMapping(((Mapping) mapping).setInternalName(jpaEntityName));

    edmEntityType.setName(edmEntityTypeName);

  }
View Full Code Here


        throw ODataJPAModelException.throwException(ODataJPAModelException.FUNC_RETURN_TYPE_EXP.addContent(method
            .getDeclaringClass(), method.getName()), null);
      }
      switch (returnType) {
      case ENTITY_TYPE:
        EntityType edmEntityType = null;
        if (multiplicity == Multiplicity.ONE) {
          edmEntityType = jpaEdmEntityTypeView.searchEdmEntityType(methodReturnType.getSimpleName());
        } else if (multiplicity == Multiplicity.MANY) {
          edmEntityType = jpaEdmEntityTypeView.searchEdmEntityType(getReturnTypeSimpleName(method));
        }

        if (edmEntityType == null) {
          throw ODataJPAModelException.throwException(ODataJPAModelException.FUNC_RETURN_TYPE_ENTITY_NOT_FOUND
              .addContent(method.getDeclaringClass(), method.getName(), methodReturnType.getSimpleName()), null);
        }
        functionReturnType.setTypeName(JPAEdmNameBuilder.build(schemaView, edmEntityType.getName()));
        break;
      case SCALAR:

        EdmSimpleTypeKind edmSimpleTypeKind = JPATypeConvertor.convertToEdmSimpleType(methodReturnType, null);
        functionReturnType.setTypeName(edmSimpleTypeKind.getFullQualifiedName());
View Full Code Here

          throw ODataJPAModelException.throwException(ODataJPAModelException.FUNC_RETURN_TYPE_EXP.addContent(method
              .getDeclaringClass(), method.getName()), null);
        }
        switch (returnType.type()) {
        case ENTITY:
          EntityType edmEntityType = null;
          if (returnType.isCollection() == false) {
            edmEntityType = jpaEdmEntityTypeView.searchEdmEntityType(methodReturnType.getSimpleName());
          } else {
            edmEntityType = jpaEdmEntityTypeView.searchEdmEntityType(getReturnTypeSimpleName(method));
          }

          if (edmEntityType == null) {
            throw ODataJPAModelException.throwException(ODataJPAModelException.FUNC_RETURN_TYPE_ENTITY_NOT_FOUND
                .addContent(method.getDeclaringClass(), method.getName(), methodReturnType.getSimpleName()), null);
          }
          functionReturnType.setTypeName(JPAEdmNameBuilder.build(schemaView, edmEntityType.getName()));
          break;
        case SIMPLE:
          EdmSimpleTypeKind edmSimpleTypeKind = JPATypeConvertor.convertToEdmSimpleType(methodReturnType, null);
          functionReturnType.setTypeName(edmSimpleTypeKind.getFullQualifiedName());
View Full Code Here

  }

  @Test
  public void testBuildNegatives() {// Bad content type
    try {
      EntityType entity = new EntityType();
      entity.setName("SalesOrderHeader");
      try {
        assertNotNull(responseBuilder.build(getLocalGetURIInfo(), getEntity(), "xml"));
      } catch (ODataNotFoundException e) {
        assertTrue(true);
      }
View Full Code Here

    return PUNIT_NAME;
  }

  @Override
  public EntityType getEdmEntityType() {
    EntityType entityType = new EntityType();
    entityType.setName(SimpleTypeA.NAME);
    return entityType;
  }
View Full Code Here

        return "salesorderprocessing";
      }

      @Override
      public EntityType getEdmEntityType() {
        EntityType entityType = new EntityType();
        entityType.setName("SalesOrderHeader");
        return entityType;
      }

      @SuppressWarnings("hiding")
      class AttributeMock<Object, String> extends JPAAttributeMock<Object, String> {
View Full Code Here

        return "salesorderprocessing";
      }

      @Override
      public EntityType getEdmEntityType() {
        EntityType entityType = new EntityType();
        entityType.setName("SalesOrderHeader");
        return entityType;
      }
View Full Code Here

  }

  @Override
  public EntityType searchEdmEntityType(final String arg0) {
    if (arg0.equals(_JPACustomProcessorMock.class.getSimpleName())) {
      return new EntityType().setName(_JPACustomProcessorMock.edmName);
    } else {
      return null;
    }
  }
View Full Code Here

  }

  @Override
  public EntityType searchEdmEntityType(final String arg0) {
    if (arg0.equals(JPACustomProcessorMock.class.getSimpleName())) {
      return new EntityType().setName(JPACustomProcessorMock.edmName);
    } else {
      return null;
    }
  }
View Full Code Here

      }
      return complexType.setName(name).setProperties(properties);
    }

    public EntityType buildEntityType() {
      EntityType entityType = new EntityType();
      if (baseEntityType != null) {
        entityType.setBaseType(baseEntityType);
      }
      if (!keyProperties.isEmpty()) {
        entityType.setKey(new Key().setKeys(keyProperties));
      }
      if (!navProperties.isEmpty()) {
        entityType.setNavigationProperties(navProperties);
      }
      return entityType.setName(name)
          .setAbstract(isAbstract)
          .setHasStream(isMediaResource)
          .setProperties(properties);
    }
View Full Code Here

TOP

Related Classes of org.apache.olingo.odata2.api.edm.provider.EntityType

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.