This commit is contained in:
Luca Frosini 2022-12-02 15:29:39 +01:00
parent 080c849bc0
commit 4afeed1692
4 changed files with 31 additions and 2 deletions

View File

@ -24,6 +24,8 @@ public class JsonQueryFacet extends JsonQueryEntity {
public StringBuffer analize(StringBuffer stringBuffer) throws SchemaException, ResourceRegistryException {
StringBuffer newBuffer = new StringBuffer();
int size = jsonNode.size();
boolean entry = entryPoint;
if(jsonNode.has(_IN)) {
if(!entryPoint) {
@ -35,9 +37,14 @@ public class JsonQueryFacet extends JsonQueryEntity {
jsonQueryConsistsOf.setDirection(Direction.OUT);
stringBuffer = jsonQueryConsistsOf.analize(stringBuffer);
entry = false;
/* Need to substract 1 from size otherwise
* it add WHERE at the end because _in
* is not a property to be used for a WHERE compare
*/
--size;
}
int size = jsonNode.size();
newBuffer.append("SELECT FROM ");
if(!entry) {

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, "query5.json");
File jsonQueryFile = new File(queriesDirectory, "query7.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,21 @@
{
"@class": "StateFacet",
"_in": {
"@class": "ConsistsOf",
"source" : {
"@class" : "EService",
"header": {
"$or": [
{"$and": {
"uuid" : "aec0ef31-c735-4a4c-b2f4-57dfbd2fe925",
"createdBy": {"$ne": "luca.frosini"}
}},
{"$and": {
"uuid" : "0255b7ec-e3da-4071-b456-9a2907ece1db",
"createdBy": "DataTransfer:data-transfer-service:pc-frosini.isti.cnr.it_8080"
}}
]
}
}
}
}

View File

@ -0,0 +1 @@
SELECT FROM ( TRAVERSE inV("StateFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( SELECT FROM ( SELECT FROM EService) WHERE ((header.uuid = "aec0ef31-c735-4a4c-b2f4-57dfbd2fe925" AND header.createdBy <> "luca.frosini") OR (header.uuid = "0255b7ec-e3da-4071-b456-9a2907ece1db" AND header.createdBy = "DataTransfer:data-transfer-service:pc-frosini.isti.cnr.it_8080")))))