Fixed IsRelatedTo Query management

This commit is contained in:
Luca Frosini 2022-12-07 22:58:13 +01:00
parent fd1d9673b3
commit a134a93f02
4 changed files with 42 additions and 7 deletions

View File

@ -1,7 +1,6 @@
package org.gcube.informationsystem.resourceregistry.queries.json.base.relations;
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
import org.gcube.informationsystem.base.reference.AccessType;
import org.gcube.informationsystem.base.reference.Direction;
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
@ -109,7 +108,7 @@ public class JsonQueryIsRelatedTo extends JsonQueryRelation {
stringBuffer = jsonQueryResource.analize(stringBuffer);
StringBuffer buffer = new StringBuffer();
if(!entryPoint) {
if(requestedResourceType!=null) {
buffer.append("TRAVERSE ");
buffer.append(direction.opposite().name().toLowerCase());
buffer.append("V(\"");
@ -123,7 +122,7 @@ public class JsonQueryIsRelatedTo extends JsonQueryRelation {
buffer.append("\") FROM ( ");
buffer.append(stringBuffer);
buffer.append(")");
if(!entryPoint) {
if(requestedResourceType!=null) {
buffer.append(")");
}
stringBuffer = buffer;
@ -136,17 +135,16 @@ public class JsonQueryIsRelatedTo extends JsonQueryRelation {
jsonQueryResource.setEntryPoint(false);
stringBuffer = jsonQueryResource.analize(stringBuffer);
boolean entryPointOldValue = entryPoint;
// It is no more and entry point for the function traverseThisEdge
entryPoint = false;
stringBuffer = traverseThisEdge(stringBuffer);
// Restoring entryPoint indication
entryPoint = true;
entryPoint = entryPointOldValue;
}
return stringBuffer;
}
}

View File

@ -66,7 +66,7 @@ public class JsonQueryTest extends ContextTest {
@Test
public void testSingleCreateQuery() throws Exception {
File queriesDirectory = getQueriesDirectory();
File jsonQueryFile = new File(queriesDirectory, "query8.json");
File jsonQueryFile = new File(queriesDirectory, "query9.json");
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jsonNode = objectMapper.readTree(jsonQueryFile);
logger.info("Going to test the following JSON query {}", jsonNode.toString());

View File

@ -0,0 +1,36 @@
{
"@class": "SimpleFacet",
"_in": {
"@class": "ConsistsOf",
"source": {
"@class": "Configuration",
"consistsOf": [
{
"@class": "IsIdentifiedBy",
"target": {
"@class": "IdentifierFacet",
"value": "gcat-configuration"
}
}
],
"isRelatedTo": [
{
"@class": "IsCustomizedBy",
"source": {
"@class": "VirtualService",
"consistsOf": [
{
"@class": "IsIdentifiedBy",
"target": {
"@class": "SoftwareFacet",
"group": "org.gcube.data-catalogue",
"name": "catalogue-virtual-service"
}
}
]
}
}
]
}
}
}

View File

@ -0,0 +1 @@
SELECT FROM ( TRAVERSE inV("SimpleFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE outV("Configuration") FROM ( TRAVERSE inE("IsIdentifiedBy") FROM ( SELECT FROM ( TRAVERSE inV("IdentifierFacet") FROM ( TRAVERSE outE("IsIdentifiedBy") FROM ( TRAVERSE inV("Configuration") FROM ( TRAVERSE outE("IsCustomizedBy") FROM ( TRAVERSE outV("VirtualService") FROM ( TRAVERSE inE("IsIdentifiedBy") FROM ( SELECT FROM ( TRAVERSE inV("SoftwareFacet") FROM ( TRAVERSE outE("IsIdentifiedBy") FROM ( TRAVERSE outV("VirtualService") FROM ( SELECT FROM IsCustomizedBy)))) WHERE group = "org.gcube.data-catalogue" AND name = "catalogue-virtual-service"))))))) WHERE value = "gcat-configuration")))))