Removed postfilter because polymorphism support has been added in query

This commit is contained in:
luca.frosini 2023-11-06 17:45:00 +01:00
parent 7409a8d278
commit 68c742eb09
1 changed files with 14 additions and 15 deletions

View File

@ -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.queries.json.base.relations.JsonQueryIsRelatedTo;
import org.gcube.informationsystem.resourceregistry.requests.RequestUtility; import org.gcube.informationsystem.resourceregistry.requests.RequestUtility;
import org.gcube.informationsystem.resourceregistry.requests.ServerRequestInfo; 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.types.TypesCache;
import org.gcube.informationsystem.resourceregistry.utils.OrientDBUtility; import org.gcube.informationsystem.resourceregistry.utils.OrientDBUtility;
import org.gcube.informationsystem.utils.TypeUtility; import org.gcube.informationsystem.utils.TypeUtility;
@ -159,25 +158,22 @@ public class JsonQuery {
JsonNode jsonNodeResult = null; JsonNode jsonNodeResult = null;
ElementManagement<?,?> erManagement = ElementManagementUtility.getERManagement(securityContext, oDatabaseDocument, ElementManagement<?,?> erManagement = ElementManagementUtility.getERManagement(securityContext, oDatabaseDocument,
element); 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 requestedType = entryPoint.getType();
String gotType = erManagement.getTypeName(); 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); CachedType<?> cachedType = TypesCache.getInstance().getCachedType(gotType);
if(cachedType.getSuperTypes().contains(requestedType)) {
if(requestedType.compareTo(gotType)==0 || cachedType.getSuperTypes().contains(requestedType)) {
erManagement.setAsEntryPoint(); erManagement.setAsEntryPoint();
jsonNodeResult = erManagement.serializeAsJsonNode(); jsonNodeResult = erManagement.serializeAsJsonNode();
arrayNode.add(jsonNodeResult); arrayNode.add(jsonNodeResult);
@ -187,6 +183,9 @@ public class JsonQuery {
continue; continue;
} }
*/
} catch(ResourceRegistryException e) { } catch(ResourceRegistryException e) {
logger.error("Unable to correctly serialize {}. It will be excluded from results. {}", logger.error("Unable to correctly serialize {}. It will be excluded from results. {}",