From bb4e00847b86e8696eb63f75715349bbcf9e3a79 Mon Sep 17 00:00:00 2001 From: Joris <j.r.j.lelieveld@students.uu.nl> Date: Fri, 9 Apr 2021 15:41:58 +0200 Subject: [PATCH] Comments added --- cmd/query-service/main.go | 146 +++++++++++++++++++------------------- internal/aql/aql.go | 5 ++ 2 files changed, 78 insertions(+), 73 deletions(-) diff --git a/cmd/query-service/main.go b/cmd/query-service/main.go index 9ab1860..58bfa1a 100644 --- a/cmd/query-service/main.go +++ b/cmd/query-service/main.go @@ -96,76 +96,76 @@ func onMessageReceived(msg amqp.Delivery) { msg.Ack(true) } -func FORGLORY() { - s := `{ - "Return": { - "Entities": [ - 0, - 1 - ], - "Relations": [ - 0 - ] - }, - "Entities": [ - { - "Type": "airports", - "Constraints": [ - { - "Attribute": "country", - "Value": "USA", - "DataType": "text", - "MatchType": "exact" - } - ] - }, - { - "Type": "airports", - "Constraints": [ - { - "Attribute": "city", - "Value": "New York", - "DataType": "text", - "MatchType": "exact" - }, - { - "Attribute": "vip", - "Value": "true", - "DataType": "bool", - "MatchType": "exact" - } - ] - } - ], - "Relations": [ - { - "Type": "flights", - "Depth": { - "min": 1, - "max": 1 - }, - "EntityFrom": 0, - "EntityTo": 1, - "Constraints": [ - { - "Attribute": "Month", - "Value": "1", - "DataType": "number", - "MatchType": "exact" - }, - { - "Attribute": "Day", - "Value": "15", - "DataType": "number", - "MatchType": "exact" - } - ] - } - ] - }` - - s3 := []byte(s) - - yeet, _ := aql.ConvertJSONToAQL(&s3) - fmt.Print(*yeet) -} +// func FORGLORY() { +// s := `{ +// "Return": { +// "Entities": [ +// 0, +// 1 +// ], +// "Relations": [ +// 0 +// ] +// }, +// "Entities": [ +// { +// "Type": "airports", +// "Constraints": [ +// { +// "Attribute": "country", +// "Value": "USA", +// "DataType": "text", +// "MatchType": "exact" +// } +// ] +// }, +// { +// "Type": "airports", +// "Constraints": [ +// { +// "Attribute": "city", +// "Value": "New York", +// "DataType": "text", +// "MatchType": "exact" +// }, +// { +// "Attribute": "vip", +// "Value": "true", +// "DataType": "bool", +// "MatchType": "exact" +// } +// ] +// } +// ], +// "Relations": [ +// { +// "Type": "flights", +// "Depth": { +// "min": 1, +// "max": 1 +// }, +// "EntityFrom": 0, +// "EntityTo": 1, +// "Constraints": [ +// { +// "Attribute": "Month", +// "Value": "1", +// "DataType": "number", +// "MatchType": "exact" +// }, +// { +// "Attribute": "Day", +// "Value": "15", +// "DataType": "number", +// "MatchType": "exact" +// } +// ] +// } +// ] +// }` + +// s3 := []byte(s) + +// yeet, _ := aql.ConvertJSONToAQL(&s3) +// fmt.Print(*yeet) +// } diff --git a/internal/aql/aql.go b/internal/aql/aql.go index 08f09b0..95f8e96 100644 --- a/internal/aql/aql.go +++ b/internal/aql/aql.go @@ -148,6 +148,7 @@ func ConvertJSONToAQL(jsonMsg *[]byte) (*string, error) { return result, nil } +// createAllNodesQuery creates node queries in AQL func createAllNodesQuery(returnEntitiesIndices []int, entities []entityStruct) *string { var ( result string @@ -308,6 +309,7 @@ LET e0 = ( RETURN e0 */ +// createEdgeQuery creates an aql query for relations func createEdgeQuery(q *parsedJSON, name string) *string { //Creation of n0 n1 let statements query := "" @@ -334,6 +336,7 @@ func createEdgeQuery(q *parsedJSON, name string) *string { return &query } +// createLetStatementForRelation creates the relation query func createLetStatementForRelation(relation *relationStruct, name string) *string { letStatement := fmt.Sprintf("\nLET %s = (\n", name) @@ -419,6 +422,7 @@ func createQueryConstraint(constraint *constraintStruct) *string { return &line } +// createEdgeQueryConstraint translates the constraints of an edge query to aql func createEdgeQueryConstraint(constraint *constraintStruct) *string { //FILTER x.{CONSTRAINT[0]} {{CONSTRAINT[0]}.MATCHTYPE} {CONSTRAINT[0].VALUE} // name match value + dataType @@ -471,6 +475,7 @@ func createEdgeQueryConstraint(constraint *constraintStruct) *string { return &line } +// convertJSONToStruct takes the json as byte array and converts it to a struct func convertJSONToStruct(jsonMsg *[]byte) (*parsedJSON, error) { jsonStruct := parsedJSON{} err := json.Unmarshal(*jsonMsg, &jsonStruct) -- GitLab