Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
goSDN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
danet
goSDN
Commits
10929794
Commit
10929794
authored
4 years ago
by
Malte Bauch
Browse files
Options
Downloads
Patches
Plain Diff
added comments database
parent
7192a231
No related branches found
No related tags found
2 merge requests
!43
Resolve "neo4j"
,
!18
Develop
Pipeline
#52533
passed with warnings
4 years ago
Stage: test
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
database/database.go
+17
-2
17 additions, 2 deletions
database/database.go
with
17 additions
and
2 deletions
database/database.go
+
17
−
2
View file @
10929794
...
@@ -81,6 +81,7 @@ func storePndTxFunc(name, description string, interfaces []string) neo4j.Transac
...
@@ -81,6 +81,7 @@ func storePndTxFunc(name, description string, interfaces []string) neo4j.Transac
})
})
if
err
!=
nil
{
if
err
!=
nil
{
//TODO: handle neo4j.isServiceUnavailable()
return
nil
,
err
return
nil
,
err
}
}
...
@@ -115,6 +116,9 @@ func (d Database) GetNodesByLabel(label string) {}
...
@@ -115,6 +116,9 @@ func (d Database) GetNodesByLabel(label string) {}
func
(
d
Database
)
GetDeviceByID
(
id
string
)
{}
func
(
d
Database
)
GetDeviceByID
(
id
string
)
{}
//storeNodesTxFunc transaction to store devices from a json.
//relates them to a specific pnd id.
//returns a slice of added devices
func
storeNodesTxFunc
(
json
string
,
id
int64
)
neo4j
.
TransactionWork
{
func
storeNodesTxFunc
(
json
string
,
id
int64
)
neo4j
.
TransactionWork
{
return
func
(
tx
neo4j
.
Transaction
)
(
interface
{},
error
)
{
return
func
(
tx
neo4j
.
Transaction
)
(
interface
{},
error
)
{
var
nodelist
[]
neo4j
.
Node
var
nodelist
[]
neo4j
.
Node
...
@@ -142,6 +146,7 @@ func storeNodesTxFunc(json string, id int64) neo4j.TransactionWork {
...
@@ -142,6 +146,7 @@ func storeNodesTxFunc(json string, id int64) neo4j.TransactionWork {
})
})
if
err
!=
nil
{
if
err
!=
nil
{
//TODO: handle neo4j.isServiceUnavailable()
return
nil
,
err
return
nil
,
err
}
}
...
@@ -182,6 +187,9 @@ func (d Database) RemoveNodes(json string) {}
...
@@ -182,6 +187,9 @@ func (d Database) RemoveNodes(json string) {}
//RemoveSingleNode removes the given node and their relationship by id.
//RemoveSingleNode removes the given node and their relationship by id.
func
(
d
Database
)
RemoveSingleNode
(
id
string
)
{}
func
(
d
Database
)
RemoveSingleNode
(
id
string
)
{}
//storeLinksTxFunc transaction to store links from a json.
//creates relation between different devices.
//returns a slice of those created relations.
func
storeLinksTxFunc
(
json
string
)
neo4j
.
TransactionWork
{
func
storeLinksTxFunc
(
json
string
)
neo4j
.
TransactionWork
{
return
func
(
tx
neo4j
.
Transaction
)
(
interface
{},
error
)
{
return
func
(
tx
neo4j
.
Transaction
)
(
interface
{},
error
)
{
var
relationsList
[]
neo4j
.
Relationship
var
relationsList
[]
neo4j
.
Relationship
...
@@ -203,6 +211,7 @@ func storeLinksTxFunc(json string) neo4j.TransactionWork {
...
@@ -203,6 +211,7 @@ func storeLinksTxFunc(json string) neo4j.TransactionWork {
})
})
if
err
!=
nil
{
if
err
!=
nil
{
//TODO: handle neo4j.isServiceUnavailable()
return
nil
,
err
return
nil
,
err
}
}
...
@@ -233,6 +242,8 @@ func (d Database) StoreLinks(json string) []neo4j.Relationship {
...
@@ -233,6 +242,8 @@ func (d Database) StoreLinks(json string) []neo4j.Relationship {
return
result
.
([]
neo4j
.
Relationship
)
return
result
.
([]
neo4j
.
Relationship
)
}
}
//storeNodeEdgePointsTxFunc transaction to store interfaces from a json.
//returns count of added/updated interfaces
func
storeNodeEdgePointsTxFunc
(
json
string
)
neo4j
.
TransactionWork
{
func
storeNodeEdgePointsTxFunc
(
json
string
)
neo4j
.
TransactionWork
{
return
func
(
tx
neo4j
.
Transaction
)
(
interface
{},
error
)
{
return
func
(
tx
neo4j
.
Transaction
)
(
interface
{},
error
)
{
query
:=
query
:=
...
@@ -253,6 +264,7 @@ func storeNodeEdgePointsTxFunc(json string) neo4j.TransactionWork {
...
@@ -253,6 +264,7 @@ func storeNodeEdgePointsTxFunc(json string) neo4j.TransactionWork {
})
})
if
err
!=
nil
{
if
err
!=
nil
{
//TODO: handle neo4j.isServiceUnavailable()
return
nil
,
err
return
nil
,
err
}
}
...
@@ -264,9 +276,11 @@ func storeNodeEdgePointsTxFunc(json string) neo4j.TransactionWork {
...
@@ -264,9 +276,11 @@ func storeNodeEdgePointsTxFunc(json string) neo4j.TransactionWork {
}
}
}
}
//TODO: currently this goes over each and every device
and
interface and adds
//TODO: currently this goes over each and every device
/
interface and adds
// a interface_of relation. -> do it only for the newly added interfaces
// a interface_of relation. -> do it only for the newly added interfaces
// returns count of created relations
//storeNodeEdgePointsRelationTxFunc transaction to create relations between interfaces and devices
//returns count of added/updated relations
func
storeNodeEdgePointsRelationTxFunc
()
neo4j
.
TransactionWork
{
func
storeNodeEdgePointsRelationTxFunc
()
neo4j
.
TransactionWork
{
return
func
(
tx
neo4j
.
Transaction
)
(
interface
{},
error
)
{
return
func
(
tx
neo4j
.
Transaction
)
(
interface
{},
error
)
{
query
:=
query
:=
...
@@ -280,6 +294,7 @@ func storeNodeEdgePointsRelationTxFunc() neo4j.TransactionWork {
...
@@ -280,6 +294,7 @@ func storeNodeEdgePointsRelationTxFunc() neo4j.TransactionWork {
result
,
err
:=
tx
.
Run
(
query
,
nil
)
result
,
err
:=
tx
.
Run
(
query
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
//TODO: handle neo4j.isServiceUnavailable()
return
nil
,
err
return
nil
,
err
}
}
...
...
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