From e0bfef4c49787fd66151011fa99f294bd6bba93c Mon Sep 17 00:00:00 2001 From: "luca.frosini" Date: Thu, 16 Nov 2023 12:02:17 +0100 Subject: [PATCH] Changing the generated query to support projection --- .../operators/ConditionalOperator.java | 20 ++++++++---- .../queries/operators/FieldOperator.java | 29 +++++++++++++++++ .../queries/operators/Function.java | 9 ++++++ .../operators/MatemathicsOperator.java | 11 ++++++- .../queries/JsonQueryTest.java | 6 ++-- src/test/resources/queries/query1.match.query | 10 ++++++ .../resources/queries/query2-indented.query | 6 ++-- src/test/resources/queries/query2.json | 6 ++-- src/test/resources/queries/query2.match.query | 15 +++++++++ src/test/resources/queries/query2.query | 2 +- src/test/resources/queries/query3.match.query | 32 +++++++++++++++++++ .../resources/queries/query4-indented.query | 7 ++++ src/test/resources/queries/query4.json | 2 +- src/test/resources/queries/query4.match.query | 7 ++++ src/test/resources/queries/query4.query | 2 +- .../resources/queries/query5-indented.query | 11 +++++++ src/test/resources/queries/query5.json | 26 +++++++++------ 17 files changed, 172 insertions(+), 29 deletions(-) create mode 100644 src/main/java/org/gcube/informationsystem/resourceregistry/queries/operators/FieldOperator.java create mode 100644 src/main/java/org/gcube/informationsystem/resourceregistry/queries/operators/Function.java create mode 100644 src/test/resources/queries/query1.match.query create mode 100644 src/test/resources/queries/query2.match.query create mode 100644 src/test/resources/queries/query3.match.query create mode 100644 src/test/resources/queries/query4-indented.query create mode 100644 src/test/resources/queries/query4.match.query create mode 100644 src/test/resources/queries/query5-indented.query diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/queries/operators/ConditionalOperator.java b/src/main/java/org/gcube/informationsystem/resourceregistry/queries/operators/ConditionalOperator.java index 115d6da..aef9f1d 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/queries/operators/ConditionalOperator.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/queries/operators/ConditionalOperator.java @@ -10,6 +10,9 @@ import org.gcube.informationsystem.types.PropertyTypeName.BaseTypeGroup; /** * @author Luca Frosini (ISTI - CNR) * See https://www.orientdb.com/docs/3.0.x/sql/SQL-Where.html + * https://www.orientdb.com/docs/3.0.x/sql/SQL-Syntax.html#conditions + * https://www.orientdb.com/docs/3.0.x/sql/SQL-Syntax.html#comparison-operators + * https://www.orientdb.com/docs/3.0.x/sql/SQL-Syntax.html#boolean-operators */ public enum ConditionalOperator { @@ -19,22 +22,25 @@ public enum ConditionalOperator { LT("_lt", " < ", BaseTypeGroup.ANY, "Matches values that are less than a specified value."), LTE("_lte", " <= ", BaseTypeGroup.ANY, "Matches values that are less than or equal to a specified value."), NE("_ne", " <> ", BaseTypeGroup.ANY, "Matches all values that are not equal to a specified value."), - BETWEEN("_between", " BETWEEN ", BaseTypeGroup.ANY, "The value is between a range. E.g. `price BETWEEN 10 AND 30`. It's equivalent to `price >= 10 AND price <= 30`."), + BETWEEN("_between", " BETWEEN %s AND %s", BaseTypeGroup.ANY, "Returns TRUE is a value is between two values, eg. 5 BETWEEN 1 AND 10. The value is between a range. E.g. `price BETWEEN 10 AND 30`. It's equivalent to `price >= 10 AND price <= 30`."), IS("_is", " IS ", BaseTypeGroup.ANY, "Used to test if a value is NULL"), - LIKE("_like", " LIKE ", BaseTypeGroup.STRING, "Similar to equals, but allow the wildcard '%' that means 'any'. E.g. `name LIKE 'Luk%'`"), + LIKE("_like", " LIKE ", BaseTypeGroup.STRING, "For strings, checks if a string contains another string. % is used as a wildcard, eg. 'foobar CONTAINS '%ooba%''. Similar to equals, but allow the wildcard '%' that means 'any'. E.g. `name LIKE 'Luk%'`"), CONTAINS_TEXT("_containsText", " CONTAINSTEXT ", BaseTypeGroup.STRING, "The string contains such text. E.g. `text CONTAINSTEXT 'jay'`"), - MATCHES("_matches", " MATCHES ", BaseTypeGroup.STRING, "Matches the string using a Regular Expression. E.g. `text MATCHES '\b[A-Z0-9.%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}\b'`"), + MATCHES("_matches", " MATCHES ", BaseTypeGroup.STRING, "Checks if a string matches a regular expression. Matches the string using a Regular Expression. E.g. `text MATCHES '\b[A-Z0-9.%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}\b'`"), - IN("_in", " IN ", BaseTypeGroup.COLLECTION, "Matches any of the values specified in an array. E.g. `name in ['European','Asiatic']`"), - CONTAINS("_contains", " CONTAINS ", BaseTypeGroup.COLLECTION, "True if the collection contains at least one element that satisfy the next condition. Condition can be a single item: in this case the behaviour is like the IN operator. E.g. `children contains (name = 'Luke')` - `map.values() contains (name = 'Luke')`"), + IN("_in", " IN ", BaseTypeGroup.COLLECTION, "The same as CONTAINS, but with inverted operands. Matches any of the values specified in an array. E.g. `name in ['European','Asiatic']`"), + CONTAINS("_contains", " CONTAINS ", BaseTypeGroup.COLLECTION, "Checks if the left collection contains the right element. The left argument has to be a colleciton, otherwise it returns FALSE. It's NOT the check of colleciton intersections, so ['a', 'b', 'c'] CONTAINS ['a', 'b'] will return FALSE, while ['a', 'b', 'c'] CONTAINS 'a' will return TRUE. True if the collection contains at least one element that satisfy the next condition. Condition can be a single item: in this case the behaviour is like the IN operator. E.g. `children contains (name = 'Luke')` - `map.values() contains (name = 'Luke')`"), CONTAINS_ALL("_containsAll", " CONTAINSALL ", BaseTypeGroup.COLLECTION, "True if all the elements of the collection satisfy the next condition. E.g. `children CONTAINSALL (name = 'Luke')`"), CONTAINS_ANY("_containsAny", " CONTAINSANY ", BaseTypeGroup.COLLECTION, "True if all the elements of the collection satisfy the next condition. E.g. `children CONTAINSANY (name = 'Luke')`"), - CONTAINS_KEY("_containsKey", " CONTAINSKEY ", BaseTypeGroup.MAP, "True if the map contains at least one key equals to the requested. You can also use map.keys() CONTAINS in place of it. E.g. `connections CONTAINSKEY 'Luke'`"), - CONTAINS_VALUE("_containsValue", " CONTAINSVALUE ", BaseTypeGroup.MAP , "True if the map contains at least one value equals to the requested. You can also use map.values() CONTAINS in place of it. E.g. `connections containsValue 10:3`"); + CONTAINS_KEY("_containsKey", " CONTAINSKEY ", BaseTypeGroup.MAP, "For maps, the same as for CONTAINS, but checks on the map keys. True if the map contains at least one key equals to the requested. You can also use map.keys() CONTAINS in place of it. E.g. `connections CONTAINSKEY 'Luke'`"), + CONTAINS_VALUE("_containsValue", " CONTAINSVALUE ", BaseTypeGroup.MAP , "For maps, the same as for CONTAINS, but checks on the map values. True if the map contains at least one value equals to the requested. You can also use map.values() CONTAINS in place of it. E.g. `connections containsValue 10:3`"), + IS_DEFINED("_isDefined", " IS DEFINED ", BaseTypeGroup.ANY, "Returns TRUE is a field is defined in a document"), + IS_NOT_DEFINED("_isNotDefined", " IS NOT DEFINED ", BaseTypeGroup.ANY, "Returns TRUE is a field is not defined in a document"); + protected final String operator; protected final String conditionalOperator; protected final BaseTypeGroup allowed; diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/queries/operators/FieldOperator.java b/src/main/java/org/gcube/informationsystem/resourceregistry/queries/operators/FieldOperator.java new file mode 100644 index 0000000..7410032 --- /dev/null +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/queries/operators/FieldOperator.java @@ -0,0 +1,29 @@ +package org.gcube.informationsystem.resourceregistry.queries.operators; + +/** + * @author Luca Frosini (ISTI - CNR) + * + * Methods: also called "Field Operators" + * + * SQL Methods are similar to SQL functions but they apply to values. + * In Object Oriented paradigm they are called "methods", as functions related to a class. + * So what's the difference between a function and a method? + * + * This is a SQL function: + * + * SELECT sum( salary ) FROM employee + * + * This is a SQL method: + * + * SELECT salary.toJSON() FROM employee + * + * As you can see the method is executed against a field/value. + * Methods can receive parameters, like functions. + * You can concatenate N operators in sequence. + * + * See https://orientdb.com/docs/3.0.x/sql/SQL-Where.html#methods + * http://orientdb.com/docs/3.0.x/sql/SQL-Methods.html + */ +public enum FieldOperator { + +} diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/queries/operators/Function.java b/src/main/java/org/gcube/informationsystem/resourceregistry/queries/operators/Function.java new file mode 100644 index 0000000..e7cb6c4 --- /dev/null +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/queries/operators/Function.java @@ -0,0 +1,9 @@ +package org.gcube.informationsystem.resourceregistry.queries.operators; + +/** + * @author Luca Frosini (ISTI - CNR) + * See https://www.orientdb.com/docs/3.0.x/sql/SQL-Functions.html + */ +public class Function { + +} diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/queries/operators/MatemathicsOperator.java b/src/main/java/org/gcube/informationsystem/resourceregistry/queries/operators/MatemathicsOperator.java index 11b8234..2dc2ab5 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/queries/operators/MatemathicsOperator.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/queries/operators/MatemathicsOperator.java @@ -7,7 +7,16 @@ import java.util.Set; /** * @author Luca Frosini (ISTI - CNR) - * See https://www.orientdb.com/docs/3.0.x/sql/SQL-Where.html + * + * OrientDB supports the eval() function to execute complex operations. Example: + * + * SELECT eval( "amount * 120 / 100 - discount" ) as finalPrice from Order + + * + * See https://www.orientdb.com/docs/3.0.x/sql/SQL-Where.html#mathematics-operators + * https://www.orientdb.com/docs/3.0.x/sql/SQL-Syntax.html#math-operators + * https://www.orientdb.com/docs/3.0.x/sql/SQL-Syntax.html#math-operators-precedence + * https://www.orientdb.com/docs/3.0.x/sql/SQL-Syntax.html#array-concatenation */ public enum MatemathicsOperator { 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 08e7578..68106f4 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/queries/JsonQueryTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/queries/JsonQueryTest.java @@ -81,7 +81,7 @@ public class JsonQueryTest extends ContextTest { @Test public void testSingleCreateQuery() throws Exception { File queriesDirectory = getQueriesDirectory(); - File jsonQueryFile = new File(queriesDirectory, "query9.json"); + File jsonQueryFile = new File(queriesDirectory, "query10.json"); ObjectMapper objectMapper = new ObjectMapper(); JsonNode jsonNode = objectMapper.readTree(jsonQueryFile); logger.info("Going to test the following JSON query {}", jsonNode.toString()); @@ -107,8 +107,8 @@ public class JsonQueryTest extends ContextTest { String result = jsonQuery.query(); logger.info("Result : {}", result); } - - public List testSingleQuery(int offset, int limit) throws Exception { + + protected List testSingleQuery(int offset, int limit) throws Exception { ContextTest.setContextByName(DEVVRE); File queriesDirectory = getQueriesDirectory(); File jsonQueryFile = new File(queriesDirectory, "query1.json"); diff --git a/src/test/resources/queries/query1.match.query b/src/test/resources/queries/query1.match.query new file mode 100644 index 0000000..e9d618e --- /dev/null +++ b/src/test/resources/queries/query1.match.query @@ -0,0 +1,10 @@ +SELECT EXPAND(eservice) 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 + eservice +) \ No newline at end of file diff --git a/src/test/resources/queries/query2-indented.query b/src/test/resources/queries/query2-indented.query index 3dc5112..29813da 100644 --- a/src/test/resources/queries/query2-indented.query +++ b/src/test/resources/queries/query2-indented.query @@ -18,9 +18,9 @@ SELECT FROM ( TRAVERSE inV("EService") FROM ( SELECT FROM ( TRAVERSE outE("Activates") FROM ( - SELECT FROM HostingNode WHERE id = "5fbc1a56-d450-4f0f-85c1-9b1684581717" + SELECT FROM HostingNode WHERE id = "44fac329-eed5-4f18-90ba-a54d5aad316e" ) - ) WHERE id = "d3f58e52-5346-47bc-b736-9d77a0b554ce" + ) WHERE id = "bd89a311-780d-4efe-93e5-08281e53bce7" ) ) ) @@ -35,7 +35,7 @@ SELECT FROM ( ) ) ) - ) WHERE endpoint = "http://pc-frosini.isti.cnr.it:8080/data-transfer-service/gcube/service" + ) 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.json b/src/test/resources/queries/query2.json index 3d40871..8ae1079 100644 --- a/src/test/resources/queries/query2.json +++ b/src/test/resources/queries/query2.json @@ -23,17 +23,17 @@ "type": "ConsistsOf", "target": { "type": "AccessPointFacet", - "endpoint": "http://pc-frosini.isti.cnr.it:8080/data-transfer-service/gcube/service" + "endpoint": "http://smartexecutor1.dev.int.d4science.net:80/data-transfer-service/gcube/resource" } } ], "isRelatedTo" : [ { "type": "Activates", - "id": "d3f58e52-5346-47bc-b736-9d77a0b554ce", + "id": "bd89a311-780d-4efe-93e5-08281e53bce7", "source": { "type": "HostingNode", - "id" : "5fbc1a56-d450-4f0f-85c1-9b1684581717" + "id" : "44fac329-eed5-4f18-90ba-a54d5aad316e" } } ] diff --git a/src/test/resources/queries/query2.match.query b/src/test/resources/queries/query2.match.query new file mode 100644 index 0000000..677df5b --- /dev/null +++ b/src/test/resources/queries/query2.match.query @@ -0,0 +1,15 @@ +SELECT EXPAND(eservice) 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 + eservice +) \ No newline at end of file diff --git a/src/test/resources/queries/query2.query b/src/test/resources/queries/query2.query index a8ecc3f..4d7d727 100644 --- a/src/test/resources/queries/query2.query +++ b/src/test/resources/queries/query2.query @@ -1 +1 @@ -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 = "5fbc1a56-d450-4f0f-85c1-9b1684581717")) WHERE id = "d3f58e52-5346-47bc-b736-9d77a0b554ce")))) 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 +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/query3.match.query b/src/test/resources/queries/query3.match.query new file mode 100644 index 0000000..088087e --- /dev/null +++ b/src/test/resources/queries/query3.match.query @@ -0,0 +1,32 @@ +SELECT EXPAND(eservice) 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').outV("HostingNode").outE('ConsistsOf').inV("CPUFacet") {where: (vendor='GenuineIntel')} + RETURN + eservice +) + + + +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 +) \ No newline at end of file diff --git a/src/test/resources/queries/query4-indented.query b/src/test/resources/queries/query4-indented.query new file mode 100644 index 0000000..add6ff0 --- /dev/null +++ b/src/test/resources/queries/query4-indented.query @@ -0,0 +1,7 @@ +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.json b/src/test/resources/queries/query4.json index 4ef7a57..53dafd8 100644 --- a/src/test/resources/queries/query4.json +++ b/src/test/resources/queries/query4.json @@ -5,7 +5,7 @@ "type": "ConsistsOf", "source" : { "type" : "EService", - "id": "0255b7ec-e3da-4071-b456-9a2907ece1db" + "id": "93995af0-4f95-4816-a53e-3e1bc27ef475" } } } \ No newline at end of file diff --git a/src/test/resources/queries/query4.match.query b/src/test/resources/queries/query4.match.query new file mode 100644 index 0000000..31c3f5c --- /dev/null +++ b/src/test/resources/queries/query4.match.query @@ -0,0 +1,7 @@ +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 +) \ No newline at end of file diff --git a/src/test/resources/queries/query4.query b/src/test/resources/queries/query4.query index 5156621..3dd1f7b 100644 --- a/src/test/resources/queries/query4.query +++ b/src/test/resources/queries/query4.query @@ -1 +1 @@ -SELECT FROM ( TRAVERSE inV("StateFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( SELECT FROM EService WHERE id = "0255b7ec-e3da-4071-b456-9a2907ece1db"))) WHERE value = "down" AND @class INSTANCEOF "StateFacet" \ No newline at end of file +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/query5-indented.query b/src/test/resources/queries/query5-indented.query new file mode 100644 index 0000000..d7aa2ee --- /dev/null +++ b/src/test/resources/queries/query5-indented.query @@ -0,0 +1,11 @@ +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.json b/src/test/resources/queries/query5.json index 958caa0..a9422c1 100644 --- a/src/test/resources/queries/query5.json +++ b/src/test/resources/queries/query5.json @@ -6,15 +6,23 @@ "source" : { "type" : "EService", "_or": [ - {"_and": { - "id" : "aec0ef31-c735-4a4c-b2f4-57dfbd2fe925", - "metadata" :{ "createdBy": {"_ne": "luca.frosini"} } - }}, - {"_and": { - "id" : "0255b7ec-e3da-4071-b456-9a2907ece1db", - "metadata" : { "createdBy": "DataTransfer:data-transfer-service:pc-frosini.isti.cnr.it_8080" } - }} + { + "_and": { + "id" : "93995af0-4f95-4816-a53e-3e1bc27ef475", + "metadata" : { + "createdBy": {"_ne": "luca.frosini"} + } + } + }, + { + "_and": { + "id" : "bd4402a0-2b72-41c5-a970-321343649e7d", + "metadata" : { + "createdBy": "DataTransfer:data-transfer-service:smartexecutor1.dev.int.d4science.net_80" + } + } + } ] } } -} \ No newline at end of file +}