Skip to content

Commit

Permalink
Fixed deep select for complex properties in GeoJSON and CSV output
Browse files Browse the repository at this point in the history
  • Loading branch information
hylkevds committed Feb 24, 2024
1 parent 9a2da38 commit 58696f7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

**Internal changes & Bugfixes**
* Improved generated queries when fetching entities over a one-to-many relation.
* Fixed deep select for complex properties in GeoJSON and CSV output.


## Release version 2.3.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,11 @@ public Object getFrom(Entity entity) {
entityProperty = entity.getEntityType().getEntityProperty(entityPropertyName);
}
Object baseProperty = entity.getProperty(entityProperty);
if (baseProperty instanceof Map) {
return CollectionsHelper.getFrom((Map<String, Object>) baseProperty, subPath);
if (baseProperty instanceof Map map) {
return CollectionsHelper.getFrom(map, subPath);
}
if (baseProperty instanceof ComplexValue cv) {
return CollectionsHelper.getFrom(cv, subPath);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package de.fraunhofer.iosb.ilt.frostserver.util;

import de.fraunhofer.iosb.ilt.frostserver.property.ComplexValue;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -72,13 +73,19 @@ public static Object getFrom(final Map<String, Object> map, final List<String> p
return getFrom((Object) map, path);
}

public static Object getFrom(final ComplexValue cv, final List<String> path) {
return getFrom((Object) cv, path);
}

private static Object getFrom(final Object mapOrList, final List<String> path) {
Object currentEntry = mapOrList;
int last = path.size();
for (int idx = 0; idx < last; idx++) {
String key = path.get(idx);
if (currentEntry instanceof Map map) {
currentEntry = map.get(key);
} else if (currentEntry instanceof ComplexValue cv) {
currentEntry = cv.get(key);
} else if (currentEntry instanceof List list) {
try {
currentEntry = list.get(Integer.parseInt(key));
Expand Down

0 comments on commit 58696f7

Please sign in to comment.