From 81d3f10c2fac7861fe1bd878e10a527f3eb712c8 Mon Sep 17 00:00:00 2001 From: LoLo5689 <lorenzotheunissen@gmail.com> Date: Fri, 18 Jun 2021 14:37:16 +0200 Subject: [PATCH] Fixed the double with --- aql/convertQuery.go | 12 +++++-- main/main.go | 81 +++++++++++++++++++++++++++++++++------------ 2 files changed, 69 insertions(+), 24 deletions(-) diff --git a/aql/convertQuery.go b/aql/convertQuery.go index 87d4a01..bc15ba7 100644 --- a/aql/convertQuery.go +++ b/aql/convertQuery.go @@ -96,12 +96,20 @@ func createQuery(JSONQuery *entity.IncomingQueryJSON) *string { } // Include all types that are not yet included + first := true for k := range allTypes { if !includedTypes[k] { - ret += fmt.Sprintf("WITH %v\n", k) - + if first { + ret += fmt.Sprintf("WITH %v", k) + first = false + } else { + ret += fmt.Sprintf(", %v", k) + } } } + if !first { + ret += "\n" + } for i, relation := range JSONQuery.Relations { diff --git a/main/main.go b/main/main.go index b2c863a..204395a 100644 --- a/main/main.go +++ b/main/main.go @@ -9,7 +9,7 @@ import ( "encoding/json" "log" - "git.science.uu.nl/datastrophe/query-conversion/cypher" + "git.science.uu.nl/datastrophe/query-conversion/aql" "git.science.uu.nl/datastrophe/query-conversion/entity" ) @@ -17,29 +17,66 @@ import ( The main function that calls the appropriate functions */ func main() { - queryservice := cypher.NewService() + queryservice := aql.NewService() js := []byte(`{ - "return": { - "entities": [ - 0 - ] - }, - "entities": [ - { - "type": "airports", - "constraints": [ - { - "attribute": "city", - "value": "San Francisco", - "dataType": "string", - "matchType": "exact" - } - ] - } - ], - "limit": 5000 - }`) + "databaseName": "test", + "return": { + "entities": [ + 0, + 1, + 2, + 3 + ], + "relations": [ + 0, + 1 + ] + }, + "entities": [ + { + "type": "kamerleden", + "constraints": [] + }, + { + "type": "partijen", + "constraints": [] + } + , + { + "type": "kamerleden", + "constraints": [] + }, + { + "type": "commissies", + "constraints": [] + } + ], + "relations": [ + { + "type": "lid_van", + "depth": { + "min": 1, + "max": 1 + }, + "entityFrom": 0, + "entityTo": 1, + "constraints": [] + }, + { + "type": "onderdeel_van", + "depth": { + "min": 1, + "max": 1 + }, + "entityFrom": 2, + "entityTo": 3, + "constraints": [] + } + ], + "limit": 5000, + "modifiers": [] + }`) var inc entity.IncomingQueryJSON json.Unmarshal(js, &inc) -- GitLab