From 4ad036acb7ddb4efb0c7a45463471df86347b3e7 Mon Sep 17 00:00:00 2001 From: Fjodor <fjodor_rs@hotmail.com> Date: Wed, 26 May 2021 16:11:40 +0200 Subject: [PATCH] added print statement for testing, checked possible queries @Lorenzo --- cypher/convertQuery.go | 8 ++------ main/main.go | 26 +++++++++++++++----------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/cypher/convertQuery.go b/cypher/convertQuery.go index 059570d..fd7d8de 100644 --- a/cypher/convertQuery.go +++ b/cypher/convertQuery.go @@ -191,16 +191,12 @@ func createQuery(JSONQuery *entity.IncomingQueryJSON) *string { // Create UNION statements that create unique lists of all the nodes and relations // Thus removing all duplicates - nodeUnion = "\nLET nodes = first(RETURN UNION_DISTINCT(" - for _, relation := range relationsToReturn { - nodeUnion += fmt.Sprintf("flatten(%v[**].vertices), ", relation) - } + nodeUnion = "\nRETURN " for _, node := range nodesToReturn { nodeUnion += fmt.Sprintf("%v,", node) } - nodeUnion += "[],[]))\n" - + // RETURN n0, n1, n2, nn, r0, r1, r2, r3, rn relationUnion = "LET edges = first(RETURN UNION_DISTINCT(" for _, relation := range relationsToReturn { relationUnion += fmt.Sprintf("flatten(%v[**].edges), ", relation) diff --git a/main/main.go b/main/main.go index 9ccfa23..38dbc26 100644 --- a/main/main.go +++ b/main/main.go @@ -1,17 +1,20 @@ package main -import( +import ( + "encoding/json" "log" - "git.science.uu.nl/datastrophe/query-conversion/cypher/queryConverter.go" + + "git.science.uu.nl/datastrophe/query-conversion/cypher" + "git.science.uu.nl/datastrophe/query-conversion/entity" ) -func main(){ - queryservice := new cypher.NewService() +func main() { + queryservice := cypher.NewService() - js = `{ + js := []byte(`{ "return": { "entities": [ - 0 + 0 ], "relations": [] }, @@ -30,9 +33,10 @@ func main(){ ], "relations": [], "limit": 5000 - }` - - - result, _ := cypher.convertQuery(JSON.marshal(js)) - log.Println(result) + }`) + + var inc entity.IncomingQueryJSON + json.Unmarshal(js, &inc) + result, _ := queryservice.ConvertQuery(&inc) + log.Println(*result) } -- GitLab