diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/queries/json/base/JsonQueryERElement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/queries/json/base/JsonQueryERElement.java index c938329..c96dcd1 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/queries/json/base/JsonQueryERElement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/queries/json/base/JsonQueryERElement.java @@ -217,7 +217,7 @@ public abstract class JsonQueryERElement { } public StringBuffer createQuery(StringBuffer stringBuffer) throws SchemaNotFoundException, InvalidQueryException, SchemaException, ResourceRegistryException { - return createTraversalQuery(stringBuffer); + return createMatchQuery(stringBuffer); } public abstract StringBuffer createTraversalQuery(StringBuffer stringBuffer) throws SchemaNotFoundException, InvalidQueryException, SchemaException, ResourceRegistryException; diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/queries/json/base/relations/JsonQueryConsistsOf.java b/src/main/java/org/gcube/informationsystem/resourceregistry/queries/json/base/relations/JsonQueryConsistsOf.java index 28abb30..4e928c4 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/queries/json/base/relations/JsonQueryConsistsOf.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/queries/json/base/relations/JsonQueryConsistsOf.java @@ -151,6 +151,7 @@ public class JsonQueryConsistsOf extends JsonQueryRelation { jsonQueryFacet.setBreadcrumb(childrenBreadcrumb); jsonQueryFacet.setPosition(childrenPosition++); jsonQueryFacet.setTraverseBack(false); + jsonQueryFacet.setDirection(Direction.IN); newBuffer = jsonQueryFacet.createMatchQuery(newBuffer); } @@ -161,6 +162,7 @@ public class JsonQueryConsistsOf extends JsonQueryRelation { jsonQueryResource.setBreadcrumb(childrenBreadcrumb); jsonQueryResource.setPosition(childrenPosition++); jsonQueryResource.setTraverseBack(true); + jsonQueryResource.setDirection(Direction.OUT); newBuffer = jsonQueryResource.createMatchQuery(newBuffer); } diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/queries/JsonQueryTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/queries/JsonQueryTest.java index 49b769e..d7616eb 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/queries/JsonQueryTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/queries/JsonQueryTest.java @@ -42,6 +42,36 @@ public class JsonQueryTest extends ContextTest { return new File(resourcesDirectory, "projection-queries"); } + protected boolean compareQueries(StringBuffer createdSb, StringBuffer expectedSb) { + return compareQueries(createdSb.toString(), expectedSb.toString()); + } + + protected String normalizeString(String s) { + return s.replaceAll("\n{1,}", "") + .replaceAll("\r{1,}", "") + .replaceAll("\t{1,}", "") + .replaceAll("\\s{2,}", " ") + .replaceAll("\\(\\s{1,}", "(") + .replaceAll("\\s{1,}\\(", "(") + .replaceAll("\\)\\s{1,}", ")") + .replaceAll("\\s{1,}\\)", ")"); + } + + protected boolean compareQueries(String createdString, String expectedString) { + String created = normalizeString(createdString); + String expected = normalizeString(expectedString); + logger.debug(created); + logger.debug(expected); + return created.compareTo(expected)==0 ? true : false; + } + + @Test + public void testCompares() throws Exception { + String a = "))\n\t\r ) ) ) )"; + String b = "))))))"; + Assert.assertTrue(compareQueries(a, b)); + } + @Test public void testJsonQueries() throws Exception { ContextTest.setContextByName(DEVVRE); @@ -69,7 +99,7 @@ public class JsonQueryTest extends ContextTest { logger.info("Created Query from JSON: {}", createdStringBuffer.toString()); StringBuffer expectedStringBuffer = new StringBuffer(); - File expectedQueryFile = new File(queriesDirectory, jsonQueryFile.getName().replace("json", "oquery")); + File expectedQueryFile = new File(queriesDirectory, jsonQueryFile.getName().replace("json", "match.oquery")); try(BufferedReader br = new BufferedReader(new FileReader(expectedQueryFile))) { for(String line; (line = br.readLine()) != null; ) { expectedStringBuffer.append(line); @@ -77,8 +107,7 @@ public class JsonQueryTest extends ContextTest { } logger.info("Expected Query from JSON: {}", expectedStringBuffer.toString()); - - Assert.assertTrue(createdStringBuffer.toString().compareTo(expectedStringBuffer.toString())==0); + Assert.assertTrue(compareQueries(createdStringBuffer, expectedStringBuffer)); String result = jsonQuery.query(); logger.info("Result : {}", result); @@ -88,7 +117,7 @@ public class JsonQueryTest extends ContextTest { @Test public void testSingleCreateQuery() throws Exception { File queriesDirectory = getQueriesDirectory(); - File jsonQueryFile = new File(queriesDirectory, "query10.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()); @@ -100,7 +129,7 @@ public class JsonQueryTest extends ContextTest { logger.info("Created Query from JSON: {}", createdStringBuffer.toString()); StringBuffer expectedStringBuffer = new StringBuffer(); - File expectedQueryFile = new File(queriesDirectory, jsonQueryFile.getName().replace("json", "oquery")); + File expectedQueryFile = new File(queriesDirectory, jsonQueryFile.getName().replace("json", "match.oquery")); try(BufferedReader br = new BufferedReader(new FileReader(expectedQueryFile))) { for(String line; (line = br.readLine()) != null; ) { expectedStringBuffer.append(line); @@ -108,8 +137,7 @@ public class JsonQueryTest extends ContextTest { } logger.info("Expected Query from JSON: {}", expectedStringBuffer.toString()); - - Assert.assertTrue(createdStringBuffer.toString().compareTo(expectedStringBuffer.toString())==0); + Assert.assertTrue(compareQueries(createdStringBuffer, expectedStringBuffer)); String result = jsonQuery.query(); logger.info("Result : {}", result); @@ -220,7 +248,7 @@ public class JsonQueryTest extends ContextTest { logger.info("Expected Query from JSON: {}", expectedStringBuffer.toString()); - Assert.assertTrue(createdStringBuffer.toString().replaceAll("\n", "").compareTo(expectedStringBuffer.toString().replaceAll("\n", ""))==0); + Assert.assertTrue(compareQueries(createdStringBuffer, expectedStringBuffer)); // String result = jsonQuery.query(); // logger.info("Result : {}", result); @@ -257,8 +285,7 @@ public class JsonQueryTest extends ContextTest { } logger.info("Expected Query from JSON: {}", expectedStringBuffer.toString()); - - Assert.assertTrue(createdStringBuffer.toString().replaceAll("\n", "").compareTo(expectedStringBuffer.toString().replaceAll("\n", ""))==0); + Assert.assertTrue(compareQueries(createdStringBuffer, expectedStringBuffer)); //String result = jsonQuery.query(); //logger.info("Result : {}", result); diff --git a/src/test/resources/queries/query1.match.oquery b/src/test/resources/queries/query1.match.oquery index 4231bb2..186da35 100644 --- a/src/test/resources/queries/query1.match.oquery +++ b/src/test/resources/queries/query1.match.oquery @@ -1,10 +1,17 @@ SELECT EXPAND(ret) FROM ( - MATCH - {class: EService, as: eservice, where: ($currentMatch['@class'] INSTANCEOF 'EService')} - .outE('IsIdentifiedBy').inV('SoftwareFacet') {where: (($currentMatch['@class'] INSTANCEOF 'SoftwareFacet') AND name='data-transfer-service' AND group='DataTransfer')} - .inE('IsIdentifiedBy').outV('Eservice') {where: ($matched.eservice == $currentMatch)} - .outE('ConsistsOf') {where: (propagationConstraint.add='propagate')} - .inV('StateFacet') {where: (($currentMatch['@class'] INSTANCEOF 'StateFacet') AND value='down')} - RETURN - DISTINCT(eservice) as ret + MATCH + {class: EService, as: eservice0, where: ($currentMatch['@class'] INSTANCEOF 'EService')} + + .outE('ConsistsOf') { as: consistsof00, where: (($currentMatch['@class'] INSTANCEOF 'ConsistsOf') AND (consistsof00.propagationConstraint.add = "propagate"))} + .inV('StateFacet') { as: statefacet000, where: (($currentMatch['@class'] INSTANCEOF 'StateFacet') AND (statefacet000.value = "down"))} + .inE('ConsistsOf') { where: ($matched.consistsof00 == $currentMatch)} + .outV('EService') { where: ($matched.eservice0 == $currentMatch)} + + .outE('IsIdentifiedBy') { as: isidentifiedby01, where: ($currentMatch['@class'] INSTANCEOF 'IsIdentifiedBy')} + .inV('SoftwareFacet') { as: softwarefacet010, where: (($currentMatch['@class'] INSTANCEOF 'SoftwareFacet') AND (softwarefacet010.name = "data-transfer-service" AND softwarefacet010.group = "DataTransfer"))} + .inE('IsIdentifiedBy') { where: ($matched.isidentifiedby01 == $currentMatch)} + .outV('EService') { where: ($matched.eservice0 == $currentMatch)} + + RETURN + DISTINCT(eservice0) as ret ) \ No newline at end of file diff --git a/src/test/resources/queries/query1.oquery b/src/test/resources/queries/query1.oquery deleted file mode 100644 index a1884cf..0000000 --- a/src/test/resources/queries/query1.oquery +++ /dev/null @@ -1 +0,0 @@ -SELECT FROM ( TRAVERSE outV("EService") FROM ( TRAVERSE inE("IsIdentifiedBy") FROM ( SELECT FROM ( TRAVERSE inV("SoftwareFacet") FROM ( TRAVERSE outE("IsIdentifiedBy") FROM ( TRAVERSE outV("EService") FROM ( SELECT FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM StateFacet WHERE value = "down")) WHERE propagationConstraint.add = "propagate")))) WHERE name = "data-transfer-service" AND group = "DataTransfer"))) WHERE @class INSTANCEOF "EService" \ No newline at end of file diff --git a/src/test/resources/queries/query1-indented.oquery b/src/test/resources/queries/query1.traversal.oquery similarity index 100% rename from src/test/resources/queries/query1-indented.oquery rename to src/test/resources/queries/query1.traversal.oquery diff --git a/src/test/resources/queries/query2.match.oquery b/src/test/resources/queries/query2.match.oquery index 2cb03f2..6b232aa 100644 --- a/src/test/resources/queries/query2.match.oquery +++ b/src/test/resources/queries/query2.match.oquery @@ -1,15 +1,27 @@ SELECT EXPAND(ret) FROM ( - MATCH - {class: EService, as: eservice, where: ($currentMatch['@class'] INSTANCEOF 'EService')} - .outE('IsIdentifiedBy').inV('SoftwareFacet') {where: (($currentMatch['@class'] INSTANCEOF 'SoftwareFacet') AND name='data-transfer-service' AND group='DataTransfer')} - .inE('IsIdentifiedBy').outV('Eservice') {where: ($matched.eservice == $currentMatch)} - .outE('ConsistsOf') {where: (propagationConstraint.add='propagate')} - .inV('StateFacet') {where: (($currentMatch['@class'] INSTANCEOF 'StateFacet') AND value='down')} - .inE('ConsistsOf').outV('Eservice') {where: ($matched.eservice == $currentMatch)} - .outE('ConsistsOf').inV('AccessPointFacet') {where: (($currentMatch['@class'] INSTANCEOF 'AccessPointFacet') AND endpoint='http://smartexecutor1.dev.int.d4science.net:80/data-transfer-service/gcube/resource')} - .inE('ConsistsOf').outV('Eservice') {where: ($matched.eservice == $currentMatch)} - .inE('Activates') {where: (id='bd89a311-780d-4efe-93e5-08281e53bce7')} - .outV('HostingNode') {where: (id='44fac329-eed5-4f18-90ba-a54d5aad316e')} - RETURN - DISTINCT(eservice) as ret + MATCH + {class: EService, as: eservice0, where: ($currentMatch['@class'] INSTANCEOF 'EService')} + + .inE('Activates') { as: activates00, where: (($currentMatch['@class'] INSTANCEOF 'Activates') AND (activates00.id = "bd89a311-780d-4efe-93e5-08281e53bce7"))} + .outV('HostingNode') { as: hostingnode000, where: (($currentMatch['@class'] INSTANCEOF 'HostingNode') AND (hostingnode000.id = "44fac329-eed5-4f18-90ba-a54d5aad316e"))} + .outE('Activates') { where: ($matched.activates00 == $currentMatch)} + .inV('EService') { where: ($matched.eservice0 == $currentMatch)} + + .outE('ConsistsOf') { as: consistsof01, where: (($currentMatch['@class'] INSTANCEOF 'ConsistsOf') AND (consistsof01.propagationConstraint.add = "propagate"))} + .inV('StateFacet') { as: statefacet010, where: (($currentMatch['@class'] INSTANCEOF 'StateFacet') AND (statefacet010.value = "down"))} + .inE('ConsistsOf') { where: ($matched.consistsof01 == $currentMatch)} + .outV('EService') { where: ($matched.eservice0 == $currentMatch)} + + .outE('IsIdentifiedBy') { as: isidentifiedby02, where: ($currentMatch['@class'] INSTANCEOF 'IsIdentifiedBy')} + .inV('SoftwareFacet') { as: softwarefacet020, where: (($currentMatch['@class'] INSTANCEOF 'SoftwareFacet') AND (softwarefacet020.name = "data-transfer-service" AND softwarefacet020.group = "DataTransfer"))} + .inE('IsIdentifiedBy') { where: ($matched.isidentifiedby02 == $currentMatch)} + .outV('EService') { where: ($matched.eservice0 == $currentMatch)} + + .outE('ConsistsOf') { as: consistsof03, where: ($currentMatch['@class'] INSTANCEOF 'ConsistsOf')} + .inV('AccessPointFacet') { as: accesspointfacet030, where: (($currentMatch['@class'] INSTANCEOF 'AccessPointFacet') AND (accesspointfacet030.endpoint = "http://smartexecutor1.dev.int.d4science.net:80/data-transfer-service/gcube/resource"))} + .inE('ConsistsOf') { where: ($matched.consistsof03 == $currentMatch)} + .outV('EService') { where: ($matched.eservice0 == $currentMatch)} + + RETURN + DISTINCT(eservice0) as ret ) \ No newline at end of file diff --git a/src/test/resources/queries/query2.oquery b/src/test/resources/queries/query2.oquery deleted file mode 100644 index 4d7d727..0000000 --- a/src/test/resources/queries/query2.oquery +++ /dev/null @@ -1 +0,0 @@ -SELECT FROM ( TRAVERSE outV("EService") FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("AccessPointFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE outV("EService") FROM ( TRAVERSE inE("IsIdentifiedBy") FROM ( SELECT FROM ( TRAVERSE inV("SoftwareFacet") FROM ( TRAVERSE outE("IsIdentifiedBy") FROM ( TRAVERSE outV("EService") FROM ( SELECT FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("StateFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE inV("EService") FROM ( SELECT FROM ( TRAVERSE outE("Activates") FROM ( SELECT FROM HostingNode WHERE id = "44fac329-eed5-4f18-90ba-a54d5aad316e")) WHERE id = "bd89a311-780d-4efe-93e5-08281e53bce7")))) WHERE value = "down")) WHERE propagationConstraint.add = "propagate")))) WHERE name = "data-transfer-service" AND group = "DataTransfer"))))) WHERE endpoint = "http://smartexecutor1.dev.int.d4science.net:80/data-transfer-service/gcube/resource"))) WHERE @class INSTANCEOF "EService" \ No newline at end of file diff --git a/src/test/resources/queries/query2-indented.oquery b/src/test/resources/queries/query2.traversal.oquery similarity index 100% rename from src/test/resources/queries/query2-indented.oquery rename to src/test/resources/queries/query2.traversal.oquery diff --git a/src/test/resources/queries/query3.match.oquery b/src/test/resources/queries/query3.match.oquery index 51decfe..5c76822 100644 --- a/src/test/resources/queries/query3.match.oquery +++ b/src/test/resources/queries/query3.match.oquery @@ -1,15 +1,31 @@ SELECT EXPAND(ret) FROM ( - MATCH - {class: EService, as: eservice, where: ($currentMatch['@class'] INSTANCEOF 'EService')} - .outE('IsIdentifiedBy').inV('SoftwareFacet') {where: (($currentMatch['@class'] INSTANCEOF 'SoftwareFacet') AND name='data-transfer-service' AND group='DataTransfer')} - .inE('IsIdentifiedBy').outV('Eservice') {where: ($matched.eservice == $currentMatch)} - .outE('ConsistsOf') {where: (propagationConstraint.add='propagate')} - .inV('StateFacet') {where: (($currentMatch['@class'] INSTANCEOF 'StateFacet') AND value='ready')} - .inE('ConsistsOf').outV('Eservice') {where: ($matched.eservice == $currentMatch)} - .outE('ConsistsOf').inV('AccessPointFacet') {where: (($currentMatch['@class'] INSTANCEOF 'AccessPointFacet') AND endpoint='http://smartexecutor1.dev.int.d4science.net:80/data-transfer-service/gcube/resource')} - .inE('ConsistsOf').outV('Eservice') {where: ($matched.eservice == $currentMatch)} - .inE('Activates').outV('HostingNode').outE('ConsistsOf').inV('CPUFacet') {where: (($currentMatch['@class'] INSTANCEOF 'CPUFacet') AND vendor='GenuineIntel')} - - RETURN - DISTINCT(eservice) as ret + MATCH + {class: EService, as: eservice0, where: ($currentMatch['@class'] INSTANCEOF 'EService')} + + .inE('Activates') { as: activates00, where: ($currentMatch['@class'] INSTANCEOF 'Activates')} + .outV('HostingNode') { as: hostingnode000, where: ($currentMatch['@class'] INSTANCEOF 'HostingNode')} + .outE('ConsistsOf') { as: consistsof0000, where: ($currentMatch['@class'] INSTANCEOF 'ConsistsOf')} + .inV('CPUFacet') { as: cpufacet00000, where: (($currentMatch['@class'] INSTANCEOF 'CPUFacet') AND (cpufacet00000.vendor = "GenuineIntel"))} + .inE('ConsistsOf') { where: ($matched.consistsof0000 == $currentMatch)} + .outV('HostingNode') { where: ($matched.hostingnode000 == $currentMatch)} + .outE('Activates') { where: ($matched.activates00 == $currentMatch)} + .inV('EService') { where: ($matched.eservice0 == $currentMatch)} + + .outE('ConsistsOf') { as: consistsof01, where: (($currentMatch['@class'] INSTANCEOF 'ConsistsOf') AND (consistsof01.propagationConstraint.add = "propagate"))} + .inV('StateFacet') { as: statefacet010, where: (($currentMatch['@class'] INSTANCEOF 'StateFacet') AND (statefacet010.value = "down"))} + .inE('ConsistsOf') { where: ($matched.consistsof01 == $currentMatch)} + .outV('EService') { where: ($matched.eservice0 == $currentMatch)} + + .outE('IsIdentifiedBy') { as: isidentifiedby02, where: ($currentMatch['@class'] INSTANCEOF 'IsIdentifiedBy')} + .inV('SoftwareFacet') { as: softwarefacet020, where: (($currentMatch['@class'] INSTANCEOF 'SoftwareFacet') AND (softwarefacet020.name = "data-transfer-service" AND softwarefacet020.group = "DataTransfer"))} + .inE('IsIdentifiedBy') { where: ($matched.isidentifiedby02 == $currentMatch)} + .outV('EService') { where: ($matched.eservice0 == $currentMatch)} + + .outE('ConsistsOf') { as: consistsof03, where: ($currentMatch['@class'] INSTANCEOF 'ConsistsOf')} + .inV('AccessPointFacet') { as: accesspointfacet030, where: (($currentMatch['@class'] INSTANCEOF 'AccessPointFacet') AND (accesspointfacet030.endpoint = "http://pc-frosini.isti.cnr.it:8080/data-transfer-service/gcube/service"))} + .inE('ConsistsOf') { where: ($matched.consistsof03 == $currentMatch)} + .outV('EService') { where: ($matched.eservice0 == $currentMatch)} + + RETURN + DISTINCT(eservice0) as ret ) \ No newline at end of file diff --git a/src/test/resources/queries/query3.oquery b/src/test/resources/queries/query3.oquery deleted file mode 100644 index 62c7059..0000000 --- a/src/test/resources/queries/query3.oquery +++ /dev/null @@ -1 +0,0 @@ -SELECT FROM ( TRAVERSE outV("EService") FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("AccessPointFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE outV("EService") FROM ( TRAVERSE inE("IsIdentifiedBy") FROM ( SELECT FROM ( TRAVERSE inV("SoftwareFacet") FROM ( TRAVERSE outE("IsIdentifiedBy") FROM ( TRAVERSE outV("EService") FROM ( SELECT FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("StateFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE inV("EService") FROM ( TRAVERSE outE("Activates") FROM ( TRAVERSE outV("HostingNode") FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM CPUFacet WHERE vendor = "GenuineIntel"))))))) WHERE value = "down")) WHERE propagationConstraint.add = "propagate")))) WHERE name = "data-transfer-service" AND group = "DataTransfer"))))) WHERE endpoint = "http://pc-frosini.isti.cnr.it:8080/data-transfer-service/gcube/service"))) WHERE @class INSTANCEOF "EService" \ No newline at end of file diff --git a/src/test/resources/queries/query3-indented.oquery b/src/test/resources/queries/query3.traversal.oquery similarity index 100% rename from src/test/resources/queries/query3-indented.oquery rename to src/test/resources/queries/query3.traversal.oquery diff --git a/src/test/resources/queries/query4.match.oquery b/src/test/resources/queries/query4.match.oquery index 31c3f5c..4f947b8 100644 --- a/src/test/resources/queries/query4.match.oquery +++ b/src/test/resources/queries/query4.match.oquery @@ -1,7 +1,15 @@ +DA FIXARE + SELECT EXPAND(ret) FROM ( - MATCH - {class: StateFacet, as: statefacet, where: (($currentMatch['@class'] INSTANCEOF 'StateFacet') AND value='down')} - .inE('ConsistsOf').outV('Eservice') {where: (($currentMatch['@class'] INSTANCEOF 'EService') AND id='93995af0-4f95-4816-a53e-3e1bc27ef475')} - RETURN - DISTINCT(statefacet) as ret + MATCH + {class: StateFacet, as: statefacet0, where: (($currentMatch['@class'] INSTANCEOF 'StateFacet') AND (statefacet0.value = "down"))} + + DOVREBBE ESSERE consistsof00 e tutto di conseguenza + .outE('ConsistsOf') { as: consistsof0, where: ($currentMatch['@class'] INSTANCEOF 'ConsistsOf')} + .outV('EService') { as: eservice00, where: (($currentMatch['@class'] INSTANCEOF 'EService') AND (eservice00.id = "93995af0-4f95-4816-a53e-3e1bc27ef475"))} +MANCA -> .outE('ConsistsOf') { where: ($matched.consistsof0 == $currentMatch)} +MANCA -> .inV('StateFacet') { where: ($matched.statefacet0 == $currentMatch)} + + RETURN + DISTINCT(statefacet0) as ret ) \ No newline at end of file diff --git a/src/test/resources/queries/query4.oquery b/src/test/resources/queries/query4.oquery deleted file mode 100644 index 3dd1f7b..0000000 --- a/src/test/resources/queries/query4.oquery +++ /dev/null @@ -1 +0,0 @@ -SELECT FROM ( TRAVERSE inV("StateFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( SELECT FROM EService WHERE id = "93995af0-4f95-4816-a53e-3e1bc27ef475"))) WHERE value = "down" AND @class INSTANCEOF "StateFacet" \ No newline at end of file diff --git a/src/test/resources/queries/query4-indented.oquery b/src/test/resources/queries/query4.traversal.oquery similarity index 100% rename from src/test/resources/queries/query4-indented.oquery rename to src/test/resources/queries/query4.traversal.oquery diff --git a/src/test/resources/queries/query5.match.oquery b/src/test/resources/queries/query5.match.oquery index 5675cf1..05adbf5 100644 --- a/src/test/resources/queries/query5.match.oquery +++ b/src/test/resources/queries/query5.match.oquery @@ -1,20 +1,12 @@ SELECT EXPAND(ret) FROM ( - MATCH - {class: StateFacet, as: statefacet, where: (($currentMatch['@class'] INSTANCEOF 'StateFacet') AND value='down')} - .inE('ConsistsOf').outV('Eservice') { - where: ( - ($currentMatch['@class'] INSTANCEOF 'EService') AND - ( - ( - id='93995af0-4f95-4816-a53e-3e1bc27ef475' AND metadata.createdBy <> 'luca.frosini' - ) - OR - ( - id='bd4402a0-2b72-41c5-a970-321343649e7d' AND metadata.createdBy = 'DataTransfer:data-transfer-service:smartexecutor1.dev.int.d4science.net_80' - ) - ) - ) - } - RETURN - DISTINCT(statefacet) as ret + MATCH + {class: StateFacet, as: statefacet0, where: (($currentMatch['@class'] INSTANCEOF 'StateFacet') AND (statefacet0.value = "down"))} + + DOVREBBE ESSERE consistsof00 + .outE('ConsistsOf') { as: consistsof0, where: ($currentMatch['@class'] INSTANCEOF 'ConsistsOf')} + .outV('EService') { as: eservice00, where: (($currentMatch['@class'] INSTANCEOF 'EService') AND (((eservice00.id = "93995af0-4f95-4816-a53e-3e1bc27ef475" AND eservice00.metadata.createdBy <> "luca.frosini") OR (eservice00.id = "bd4402a0-2b72-41c5-a970-321343649e7d" AND eservice00.metadata.createdBy = "DataTransfer:data-transfer-service:smartexecutor1.dev.int.d4science.net_80"))))} +MANCA -> .outE('ConsistsOf') { where: ($matched.consistsof0 == $currentMatch)} +MANCA -> .inV('StateFacet') { where: ($matched.statefacet0 == $currentMatch)} + RETURN + DISTINCT(statefacet0) as ret ) \ No newline at end of file diff --git a/src/test/resources/queries/query5.oquery b/src/test/resources/queries/query5.oquery deleted file mode 100644 index adc81f2..0000000 --- a/src/test/resources/queries/query5.oquery +++ /dev/null @@ -1 +0,0 @@ -SELECT FROM ( TRAVERSE inV("StateFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( SELECT FROM EService WHERE ((id = "93995af0-4f95-4816-a53e-3e1bc27ef475" AND metadata.createdBy <> "luca.frosini") OR (id = "bd4402a0-2b72-41c5-a970-321343649e7d" AND metadata.createdBy = "DataTransfer:data-transfer-service:smartexecutor1.dev.int.d4science.net_80"))))) WHERE value = "down" AND @class INSTANCEOF "StateFacet" \ No newline at end of file diff --git a/src/test/resources/queries/query5-indented.oquery b/src/test/resources/queries/query5.traversal.oquery similarity index 100% rename from src/test/resources/queries/query5-indented.oquery rename to src/test/resources/queries/query5.traversal.oquery diff --git a/src/test/resources/queries/query6.match.oquery b/src/test/resources/queries/query6.match.oquery index 6c8c390..7e5092e 100644 --- a/src/test/resources/queries/query6.match.oquery +++ b/src/test/resources/queries/query6.match.oquery @@ -1,17 +1,31 @@ SELECT EXPAND(ret) FROM ( - MATCH - {class: EService, as: eservice, where: (($currentMatch['@class'] INSTANCEOF 'EService') AND id="93995af0-4f95-4816-a53e-3e1bc27ef475")} - .outE('IsIdentifiedBy').inV('SoftwareFacet') {where: (($currentMatch['@class'] INSTANCEOF 'SoftwareFacet') AND name='data-transfer-service' AND group='DataTransfer')} - .inE('IsIdentifiedBy').outV('Eservice') {where: ($matched.eservice == $currentMatch)} - .outE('ConsistsOf') {where: (propagationConstraint.add='propagate')} - .inV('StateFacet') {where: (($currentMatch['@class'] INSTANCEOF 'StateFacet') AND value='down')} - .inE('ConsistsOf').outV('Eservice') {where: ($matched.eservice == $currentMatch)} - .outE('ConsistsOf').inV('AccessPointFacet') {where: (($currentMatch['@class'] INSTANCEOF 'AccessPointFacet') AND endpoint='http://smartexecutor1.dev.int.d4science.net:80/data-transfer-service/gcube/resource')} - .inE('ConsistsOf').outV('Eservice') {where: ($matched.eservice == $currentMatch)} - .inE('Activates') {where: (id='bd89a311-780d-4efe-93e5-08281e53bce7')} - .outV('HostingNode') {where: (id='44fac329-eed5-4f18-90ba-a54d5aad316e')} - .outE('ConsistsOf').inV('CPUFacet') {where: (($currentMatch['@class'] INSTANCEOF 'CPUFacet') AND vendor='GenuineIntel')} - - RETURN - DISTINCT(eservice) as ret + MATCH + {class: EService, as: eservice0, where: (($currentMatch['@class'] INSTANCEOF 'EService') AND (eservice0.id = "93995af0-4f95-4816-a53e-3e1bc27ef475"))} + + .inE('Activates') { as: activates00, where: (($currentMatch['@class'] INSTANCEOF 'Activates') AND (activates00.id = "bd89a311-780d-4efe-93e5-08281e53bce7"))} + .outV('HostingNode') { as: hostingnode000, where: (($currentMatch['@class'] INSTANCEOF 'HostingNode') AND (hostingnode000.id = "44fac329-eed5-4f18-90ba-a54d5aad316e"))} + .outE('ConsistsOf') { as: consistsof0000, where: ($currentMatch['@class'] INSTANCEOF 'ConsistsOf')} + .inV('CPUFacet') { as: cpufacet00000, where: (($currentMatch['@class'] INSTANCEOF 'CPUFacet') AND (cpufacet00000.vendor = "GenuineIntel"))} + .inE('ConsistsOf') { where: ($matched.consistsof0000 == $currentMatch)} + .outV('HostingNode') { where: ($matched.hostingnode000 == $currentMatch)} + .outE('Activates') { where: ($matched.activates00 == $currentMatch)} + .inV('EService') { where: ($matched.eservice0 == $currentMatch)} + + .outE('ConsistsOf') { as: consistsof01, where: (($currentMatch['@class'] INSTANCEOF 'ConsistsOf') AND (consistsof01.propagationConstraint.add = "propagate"))} + .inV('StateFacet') { as: statefacet010, where: (($currentMatch['@class'] INSTANCEOF 'StateFacet') AND (statefacet010.value = "down"))} + .inE('ConsistsOf') { where: ($matched.consistsof01 == $currentMatch)} + .outV('EService') { where: ($matched.eservice0 == $currentMatch)} + + .outE('IsIdentifiedBy') { as: isidentifiedby02, where: ($currentMatch['@class'] INSTANCEOF 'IsIdentifiedBy')} + .inV('SoftwareFacet') { as: softwarefacet020, where: (($currentMatch['@class'] INSTANCEOF 'SoftwareFacet') AND (softwarefacet020.name = "data-transfer-service" AND softwarefacet020.group = "DataTransfer"))} + .inE('IsIdentifiedBy') { where: ($matched.isidentifiedby02 == $currentMatch)} + .outV('EService') { where: ($matched.eservice0 == $currentMatch)} + + .outE('ConsistsOf') { as: consistsof03, where: ($currentMatch['@class'] INSTANCEOF 'ConsistsOf')} + .inV('AccessPointFacet') { as: accesspointfacet030, where: (($currentMatch['@class'] INSTANCEOF 'AccessPointFacet') AND (accesspointfacet030.endpoint = "http://smartexecutor1.dev.int.d4science.net:80/data-transfer-service/gcube/resource"))} + .inE('ConsistsOf') { where: ($matched.consistsof03 == $currentMatch)} + .outV('EService') { where: ($matched.eservice0 == $currentMatch)} + + RETURN + DISTINCT(eservice0) as ret ) \ No newline at end of file diff --git a/src/test/resources/queries/query6.oquery b/src/test/resources/queries/query6.oquery deleted file mode 100644 index 90827f8..0000000 --- a/src/test/resources/queries/query6.oquery +++ /dev/null @@ -1 +0,0 @@ -SELECT FROM ( TRAVERSE outV("EService") FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("AccessPointFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE outV("EService") FROM ( TRAVERSE inE("IsIdentifiedBy") FROM ( SELECT FROM ( TRAVERSE inV("SoftwareFacet") FROM ( TRAVERSE outE("IsIdentifiedBy") FROM ( TRAVERSE outV("EService") FROM ( SELECT FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("StateFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE inV("EService") FROM ( SELECT FROM ( TRAVERSE outE("Activates") FROM ( SELECT FROM ( TRAVERSE outV("HostingNode") FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM CPUFacet WHERE vendor = "GenuineIntel"))) WHERE id = "44fac329-eed5-4f18-90ba-a54d5aad316e")) WHERE id = "bd89a311-780d-4efe-93e5-08281e53bce7")))) WHERE value = "down")) WHERE propagationConstraint.add = "propagate")))) WHERE name = "data-transfer-service" AND group = "DataTransfer"))))) WHERE endpoint = "http://smartexecutor1.dev.int.d4science.net:80/data-transfer-service/gcube/resource"))) WHERE id = "93995af0-4f95-4816-a53e-3e1bc27ef475" AND @class INSTANCEOF "EService" \ No newline at end of file diff --git a/src/test/resources/queries/query6-indented.oquery b/src/test/resources/queries/query6.traversal.oquery similarity index 100% rename from src/test/resources/queries/query6-indented.oquery rename to src/test/resources/queries/query6.traversal.oquery diff --git a/src/test/resources/queries/query7.match.oquery b/src/test/resources/queries/query7.match.oquery index ee328f1..084a83f 100644 --- a/src/test/resources/queries/query7.match.oquery +++ b/src/test/resources/queries/query7.match.oquery @@ -1,20 +1,14 @@ +DA FIXARE + SELECT EXPAND(ret) FROM ( - MATCH - {class: StateFacet, as: statefacet, where: ($currentMatch['@class'] INSTANCEOF 'StateFacet')} - .inE('ConsistsOf').outV('Eservice') { - where: ( - ($currentMatch['@class'] INSTANCEOF 'EService') AND - ( - ( - id='93995af0-4f95-4816-a53e-3e1bc27ef475' AND metadata.createdBy <> 'luca.frosini' - ) - OR - ( - id='bd4402a0-2b72-41c5-a970-321343649e7d' AND metadata.createdBy = 'DataTransfer:data-transfer-service:smartexecutor1.dev.int.d4science.net_80' - ) - ) - ) - } - RETURN - DISTINCT(statefacet) as ret + MATCH + {class: StateFacet, as: statefacet0, where: ($currentMatch['@class'] INSTANCEOF 'StateFacet')} + + DOVREBBE ESSERE consistsof00 + .outE('ConsistsOf') { as: consistsof0, where: ($currentMatch['@class'] INSTANCEOF 'ConsistsOf')} + .outV('EService') { as: eservice00, where: (($currentMatch['@class'] INSTANCEOF 'EService') AND (((eservice00.id = "93995af0-4f95-4816-a53e-3e1bc27ef475" AND eservice00.metadata.createdBy <> "luca.frosini") OR (eservice00.id = "bd4402a0-2b72-41c5-a970-321343649e7d" AND eservice00.metadata.createdBy = "DataTransfer:data-transfer-service:smartexecutor1.dev.int.d4science.net_80"))))} +MANCA -> .inE('ConsistsOf') { where: ($matched.consistsof0 == $currentMatch)} +MANCA -> .inV('StateFacet') { where: ($matched.statefacet0 == $currentMatch)} + RETURN + DISTINCT(statefacet0) as ret ) \ No newline at end of file diff --git a/src/test/resources/queries/query7.oquery b/src/test/resources/queries/query7.oquery deleted file mode 100644 index 44b7ed2..0000000 --- a/src/test/resources/queries/query7.oquery +++ /dev/null @@ -1 +0,0 @@ -SELECT FROM ( TRAVERSE inV("StateFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( SELECT FROM EService WHERE ((id = "93995af0-4f95-4816-a53e-3e1bc27ef475" AND metadata.createdBy <> "luca.frosini") OR (id = "bd4402a0-2b72-41c5-a970-321343649e7d" AND metadata.createdBy = "DataTransfer:data-transfer-service:smartexecutor1.dev.int.d4science.net_80"))))) WHERE @class INSTANCEOF "StateFacet" \ No newline at end of file diff --git a/src/test/resources/queries/query7-indented.oquery b/src/test/resources/queries/query7.traversal.oquery similarity index 100% rename from src/test/resources/queries/query7-indented.oquery rename to src/test/resources/queries/query7.traversal.oquery diff --git a/src/test/resources/queries/query8.match.oquery b/src/test/resources/queries/query8.match.oquery index 2ee7a08..81b864b 100644 --- a/src/test/resources/queries/query8.match.oquery +++ b/src/test/resources/queries/query8.match.oquery @@ -1,9 +1,23 @@ + +DA FIXARE + SELECT EXPAND(ret) FROM ( - MATCH - {class: CallsFor, as: callsfor, where: ($currentMatch['@class'] INSTANCEOF 'CallsFor')} - .inV('EService').outE('IsIdentifiedBy').inV('SoftwareFacet') {where: (($currentMatch['@class'] INSTANCEOF 'SoftwareFacet') AND name='gcat' AND group='org.gcube.data-catalogue')} - .inE('IsIdentifiedBy').outV('Eservice').outE('CallsFor') {where: ($matched.callsfor == $currentMatch)} - .outV('VirtualService').outE('IsIdentifiedBy').inV('SoftwareFacet') {where: (($currentMatch['@class'] INSTANCEOF 'SoftwareFacet') AND name='catalogue-virtual-service' AND group='org.gcube.data-catalogue')} - RETURN - DISTINCT(callsfor) as ret +MATCH + {class: CallsFor, as: callsfor0, where: ($currentMatch['@class'] INSTANCEOF 'CallsFor')} + + .inV('VirtualService') { as: virtualservice00, where: ($currentMatch['@class'] INSTANCEOF 'VirtualService')} + .outE('IsIdentifiedBy') { as: isidentifiedby000, where: ($currentMatch['@class'] INSTANCEOF 'IsIdentifiedBy')} + .inV('SoftwareFacet') { as: softwarefacet0000, where: (($currentMatch['@class'] INSTANCEOF 'SoftwareFacet') AND (softwarefacet0000.group = "org.gcube.data-catalogue" AND softwarefacet0000.name = "catalogue-virtual-service"))} + .inE('IsIdentifiedBy') { where: ($matched.isidentifiedby000 == $currentMatch)} + .outV('VirtualService') { where: ($matched.virtualservice00 == $currentMatch)} +MANCA -> .inE('CallsFor') { where: ($matched.callsfor0 == $currentMatch)} + + .outV('EService') { as: eservice01, where: ($currentMatch['@class'] INSTANCEOF 'EService')} + .outE('IsIdentifiedBy') { as: isidentifiedby010, where: ($currentMatch['@class'] INSTANCEOF 'IsIdentifiedBy')} + .inV('SoftwareFacet') { as: softwarefacet0100, where: (($currentMatch['@class'] INSTANCEOF 'SoftwareFacet') AND (softwarefacet0100.group = "org.gcube.data-catalogue" AND softwarefacet0100.name = "gcat"))} + .inE('IsIdentifiedBy') { where: ($matched.isidentifiedby010 == $currentMatch)} + .outV('EService') { where: ($matched.eservice01 == $currentMatch)} +MANCA -> .outE('CallsFor') { where: ($matched.callsfor0 == $currentMatch)} +RETURN + DISTINCT(callsfor0) as ret ) \ No newline at end of file diff --git a/src/test/resources/queries/query8.oquery b/src/test/resources/queries/query8.oquery deleted file mode 100644 index 6d37960..0000000 --- a/src/test/resources/queries/query8.oquery +++ /dev/null @@ -1 +0,0 @@ -SELECT FROM ( TRAVERSE inE("CallsFor") FROM ( TRAVERSE outV("VirtualService") FROM ( TRAVERSE inE("IsIdentifiedBy") FROM ( SELECT FROM ( TRAVERSE inV("SoftwareFacet") FROM ( TRAVERSE outE("IsIdentifiedBy") FROM ( TRAVERSE inV("VirtualService") FROM ( TRAVERSE outE("CallsFor") FROM ( TRAVERSE outV("EService") FROM ( TRAVERSE inE("IsIdentifiedBy") FROM ( SELECT FROM SoftwareFacet WHERE group = "org.gcube.data-catalogue" AND name = "gcat"))))))) WHERE group = "org.gcube.data-catalogue" AND name = "catalogue-virtual-service")))) WHERE @class INSTANCEOF "CallsFor" \ No newline at end of file diff --git a/src/test/resources/queries/query8-indented.oquery b/src/test/resources/queries/query8.traversal.oquery similarity index 100% rename from src/test/resources/queries/query8-indented.oquery rename to src/test/resources/queries/query8.traversal.oquery diff --git a/src/test/resources/queries/query9.match.oquery b/src/test/resources/queries/query9.match.oquery index 1af3750..dcbcc66 100644 --- a/src/test/resources/queries/query9.match.oquery +++ b/src/test/resources/queries/query9.match.oquery @@ -1,11 +1,30 @@ SELECT EXPAND(ret) FROM ( - MATCH - {class: SimpleFacet, as: simplefacet, where: ($currentMatch['@class'] INSTANCEOF 'SimpleFacet')} - .inE('ConsistsOf').outV('Configuration') {as: configuration, where: ($currentMatch['@class'] INSTANCEOF 'Configuration')} - .outE('IsIdentifiedBy').inV('IdentifierFacet') {where: (($currentMatch['@class'] INSTANCEOF 'IdentifierFacet') AND value='gcat-configuration')} - .inE('IsIdentifiedBy').outV('Configuration') {where: ($matched.configuration == $currentMatch)} - .outE('IsCustomizedBy').inV('VirtualService') - .outE('IsIdentifiedBy').inV('SoftwareFacet') {where: (($currentMatch['@class'] INSTANCEOF 'SoftwareFacet') AND name='catalogue-virtual-service' AND group='org.gcube.data-catalogue')} - RETURN - DISTINCT(simplefacet) as ret +MATCH + {class: SimpleFacet, as: simplefacet0, where: ($currentMatch['@class'] INSTANCEOF 'SimpleFacet')} + + DOVREBBE ESSERE consistsof00 e tutto di conseguenza + .outE('ConsistsOf') { as: consistsof0, where: ($currentMatch['@class'] INSTANCEOF 'ConsistsOf')} + .outV('Configuration') { as: configuration00, where: ($currentMatch['@class'] INSTANCEOF 'Configuration')} + .inE('IsCustomizedBy') { as: iscustomizedby000, where: ($currentMatch['@class'] INSTANCEOF 'IsCustomizedBy')} + .outV('VirtualService') { as: virtualservice0000, where: ($currentMatch['@class'] INSTANCEOF 'VirtualService')} + .outE('IsIdentifiedBy') { as: isidentifiedby00000, where: ($currentMatch['@class'] INSTANCEOF 'IsIdentifiedBy')} + .inV('SoftwareFacet') { as: softwarefacet000000, where: (($currentMatch['@class'] INSTANCEOF 'SoftwareFacet') AND (softwarefacet000000.group = "org.gcube.data-catalogue" AND softwarefacet000000.name = "catalogue-virtual-service"))} + .inE('IsIdentifiedBy') { where: ($matched.isidentifiedby00000 == $currentMatch)} + .outV('VirtualService') { where: ($matched.virtualservice0000 == $currentMatch)} + .outE('IsCustomizedBy') { where: ($matched.iscustomizedby000 == $currentMatch)} + .inV('Configuration') { where: ($matched.configuration00 == $currentMatch)} +MANCA -> .outE('ConsistsOf') { where: ($matched.consistsof0 == $currentMatch)} +MANCA -> .inV('SimpleFacet') { where: ($matched.simplefacet0 == $currentMatch)} + + + .outE('IsIdentifiedBy') { as: isidentifiedby001, where: ($currentMatch['@class'] INSTANCEOF 'IsIdentifiedBy')} + .inV('IdentifierFacet') { as: identifierfacet0010, where: (($currentMatch['@class'] INSTANCEOF 'IdentifierFacet') AND (identifierfacet0010.value = "gcat-configuration"))} + .inE('IsIdentifiedBy') { where: ($matched.isidentifiedby001 == $currentMatch)} + .outV('Configuration') { where: ($matched.configuration00 == $currentMatch)} +MANCA -> .outE('ConsistsOf') { where: ($matched.consistsof0 == $currentMatch)} +MANCA -> .inV('SimpleFacet') { where: ($matched.simplefacet0 == $currentMatch)} + + +RETURN + DISTINCT(simplefacet0) as ret ) \ No newline at end of file diff --git a/src/test/resources/queries/query9.oquery b/src/test/resources/queries/query9.oquery deleted file mode 100644 index f335a3f..0000000 --- a/src/test/resources/queries/query9.oquery +++ /dev/null @@ -1 +0,0 @@ -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 SoftwareFacet WHERE group = "org.gcube.data-catalogue" AND name = "catalogue-virtual-service"))))))) WHERE value = "gcat-configuration"))))) WHERE @class INSTANCEOF "SimpleFacet" \ No newline at end of file diff --git a/src/test/resources/queries/query9-indented.oquery b/src/test/resources/queries/query9.traversal.oquery similarity index 100% rename from src/test/resources/queries/query9-indented.oquery rename to src/test/resources/queries/query9.traversal.oquery