diff --git a/CHANGELOG.md b/CHANGELOG.md index e955299dc..c027e31df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/FROST-Server.Core.Model/src/main/java/de/fraunhofer/iosb/ilt/frostserver/property/EntityPropertyCustomSelect.java b/FROST-Server.Core.Model/src/main/java/de/fraunhofer/iosb/ilt/frostserver/property/EntityPropertyCustomSelect.java index b90416a22..f01d2d59b 100644 --- a/FROST-Server.Core.Model/src/main/java/de/fraunhofer/iosb/ilt/frostserver/property/EntityPropertyCustomSelect.java +++ b/FROST-Server.Core.Model/src/main/java/de/fraunhofer/iosb/ilt/frostserver/property/EntityPropertyCustomSelect.java @@ -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) baseProperty, subPath); + if (baseProperty instanceof Map map) { + return CollectionsHelper.getFrom(map, subPath); + } + if (baseProperty instanceof ComplexValue cv) { + return CollectionsHelper.getFrom(cv, subPath); } return null; } diff --git a/FROST-Server.Core.Model/src/main/java/de/fraunhofer/iosb/ilt/frostserver/property/ComplexValue.java b/FROST-Server.Util/src/main/java/de/fraunhofer/iosb/ilt/frostserver/property/ComplexValue.java similarity index 100% rename from FROST-Server.Core.Model/src/main/java/de/fraunhofer/iosb/ilt/frostserver/property/ComplexValue.java rename to FROST-Server.Util/src/main/java/de/fraunhofer/iosb/ilt/frostserver/property/ComplexValue.java diff --git a/FROST-Server.Util/src/main/java/de/fraunhofer/iosb/ilt/frostserver/util/CollectionsHelper.java b/FROST-Server.Util/src/main/java/de/fraunhofer/iosb/ilt/frostserver/util/CollectionsHelper.java index 2b1ad1c4c..f7f884742 100644 --- a/FROST-Server.Util/src/main/java/de/fraunhofer/iosb/ilt/frostserver/util/CollectionsHelper.java +++ b/FROST-Server.Util/src/main/java/de/fraunhofer/iosb/ilt/frostserver/util/CollectionsHelper.java @@ -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; @@ -72,6 +73,10 @@ public static Object getFrom(final Map map, final List p return getFrom((Object) map, path); } + public static Object getFrom(final ComplexValue cv, final List path) { + return getFrom((Object) cv, path); + } + private static Object getFrom(final Object mapOrList, final List path) { Object currentEntry = mapOrList; int last = path.size(); @@ -79,6 +84,8 @@ private static Object getFrom(final Object mapOrList, final List path) { 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));