diff --git a/dataproc/api/models/__pycache__/construct_model.cpython-38.pyc b/dataproc/api/models/__pycache__/construct_model.cpython-38.pyc index 17850e70c9d75bed0812e897e321a9d1e6824fd4..a22b72e02b5de3003c20375479ad908db9670488 100644 Binary files a/dataproc/api/models/__pycache__/construct_model.cpython-38.pyc and b/dataproc/api/models/__pycache__/construct_model.cpython-38.pyc differ diff --git a/dataproc/api/models/__pycache__/user_model.cpython-38.pyc b/dataproc/api/models/__pycache__/user_model.cpython-38.pyc index 1b3b54bbf0ceb6cabd85b768ab87a865379c0e4d..fde8a6f5083ab79f7061d53605ab65c1e8e74a26 100644 Binary files a/dataproc/api/models/__pycache__/user_model.cpython-38.pyc and b/dataproc/api/models/__pycache__/user_model.cpython-38.pyc differ diff --git a/dataproc/api/models/construct_model.py b/dataproc/api/models/construct_model.py index 34141f156df5a27ba3483e476b4abb5de1a89a54..0405989c8df656fa21dfa3cc93ec5e0d52b05327 100644 --- a/dataproc/api/models/construct_model.py +++ b/dataproc/api/models/construct_model.py @@ -1,5 +1,6 @@ from neomodel import StructuredNode, StringProperty, IntegerProperty,UniqueIdProperty, RelationshipTo from uuid import uuid4 +from api.models.nodeutils import NodeUtils # from api.models.ocf_model import OCF # from api.models.storagehost_model import StorageHost @@ -15,4 +16,34 @@ class Construct(StructuredNode): has_ocf=RelationshipTo('api.models.ocf_model.OCF', 'HAS') has_storage_host=RelationshipTo('api.models.storagehost_model.StorageHost', 'HAS') has_computing_host=RelationshipTo('api.models.computinghost_model.ComputingHost', 'HAS') - has_user=RelationshipTo('api.models.user_model.User', 'HAS') \ No newline at end of file + has_user=RelationshipTo('api.models.user_model.User', 'HAS') + + @property + def serialize(self): + return { + 'node_properties': { + 'uuid': self.uuid, + 'name': self.name, + }, + } + + @property + def serialize_connections(self): + return [ + { + 'nodes_type': 'OCF', + 'nodes_related': self.serialize_relationships(self.ocf.all()), + }, + { + 'nodes_type': 'StorageHost', + 'nodes_related': self.serialize_relationships(self.storagehost.all()), + }, + { + 'nodes_type': 'ComputingHost', + 'nodes_related': self.serialize_relationships(self.computinghost.all()), + }, + { + 'nodes_type': 'User', + 'nodes_related': self.serialize_relationships(self.user.all()), + }, + ] diff --git a/dataproc/api/models/user_model.py b/dataproc/api/models/user_model.py index 0f415a0ab6e837312dc5a908de53f5930ef4dad9..fe84f9ac0f51bebd7670c829449b8250fe540fc2 100644 --- a/dataproc/api/models/user_model.py +++ b/dataproc/api/models/user_model.py @@ -6,12 +6,13 @@ class User(StructuredNode): name=StringProperty() surname=StringProperty() - @property - def serialize(self): - return { - 'node_properties': { - 'uuid': self.uuid, - 'username': self.username, - }, - } + # @property + # def serialize(self): + # return { + # 'node_properties': { + # 'uuid': self.uuid, + # 'username': self.username, + # }, + # } +