Skip to content

Commit

Permalink
[BAEL-2894] Minor formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
psevestre committed May 12, 2019
1 parent 2fad9df commit f833bc1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 38 deletions.
10 changes: 0 additions & 10 deletions apache-olingo/olingo2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-api</artifactId>
<version>${olingo2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-jpa-processor-api</artifactId>
<version>${olingo2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-jpa-processor-core</artifactId>
Expand Down
8 changes: 4 additions & 4 deletions apache-olingo/olingo4/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@

<dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>odata-server-api</artifactId>
<artifactId>odata-server-core</artifactId>
<version>${odata.version}</version>
</dependency>
<!--
<dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>odata-server-core</artifactId>
<artifactId>odata-server-api</artifactId>
<version>${odata.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
Expand All @@ -75,7 +75,7 @@
<artifactId>odata-commons-core</artifactId>
<version>${odata.version}</version>
</dependency>
-->
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ protected CsdlEntityType buildODataType(EntityType<?> et) {
List<CsdlProperty> 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);
Expand All @@ -201,67 +201,66 @@ protected CsdlEntityType buildODataType(EntityType<?> et) {
List<CsdlPropertyRef> 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<CsdlNavigationProperty> 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<CsdlNavigationProperty> 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);


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;
}
Expand Down

0 comments on commit f833bc1

Please sign in to comment.