Skip to content
Snippets Groups Projects
Commit e9d464cf authored by Bouma,C.J. (Chris)'s avatar Bouma,C.J. (Chris)
Browse files

Documentation for query translation

Added comments for go linting
parent b4ad0142
No related branches found
No related tags found
No related merge requests found
...@@ -69,6 +69,7 @@ func (s *Service) ConvertQuery(jsonMsg *[]byte) (*string, error) { ...@@ -69,6 +69,7 @@ func (s *Service) ConvertQuery(jsonMsg *[]byte) (*string, error) {
return result, nil return result, nil
} }
//convertJSONtoStruct reads a JSON file and sorts the data into the appropriate structs
func convertJSONToStruct(jsonMsg *[]byte) (*parsedJSON, error) { func convertJSONToStruct(jsonMsg *[]byte) (*parsedJSON, error) {
jsonStruct := parsedJSON{} jsonStruct := parsedJSON{}
err := json.Unmarshal(*jsonMsg, &jsonStruct) err := json.Unmarshal(*jsonMsg, &jsonStruct)
...@@ -80,6 +81,7 @@ func convertJSONToStruct(jsonMsg *[]byte) (*parsedJSON, error) { ...@@ -80,6 +81,7 @@ func convertJSONToStruct(jsonMsg *[]byte) (*parsedJSON, error) {
return &jsonStruct, nil return &jsonStruct, nil
} }
//createQuery generates a query based on the json file provided
func createQuery(jsonQuery *parsedJSON) *string { func createQuery(jsonQuery *parsedJSON) *string {
// GROTE SIDENOTE: // GROTE SIDENOTE:
// Vrij zeker dat een query waar alléén edges worden opgevraagd (#4) // Vrij zeker dat een query waar alléén edges worden opgevraagd (#4)
...@@ -164,6 +166,7 @@ func createQuery(jsonQuery *parsedJSON) *string { ...@@ -164,6 +166,7 @@ func createQuery(jsonQuery *parsedJSON) *string {
return &ret return &ret
} }
//createNodeLet generates a 'LET' statement for a node related query
func createNodeLet(node *entityStruct, name *string) *string { func createNodeLet(node *entityStruct, name *string) *string {
header := fmt.Sprintf("LET %v = (\n\tFOR x IN %v \n", *name, node.Type) header := fmt.Sprintf("LET %v = (\n\tFOR x IN %v \n", *name, node.Type)
footer := "\tRETURN x\n)\n" footer := "\tRETURN x\n)\n"
...@@ -173,6 +176,7 @@ func createNodeLet(node *entityStruct, name *string) *string { ...@@ -173,6 +176,7 @@ func createNodeLet(node *entityStruct, name *string) *string {
return &ret return &ret
} }
//createRelationLetWithFromEntity generates a 'LET' statement for relations with an 'EntityFrom' property
func createRelationLetWithFromEntity(relation *relationStruct, name string, entities *[]entityStruct) *string { func createRelationLetWithFromEntity(relation *relationStruct, name string, entities *[]entityStruct) *string {
header := fmt.Sprintf("LET %v = (\n\tFOR x IN n%v \n", name, relation.EntityFrom) header := fmt.Sprintf("LET %v = (\n\tFOR x IN n%v \n", name, relation.EntityFrom)
forStatement := fmt.Sprintf("\tFOR v, e, p IN %v..%v OUTBOUND x %s \n", relation.Depth.Min, relation.Depth.Max, relation.Type) forStatement := fmt.Sprintf("\tFOR v, e, p IN %v..%v OUTBOUND x %s \n", relation.Depth.Min, relation.Depth.Max, relation.Type)
...@@ -200,6 +204,7 @@ func createRelationLetWithFromEntity(relation *relationStruct, name string, enti ...@@ -200,6 +204,7 @@ func createRelationLetWithFromEntity(relation *relationStruct, name string, enti
return &ret return &ret
} }
//createRelationLetWithOnlyToEntity generates a 'LET' statement for relations with only an 'EntityTo' property
func createRelationLetWithOnlyToEntity(relation *relationStruct, name string, entities *[]entityStruct) *string { func createRelationLetWithOnlyToEntity(relation *relationStruct, name string, entities *[]entityStruct) *string {
header := fmt.Sprintf("LET %v = (\n\tFOR x IN n%v \n", name, relation.EntityTo) header := fmt.Sprintf("LET %v = (\n\tFOR x IN n%v \n", name, relation.EntityTo)
forStatement := fmt.Sprintf("\tFOR v, e, p IN %v..%v INBOUND x %s \n", relation.Depth.Min, relation.Depth.Max, relation.Type) forStatement := fmt.Sprintf("\tFOR v, e, p IN %v..%v INBOUND x %s \n", relation.Depth.Min, relation.Depth.Max, relation.Type)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment