From 68c742eb094a4aa41b4f7e39cfab14a40e50a062 Mon Sep 17 00:00:00 2001 From: "luca.frosini" Date: Mon, 6 Nov 2023 17:45:00 +0100 Subject: [PATCH] Removed postfilter because polymorphism support has been added in query --- .../queries/json/JsonQuery.java | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/queries/json/JsonQuery.java b/src/main/java/org/gcube/informationsystem/resourceregistry/queries/json/JsonQuery.java index 4d4916d..45d6bee 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/queries/json/JsonQuery.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/queries/json/JsonQuery.java @@ -25,7 +25,6 @@ import org.gcube.informationsystem.resourceregistry.queries.json.base.relations. import org.gcube.informationsystem.resourceregistry.queries.json.base.relations.JsonQueryIsRelatedTo; import org.gcube.informationsystem.resourceregistry.requests.RequestUtility; import org.gcube.informationsystem.resourceregistry.requests.ServerRequestInfo; -import org.gcube.informationsystem.resourceregistry.types.CachedType; import org.gcube.informationsystem.resourceregistry.types.TypesCache; import org.gcube.informationsystem.resourceregistry.utils.OrientDBUtility; import org.gcube.informationsystem.utils.TypeUtility; @@ -159,25 +158,22 @@ public class JsonQuery { JsonNode jsonNodeResult = null; ElementManagement erManagement = ElementManagementUtility.getERManagement(securityContext, oDatabaseDocument, element); + erManagement.setAsEntryPoint(); + jsonNodeResult = erManagement.serializeAsJsonNode(); + arrayNode.add(jsonNodeResult); + if(limit > 0 && ++count >= limit) { + break; + } - // TODO remove this post filter using INSTANCEOF - // To support polymorphism we do not include = "TypeName" in query. So we need post processing filtering of results + /* + + // To support polymorphism we do not include @class = "TypeName" in query. So we need post processing filtering of results String requestedType = entryPoint.getType(); String gotType = erManagement.getTypeName(); - - if(requestedType.compareTo(gotType)==0) { - erManagement.setAsEntryPoint(); - jsonNodeResult = erManagement.serializeAsJsonNode(); - arrayNode.add(jsonNodeResult); - if(limit > 0 && ++count >= limit) { - break; - } - continue; - } - CachedType cachedType = TypesCache.getInstance().getCachedType(gotType); - if(cachedType.getSuperTypes().contains(requestedType)) { + + if(requestedType.compareTo(gotType)==0 || cachedType.getSuperTypes().contains(requestedType)) { erManagement.setAsEntryPoint(); jsonNodeResult = erManagement.serializeAsJsonNode(); arrayNode.add(jsonNodeResult); @@ -187,6 +183,9 @@ public class JsonQuery { continue; } + */ + + } catch(ResourceRegistryException e) { logger.error("Unable to correctly serialize {}. It will be excluded from results. {}",