Skip to content
Snippets Groups Projects
Commit 543c2636 authored by Lelieveld,J.R.J. (Joris)'s avatar Lelieveld,J.R.J. (Joris)
Browse files

Added some comments

parent bfadd26a
No related branches found
No related tags found
No related merge requests found
......@@ -13,37 +13,18 @@ import (
"github.com/arangodb/go-driver/http"
)
// Service is a struct used to store this use case in
type Service struct {
}
// NewService creates a new instantion of this use case
func NewService() *Service {
return &Service{}
}
// Document with Empty struct to retrieve all data from the DB Document
type Document map[string]interface{}
// GeneralFormat with Empty struct to retrieve all data from the DB Document
type GeneralFormat map[string][]Document
// ListContainer is a struct that keeps track of the nodes and edges that need to be returned
type ListContainer struct {
nodeList []Document
edgeList []Document
}
type arangoResult struct {
vertices []Document
edges []Document
}
//attr interface{}
//map[1 , 2 , 3 map [ .. ]]
// SendAQLQuery send AQL string query to database and returns a JSON object in a general format
/*
SendAQLQuery send AQL string query to database and returns a JSON object in a general format
Parameters: AQLQuery is a string containing the query that will be send to the database
Return: a map with two entries: "nodes" with a list of vertices/nodes and "edges" with a list of edges
that will be returned to the frontend
*/
func (s *Service) SendAQLQuery(AQLQuery string) (*map[string][]Document, error) {
var queryResult = make(map[string][]Document)
conn, err := http.NewConnection(http.ConnectionConfig{
......@@ -78,6 +59,7 @@ func (s *Service) SendAQLQuery(AQLQuery string) (*map[string][]Document, error)
}
defer cursor.Close()
//Loop through the resulting documents
listContainer := ListContainer{}
for {
var doc map[string][]interface{}
......@@ -100,7 +82,13 @@ func (s *Service) SendAQLQuery(AQLQuery string) (*map[string][]Document, error)
return &queryResult, nil
}
//Resultaat: [ { vertices : [], edges : [] } ]
/* parseResult takes the result of the query and translates this to two lists: a nodelist and an edgelist, stored in a listcontainer
Parameters: doc is the document with the nodes and vertices that came back from the database,
listContainer is a struct containing the nodelist and edgelist that will be returned to the frontend
Return: Nothing because the result is stored in the listContainer
*/
func parseResult(doc map[string][]interface{}, listContainer *ListContainer) {
vertices := doc["vertices"]
edges := doc["edges"]
......@@ -120,9 +108,11 @@ func parseResult(doc map[string][]interface{}, listContainer *ListContainer) {
}
}
// parseResult takes the result of the query and translates this to two lists: a nodelist and an edgelist, stored in a listcontainer
/* parseEdge parses the data of an edge to an output-friendly format
Parameters: d is a single entry of an edge
// parseEdge parses the data of an edge to an output-friendly format
Return: a document with almost the same structure as before, but the attributes are grouped
*/
func parseEdge(d map[string]interface{}) Document {
doc := d //.(map[string]interface{})
......@@ -154,7 +144,11 @@ func writeJSON(queryResult map[string][]Document) {
_ = ioutil.WriteFile("result.json", file, 0644)
}
// parseNode parses the data of a node to an output-friendly format
/* parseEdge parses the data of a node to an output-friendly format
Parameters: d is a single entry of an node
Return: a document with almost the same structure as before, but the attributes are grouped
*/
func parseNode(d map[string]interface{}) Document {
doc := d //.(map[string]interface{})
......
package request
// Service is a struct used to store this use case in
type Service struct {
}
// NewService creates a new instantion of this use case
func NewService() *Service {
return &Service{}
}
// Document with Empty struct to retrieve all data from the DB Document
type Document map[string]interface{}
// GeneralFormat with Empty struct to retrieve all data from the DB Document
type GeneralFormat map[string][]Document
// ListContainer is a struct that keeps track of the nodes and edges that need to be returned
type ListContainer struct {
nodeList []Document
edgeList []Document
}
type arangoResult struct {
vertices []Document
edges []Document
}
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