org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmExtension Java Examples

The following examples show how to use org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmExtension. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JPAEdmMappingModelService.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
public JPAEdmMappingModelService(final ODataJPAContext ctx) {
  JPAEdmExtension ext = null;
  mappingModelName = ctx.getJPAEdmMappingModel();
  if (mappingModelName == null) {
    ext = ctx.getJPAEdmExtension();
    if (ext != null) {
      mappingModelStream = ext.getJPAEdmMappingModelStream();
    }
  }

  mappingModelExists = mappingModelName != null || mappingModelStream != null;
}
 
Example #2
Source File: JPAEdmBaseViewImpl.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
@Override
public JPAEdmExtension getJPAEdmExtension() {
  return jpaEdmExtension;
}
 
Example #3
Source File: JPAEdmSchema.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
@Override
public void build() throws ODataJPAModelException, ODataJPARuntimeException {

  schema = new Schema();
  JPAEdmNameBuilder.build(JPAEdmSchema.this);

  associationView = new JPAEdmAssociation(JPAEdmSchema.this);

  complexTypeView = new JPAEdmComplexType(JPAEdmSchema.this);
  complexTypeView.getBuilder().build();

  entityContainerView = new JPAEdmEntityContainer(JPAEdmSchema.this);
  entityContainerView.getBuilder().build();
  schema.setEntityContainers(entityContainerView.getConsistentEdmEntityContainerList());

  JPAEdmEntitySetView entitySetView = entityContainerView.getJPAEdmEntitySetView();
  if (entitySetView.isConsistent() && entitySetView.getJPAEdmEntityTypeView() != null) {
    JPAEdmEntityTypeView entityTypeView = entitySetView.getJPAEdmEntityTypeView();
    if (entityTypeView.isConsistent() && !entityTypeView.getConsistentEdmEntityTypes().isEmpty()) {
      schema.setEntityTypes(entityTypeView.getConsistentEdmEntityTypes());
    }
  }
  if (complexTypeView.isConsistent()) {
    List<ComplexType> complexTypes = complexTypeView.getConsistentEdmComplexTypes();
    List<ComplexType> existingComplexTypes = new ArrayList<ComplexType>();
    for (ComplexType complexType : complexTypes) {
      if (complexType != null && complexTypeView.isReferencedInKey(complexType.getName())) {// null check for
                                                                                            // exclude
        existingComplexTypes.add(complexType);
      }
    }
    if (!existingComplexTypes.isEmpty()) {
      schema.setComplexTypes(existingComplexTypes);
    }
  }

  List<String> existingAssociationList = new ArrayList<String>();
  if (associationView.isConsistent() && !associationView.getConsistentEdmAssociationList().isEmpty()) {

    List<Association> consistentAssociationList = associationView.getConsistentEdmAssociationList();
    schema.setAssociations(consistentAssociationList);
    for (Association association : consistentAssociationList) {
      existingAssociationList.add(association.getName());
    }

  }
  List<EntityType> entityTypes =
      entityContainerView.getJPAEdmEntitySetView().getJPAEdmEntityTypeView().getConsistentEdmEntityTypes();
  List<NavigationProperty> navigationProperties;
  if (entityTypes != null && !entityTypes.isEmpty()) {
    for (EntityType entityType : entityTypes) {

      List<NavigationProperty> consistentNavigationProperties = null;
      navigationProperties = entityType.getNavigationProperties();
      if (navigationProperties != null) {
        consistentNavigationProperties = new ArrayList<NavigationProperty>();
        for (NavigationProperty navigationProperty : navigationProperties) {
          if (existingAssociationList.contains(navigationProperty.getRelationship().getName())) {
            consistentNavigationProperties.add(navigationProperty);
          }
        }
        if (consistentNavigationProperties.isEmpty()) {
          entityType.setNavigationProperties(null);
        } else {
          entityType.setNavigationProperties(consistentNavigationProperties);
        }
      }

    }
  }

  JPAEdmExtension edmExtension = getJPAEdmExtension();
  if (edmExtension != null) {
    edmExtension.extendJPAEdmSchema(JPAEdmSchema.this);
    edmExtension.extendWithOperation(JPAEdmSchema.this);

    JPAEdmFunctionImportView functionImportView = new JPAEdmFunctionImport(JPAEdmSchema.this);
    functionImportView.getBuilder().build();
    if (functionImportView.getConsistentFunctionImportList() != null) {
      entityContainerView.getEdmEntityContainer().setFunctionImports(
          functionImportView.getConsistentFunctionImportList());
    }

  }
}
 
Example #4
Source File: ODataJPAContextImpl.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
@Override
public void setJPAEdmExtension(final JPAEdmExtension jpaEdmExtension) {
  this.jpaEdmExtension = jpaEdmExtension;

}
 
Example #5
Source File: ODataJPAContextImpl.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
@Override
public JPAEdmExtension getJPAEdmExtension() {
  return jpaEdmExtension;
}
 
Example #6
Source File: JPAEdmTestModelView.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
@Override
public JPAEdmExtension getJPAEdmExtension() {
  return null;
}
 
Example #7
Source File: ODataJPAContext.java    From olingo-odata2 with Apache License 2.0 2 votes vote down vote up
/**
 * The method sets the JPA Edm Extension instance into the context. There
 * can be at most only one extension for a context. Invoking the method
 * several times overwrites already set extension instance in the context.
 * 
 * @param jpaEdmExtension
 * is an instance of type {@link org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmExtension}
 * 
 */
public void setJPAEdmExtension(JPAEdmExtension jpaEdmExtension);
 
Example #8
Source File: ODataJPAContext.java    From olingo-odata2 with Apache License 2.0 2 votes vote down vote up
/**
 * The method returns the JPA Edm Extension instance set into the context.
 * 
 * @return an instance of type
 * {@link org.apache.olingo.odata2.jpa.processor.api.model.mapping.JPAEmbeddableTypeMapType}
 */
public JPAEdmExtension getJPAEdmExtension();