Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Q
query-service
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GraphPolaris
Microservices
query-service
Commits
543c2636
Commit
543c2636
authored
3 years ago
by
Lelieveld,J.R.J. (Joris)
Browse files
Options
Downloads
Patches
Plain Diff
Added some comments
parent
bfadd26a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
internal/usecases/request/request.go
+25
-31
25 additions, 31 deletions
internal/usecases/request/request.go
internal/usecases/request/requestStructs.go
+27
-0
27 additions, 0 deletions
internal/usecases/request/requestStructs.go
with
52 additions
and
31 deletions
internal/usecases/request/request.go
+
25
−
31
View file @
543c2636
...
@@ -13,37 +13,18 @@ import (
...
@@ -13,37 +13,18 @@ import (
"github.com/arangodb/go-driver/http"
"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{}
//attr interface{}
//map[1 , 2 , 3 map [ .. ]]
//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
)
{
func
(
s
*
Service
)
SendAQLQuery
(
AQLQuery
string
)
(
*
map
[
string
][]
Document
,
error
)
{
var
queryResult
=
make
(
map
[
string
][]
Document
)
var
queryResult
=
make
(
map
[
string
][]
Document
)
conn
,
err
:=
http
.
NewConnection
(
http
.
ConnectionConfig
{
conn
,
err
:=
http
.
NewConnection
(
http
.
ConnectionConfig
{
...
@@ -78,6 +59,7 @@ func (s *Service) SendAQLQuery(AQLQuery string) (*map[string][]Document, error)
...
@@ -78,6 +59,7 @@ func (s *Service) SendAQLQuery(AQLQuery string) (*map[string][]Document, error)
}
}
defer
cursor
.
Close
()
defer
cursor
.
Close
()
//Loop through the resulting documents
listContainer
:=
ListContainer
{}
listContainer
:=
ListContainer
{}
for
{
for
{
var
doc
map
[
string
][]
interface
{}
var
doc
map
[
string
][]
interface
{}
...
@@ -100,7 +82,13 @@ func (s *Service) SendAQLQuery(AQLQuery string) (*map[string][]Document, error)
...
@@ -100,7 +82,13 @@ func (s *Service) SendAQLQuery(AQLQuery string) (*map[string][]Document, error)
return
&
queryResult
,
nil
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
)
{
func
parseResult
(
doc
map
[
string
][]
interface
{},
listContainer
*
ListContainer
)
{
vertices
:=
doc
[
"vertices"
]
vertices
:=
doc
[
"vertices"
]
edges
:=
doc
[
"edges"
]
edges
:=
doc
[
"edges"
]
...
@@ -120,9 +108,11 @@ func parseResult(doc map[string][]interface{}, listContainer *ListContainer) {
...
@@ -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
{
func
parseEdge
(
d
map
[
string
]
interface
{})
Document
{
doc
:=
d
//.(map[string]interface{})
doc
:=
d
//.(map[string]interface{})
...
@@ -154,7 +144,11 @@ func writeJSON(queryResult map[string][]Document) {
...
@@ -154,7 +144,11 @@ func writeJSON(queryResult map[string][]Document) {
_
=
ioutil
.
WriteFile
(
"result.json"
,
file
,
0644
)
_
=
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
{
func
parseNode
(
d
map
[
string
]
interface
{})
Document
{
doc
:=
d
//.(map[string]interface{})
doc
:=
d
//.(map[string]interface{})
...
...
This diff is collapsed.
Click to expand it.
internal/usecases/request/requestStructs.go
0 → 100644
+
27
−
0
View file @
543c2636
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
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment