Skip to content
Snippets Groups Projects
Commit 10929794 authored by Malte Bauch's avatar Malte Bauch
Browse files

added comments database

parent 7192a231
No related branches found
No related tags found
2 merge requests!43Resolve "neo4j",!18Develop
Pipeline #52533 passed with warnings
...@@ -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
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment