Skip to content

Commit

Permalink
- modified save_relation to provide the method also as public method
Browse files Browse the repository at this point in the history
  • Loading branch information
B-Stefan committed Nov 16, 2016
1 parent b663fd7 commit 45116fc
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions provdbconnector/prov_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,23 +349,27 @@ def _save_bundle(self, prov_bundle):
if relation.get_type() is PROV_MENTION:
continue

self._save_relation(relation, bundle_id, prov_bundle.identifier)
self.save_relation(relation, bundle_id)

return bundle_id

def _save_relation(self, prov_relation, bundle_id=None, bundle_identifier=None):
def save_relation(self, prov_relation, bundle_id=None):
"""
Saves a relation between 2 nodes that are already in the database.
:param prov_relation: The ProvRelation instance
:type prov_relation: ProvRelation
:param bundle_id
:type bundle_id: str
:param bundle_identifier
:type bundle_identifier: str
:return: Relation id
:rtype: str
"""

if not isinstance(prov_relation, ProvRelation):
raise InvalidArgumentTypeException(
"prov_relation was {}, expected: {}".format(type(prov_relation), type(ProvRelation)))


# get from and to node
from_tuple, to_tuple = prov_relation.formal_attributes[:2]
from_qualified_name = from_tuple[1]
Expand Down Expand Up @@ -443,7 +447,7 @@ def _save_bundle_links(self, prov_bundle):
if mention.get_type() is not PROV_MENTION:
continue

self._save_relation(mention)
self.save_relation(mention)

@staticmethod
def _get_metadata_and_attributes_for_record(prov_record, bundle_id=None):
Expand Down

0 comments on commit 45116fc

Please sign in to comment.