diff --git a/apache-olingo/olingo2/pom.xml b/apache-olingo/olingo2/pom.xml index 4fc81e5e49..493d34119e 100644 --- a/apache-olingo/olingo2/pom.xml +++ b/apache-olingo/olingo2/pom.xml @@ -68,16 +68,6 @@ - - org.apache.olingo - olingo-odata2-api - ${olingo2.version} - - - org.apache.olingo - olingo-odata2-jpa-processor-api - ${olingo2.version} - org.apache.olingo olingo-odata2-jpa-processor-core diff --git a/apache-olingo/olingo4/pom.xml b/apache-olingo/olingo4/pom.xml index 794aee0711..6323db413a 100644 --- a/apache-olingo/olingo4/pom.xml +++ b/apache-olingo/olingo4/pom.xml @@ -53,16 +53,16 @@ spring-boot-starter-web - - org.apache.olingo - odata-server-api - ${odata.version} - org.apache.olingo odata-server-core ${odata.version} - runtime + + commons-beanutils commons-beanutils diff --git a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/edm/JpaEdmProvider.java b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/edm/JpaEdmProvider.java index 4cd979e931..585aecfa84 100644 --- a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/edm/JpaEdmProvider.java +++ b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/edm/JpaEdmProvider.java @@ -192,7 +192,7 @@ public class JpaEdmProvider extends CsdlAbstractEdmProvider { List properties = et.getDeclaredSingularAttributes() .stream() .filter(attr -> attr.getPersistentAttributeType() == PersistentAttributeType.BASIC) - .map(attr -> buildBasicAttribute(et, attr)) + .map(attr -> buildBasicAttribute(attr)) .collect(Collectors.toList()); result.setProperties(properties); @@ -201,24 +201,25 @@ public class JpaEdmProvider extends CsdlAbstractEdmProvider { List ids = et.getDeclaredSingularAttributes() .stream() .filter(attr -> attr.getPersistentAttributeType() == PersistentAttributeType.BASIC && attr.isId()) - .map(attr -> buildRefAttribute(et, attr)) + .map(attr -> buildRefAttribute(attr)) .collect(Collectors.toList()); result.setKey(ids); // Process 1:N navs List navs = et.getDeclaredPluralAttributes() - .stream() - .map(attr -> buildNavAttribute(et, attr)) - .collect(Collectors.toList()); + .stream() + .filter(attr -> attr.isAssociation()) + .map(attr -> buildNavAttribute(attr)) + .collect(Collectors.toList()); result.setNavigationProperties(navs); // Process N:1 navs List navs2 = et.getDeclaredSingularAttributes() - .stream() - .filter(attr -> attr.getPersistentAttributeType() == PersistentAttributeType.MANY_TO_ONE) - .map(attr -> buildNavAttribute(et, attr)) - .collect(Collectors.toList()); + .stream() + .filter(attr -> attr.getPersistentAttributeType() == PersistentAttributeType.MANY_TO_ONE) + .map(attr -> buildMany2OneNavAttribute(attr)) + .collect(Collectors.toList()); result.getNavigationProperties().addAll(navs2); @@ -226,42 +227,40 @@ public class JpaEdmProvider extends CsdlAbstractEdmProvider { return result; } - private CsdlProperty buildBasicAttribute(EntityType et, SingularAttribute attr) { + private CsdlProperty buildBasicAttribute(SingularAttribute attr) { CsdlProperty p = new CsdlProperty().setName(attr.getName()) - .setType(typeMapper.java2edm(attr.getJavaType()) - .getFullQualifiedName()) - .setNullable(et.getDeclaredSingularAttribute(attr.getName()) - .isOptional()); + .setType(typeMapper.java2edm(attr.getJavaType()) + .getFullQualifiedName()) + .setNullable(attr.isOptional()); return p; } - private CsdlPropertyRef buildRefAttribute(EntityType et, SingularAttribute attr) { + private CsdlPropertyRef buildRefAttribute(SingularAttribute attr) { CsdlPropertyRef p = new CsdlPropertyRef().setName(attr.getName()); - return p; } // Build NavProperty for 1:N or M:N associations - private CsdlNavigationProperty buildNavAttribute(EntityType et, PluralAttribute attr) { + private CsdlNavigationProperty buildNavAttribute(PluralAttribute attr) { CsdlNavigationProperty p = new CsdlNavigationProperty().setName(attr.getName()) - .setType(new FullQualifiedName(NAMESPACE, attr.getBindableJavaType().getSimpleName())) - .setCollection(true) - .setNullable(false); + .setType(new FullQualifiedName(NAMESPACE, attr.getBindableJavaType().getSimpleName())) + .setCollection(true) + .setNullable(false); return p; } // Build NavProperty for N:1 associations - private CsdlNavigationProperty buildNavAttribute(EntityType et, SingularAttribute attr) { + private CsdlNavigationProperty buildMany2OneNavAttribute(SingularAttribute attr) { CsdlNavigationProperty p = new CsdlNavigationProperty().setName(attr.getName()) - .setType(new FullQualifiedName(NAMESPACE, attr.getBindableJavaType().getSimpleName())) - .setCollection(false) - .setNullable(attr.isOptional()); + .setType(new FullQualifiedName(NAMESPACE, attr.getBindableJavaType().getSimpleName())) + .setCollection(false) + .setNullable(attr.isOptional()); return p; }