in odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmSchema.java [109:192]
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());
}
}
}