From 095a24cc169928fe80662ba9b079090a3b3e376c Mon Sep 17 00:00:00 2001 From: Joris <joris.l@hotmail.com> Date: Wed, 24 Nov 2021 12:31:04 +0100 Subject: [PATCH] log statements and commented clusters --- cypher/convertQuery.go | 16 +++++----- cypher/convertQuery_test.go | 59 +++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 7 deletions(-) diff --git a/cypher/convertQuery.go b/cypher/convertQuery.go index 310639e..4a5bc35 100644 --- a/cypher/convertQuery.go +++ b/cypher/convertQuery.go @@ -3,6 +3,7 @@ package cypher import ( "errors" "fmt" + "log" "strings" "git.science.uu.nl/graphpolaris/query-conversion/entity" @@ -14,16 +15,16 @@ func (s *Service) ConvertQuery(totalJSONQuery *entity.IncomingQueryJSON) (*strin queryJSON := totalJSONQuery - query, rest, isRest := checkForQueryCluster(queryJSON) + // query, rest, isRest := checkForQueryCluster(queryJSON) - if isRest { - fmt.Println("Rest:") - fmt.Println(rest) + // if isRest { + // fmt.Println("Rest:") + // fmt.Println(rest) - // If something needs to be done with other query cluster, then add code here - } + // // If something needs to be done with other query cluster, then add code here + // } - finalCypher, err := createCypher(query) + finalCypher, err := createCypher(queryJSON) if err != nil { return nil, err } @@ -132,6 +133,7 @@ func createQueryHierarchy(JSONQuery *entity.IncomingQueryJSON) (entity.Query, er IDctr := 0 // Add relations all to query parts + log.Println(JSONQuery.Relations) for _, rel := range JSONQuery.Relations { part := entity.QueryPart{ QType: "relation", diff --git a/cypher/convertQuery_test.go b/cypher/convertQuery_test.go index f1f148a..6033dee 100644 --- a/cypher/convertQuery_test.go +++ b/cypher/convertQuery_test.go @@ -753,3 +753,62 @@ func Test5(t *testing.T) { assert.Equal(t, trimmedAnswer, trimmedAnswer) } +func Test6(t *testing.T) { + // Works, but, the AVG function is applied to a string, so that doesnt work, but the translation does :D + query := []byte(`{ + "return": { + "entities": [ + 11, + 12 + ], + "relations": [ + 10 + ], + "groupBys": [] + }, + "entities": [ + { + "name": "Person", + "ID": 11, + "constraints": [] + }, + { + "name": "Movie", + "ID": 12, + "constraints": [] + } + ], + "relations": [ + { + "ID": 10, + "name": "DIRECTED", + "depth": { + "min": 1, + "max": 1 + }, + "fromType": "entity", + "fromID": 11, + "toType": "entity", + "toID": 12, + "constraints": [] + } + ], + "groupBys": [], + "machineLearning": [], + "limit": 5000, + "databaseName": "Movies3" + } + `) + + var JSONQuery entity.IncomingQueryJSON + json.Unmarshal(query, &JSONQuery) + + s := NewService() + cypher, err := s.ConvertQuery(&JSONQuery) + if err != nil { + fmt.Println(err) + } + + fmt.Println(*cypher) + t.Fail() +} -- GitLab