diff --git a/cypher/convertQuery.go b/cypher/convertQuery.go index 059570d571937ec89a52bb64d98e18d52b30b59e..fd7d8de58c78481dc4c1a1a4ae15319859e1a043 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 9ccfa23f680b33600685dd2a7f1d226d50d76190..38dbc2647bb8e437502a31e43c019c5680863914 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) }