Skip to content

Commit

Permalink
add working implementation of create_activity controller fxn
Browse files Browse the repository at this point in the history
  • Loading branch information
jaeddy committed Jul 24, 2019
1 parent dfff559 commit 97e8a7a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
3 changes: 2 additions & 1 deletion synprov/graph/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .models.activity import GraphActivity
from .models.agent import GraphAgent
from .models.reference import GraphReference
from .models.reference import GraphReference
from .builder import ActivityBuilder
2 changes: 1 addition & 1 deletion synprov/graph/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ def save(self):
rel.create()
self.gdb.create_relationship(rel)

return True
return self._find_activity()
23 changes: 14 additions & 9 deletions synprov/graph/controllers/activities_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from py2neo import Node, NodeMatcher

from synprov.config import neo4j_connection as graph
from synprov.graph import GraphActivity, GraphReference, GraphAgent
from synprov.graph import ActivityBuilder
from synprov.util import neo4j_to_d3


Expand All @@ -21,11 +21,16 @@ def create_activity(body=None): # noqa: E501
:rtype: Activity
"""
# act = Activity(**humps.decamelize(body))
# act.save()

# return act.node
return 'Not Implemented', 501
builder = ActivityBuilder(
**body.to_dict()
)
act_node = builder.save()
print(act_node)
return humps.camelize({
'id': str(act_node.identity),
'labels': list(act_node.labels),
'properties': dict(act_node)
})


def get_activities_graph(sort_by=None, order=None, limit=None): # noqa: E501
Expand Down Expand Up @@ -61,7 +66,7 @@ def get_activities_graph(sort_by=None, order=None, limit=None): # noqa: E501
results = graph.run(
query_base,
)
return neo4j_to_d3(results.data())
return humps.camelize(neo4j_to_d3(results.data()))


def get_agent_subgraph(id, sort_by=None, order=None, limit=None): # noqa: E501
Expand Down Expand Up @@ -100,7 +105,7 @@ def get_agent_subgraph(id, sort_by=None, order=None, limit=None): # noqa: E501
query_base,
id=id
)
return neo4j_to_d3(results.data())
return humps.camelize(neo4j_to_d3(results.data()))


def get_reference_subgraph(id,
Expand Down Expand Up @@ -150,4 +155,4 @@ def get_reference_subgraph(id,
query_base,
id=id
)
return neo4j_to_d3(results.data())
return humps.camelize(neo4j_to_d3(results.data()))

0 comments on commit 97e8a7a

Please sign in to comment.