Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
FastApi-Neo4j
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
khusraj.jain
FastApi-Neo4j
Commits
b4927861
Commit
b4927861
authored
Nov 09, 2022
by
harshavardhan.c
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add: logic addition for deleting nodes.
parent
55925c98
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
9 deletions
+26
-9
scripts/core/engine/__init__.py
scripts/core/engine/__init__.py
+9
-5
scripts/core/handler/__init__.py
scripts/core/handler/__init__.py
+2
-2
scripts/db/models.py
scripts/db/models.py
+9
-1
scripts/schemas/__init__.py
scripts/schemas/__init__.py
+5
-0
scripts/utils/graph_utility.py
scripts/utils/graph_utility.py
+1
-1
No files found.
scripts/core/engine/__init__.py
View file @
b4927861
from
scripts.db.graphdb.neo4j
import
Neo4jHandler
from
scripts.db.models
import
NodePropertiesSchema
,
RelationShipMapper
from
scripts.db.models
import
NodePropertiesSchema
,
RelationShipMapper
,
NodeFetchSchema
from
scripts.logging
import
logger
from
scripts.schemas
import
GraphData
,
NodeSchemaValidation
,
NodeActionOptions
from
scripts.utils.graph_utility
import
GraphUtility
...
...
@@ -22,7 +22,7 @@ class GraphTraversal:
for
node_type
,
node_obj
in
graph_data
.
__root__
.
items
():
process_obj
=
NodeSchemaValidation
(
**
node_obj
.
dict
(),
label
=
node_type
)
if
node_obj
.
action
==
NodeActionOptions
.
delete
:
...
self
.
perform_delete_node_action
(
graph_data
=
process_obj
)
else
:
nodes_map
,
edges_info
=
self
.
perform_save_node_action
(
node_obj
=
process_obj
,
nodes_map
=
nodes_map
,
edges_info
=
edges_info
,
node_type
=
node_type
)
...
...
@@ -34,10 +34,8 @@ class GraphTraversal:
rel_data
=
RelationShipMapper
(
_start_node_id
=
nodes_map
[
edge
.
bind_to
]
.
_id
,
_end_node_id
=
nodes_map
[
des_edge
]
.
_id
,
_type
=
edge
.
rel_name
,
**
nodes_map
[
des_edge
]
.
dict
()
,
project_id
=
nodes_map
[
des_edge
]
.
project_id
,
),
new_rel_name
=
edge
.
new_rel_name
)
except
Exception
as
e
:
logger
.
exception
(
f
'{e.args}'
)
...
...
@@ -63,3 +61,9 @@ class GraphTraversal:
except
Exception
as
e
:
logger
.
exception
(
f
'Exception Occurred while deleting node info {e.args}'
)
raise
def
fetch_node_data
(
self
,
graph_request
:
NodeFetchSchema
):
try
:
existing_data
=
self
.
graph_util
.
load_node_data_from_graph
(
node_data
=
graph_request
)
except
Exception
as
e
:
logger
.
exception
(
f
"Exception Occurred while fetching data from node"
)
scripts/core/handler/__init__.py
View file @
b4927861
from
scripts.core.engine
import
GraphTraversal
from
scripts.schemas
import
GraphData
from
scripts.schemas
import
GraphData
,
GetNodeInfo
class
GraphTrackingHandler
:
...
...
@@ -11,7 +11,7 @@ class GraphTrackingHandler:
"""
return
self
.
graph_traversal
.
ingest_data_handler
(
graph_data
=
graph_data
)
def
graph_traverse_handler
(
self
,
graph_data_request
:
Ge
nealogyDataRequest
)
->
str
:
def
graph_traverse_handler
(
self
,
graph_data_request
:
Ge
tNodeInfo
)
->
str
:
"""
"""
return
self
.
graph_traversal
.
get_genealogy
(
genealogy_data
=
graph_data_request
)
scripts/db/models.py
View file @
b4927861
from
typing
import
Optional
from
gqlalchemy
import
Node
,
Relationship
from
pydantic
import
Field
...
...
@@ -15,6 +17,12 @@ class NodePropertiesSchema(NodeCreationSchema):
class
RelationShipMapper
(
Relationship
,
type
=
"Relation_Mapper"
):
project_id
:
str
=
Field
()
class
Config
:
allow_population_by_field_name
=
True
class
NodeFetchSchema
(
Node
):
id
:
Optional
[
str
]
name
:
Optional
[
str
]
project_id
:
str
scripts/schemas/__init__.py
View file @
b4927861
...
...
@@ -90,3 +90,8 @@ class GraphData(BaseModel):
}
}
}
class
GetNodeInfo
(
BaseModel
):
project_id
:
str
event_id
:
str
scripts/utils/graph_utility.py
View file @
b4927861
...
...
@@ -3,7 +3,7 @@ from typing import List
from
gqlalchemy
import
GQLAlchemyError
from
scripts.db.graphdb.neo4j
import
Neo4jHandler
from
scripts.db.models
import
NodeCreationSchema
,
RelationShipMapper
,
NodeProperties
Schema
from
scripts.db.models
import
RelationShipMapper
,
NodePropertiesSchema
,
NodeFetch
Schema
from
scripts.logging
import
logger
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment