Skip to content

Commit 568ae8c

Browse files
committed
Fixed incorrect nullable default in XML-CSDL
1 parent 9408f8d commit 568ae8c

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Enabled compression in Tomcat.
88

99
**Internal changes & Bugfixes**
10+
* Fixed incorrect nullable default in XML-CSDL.
1011
* Fixed #2210: issue with Projects Plugin when using String FeatureOfInterest ids.
1112
* Changed error when insertion fails due to constraints to 409.
1213
* Fixed expand returning null link when target can not be read

Plugins/OData/src/main/java/de/fraunhofer/iosb/ilt/frostserver/plugin/odata/metadata/CsdlPropertyEntity.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class CsdlPropertyEntity implements CsdlProperty {
4141

4242
@JsonProperty("$Type")
4343
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
44-
public String type;
44+
public String type = TYPE_DEFAULT;
4545

4646
@JsonProperty("$Nullable")
4747
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@@ -70,6 +70,9 @@ public CsdlPropertyEntity generateFrom(CsdlDocument doc, Version version, String
7070
if (!et.getPrimaryKey().getKeyProperties().contains(ep)) {
7171
nullable = ep.isNullable();
7272
}
73+
if (collection) {
74+
nullable = false;
75+
}
7376
for (Annotation an : ep.getAnnotations()) {
7477
annotations.add(new CsdlAnnotation().generateFrom(doc, an));
7578
}
@@ -106,7 +109,7 @@ public void writeXml(String nameSpace, String name, Writer writer) throws IOExce
106109
if (collection) {
107110
typeString = "Collection(" + typeString + ")";
108111
}
109-
String nullableString = (nullable) ? " Nullable=\"" + Boolean.toString(nullable) + "\"" : "";
112+
String nullableString = (nullable) ? "" : " Nullable=\"" + Boolean.toString(nullable) + "\"";
110113
writer.write("<Property Name=\"" + name + "\" Type=\"" + typeString + "\"" + nullableString);
111114
if (annotations.isEmpty()) {
112115
writer.write(" />");

Plugins/OData/src/main/java/de/fraunhofer/iosb/ilt/frostserver/plugin/odata/metadata/CsdlPropertyNavigation.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class CsdlPropertyNavigation implements CsdlProperty {
3838

3939
@JsonProperty("$Collection")
4040
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
41-
public Boolean collection;
41+
public boolean collection;
4242

4343
@JsonProperty("$Partner")
4444
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@@ -50,7 +50,7 @@ public class CsdlPropertyNavigation implements CsdlProperty {
5050

5151
@JsonProperty("$Nullable")
5252
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
53-
public Boolean nullable;
53+
public boolean nullable;
5454

5555
@JsonIgnore
5656
private final List<CsdlAnnotation> annotations = new ArrayList<>();
@@ -64,7 +64,11 @@ public CsdlPropertyNavigation generateFrom(CsdlDocument doc, String nameSpace, N
6464
if (np.isEntitySet()) {
6565
collection = true;
6666
}
67-
nullable = np.isNullable();
67+
if (collection) {
68+
nullable = false;
69+
} else {
70+
nullable = np.isNullable();
71+
}
6872
for (Annotation an : np.getAnnotations()) {
6973
annotations.add(new CsdlAnnotation().generateFrom(doc, an));
7074
}
@@ -83,11 +87,11 @@ public Map<String, Object> otherProperties() {
8387
@Override
8488
public void writeXml(String nameSpace, String name, Writer writer) throws IOException {
8589
String finalType = type;
86-
if (collection != null && collection) {
90+
if (collection) {
8791
finalType = "Collection(" + type + ")";
8892
}
8993
String nullableString = "";
90-
if (nullable != null && nullable) {
94+
if (collection || !nullable) {
9195
nullableString = " Nullable=\"" + Boolean.toString(nullable) + "\"";
9296
}
9397
String partnerString = "";

0 commit comments

Comments
 (0)