aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorasteroide <thomas.duval@orange.com>2017-06-01 11:20:24 +0200
committerasteroide <thomas.duval@orange.com>2017-06-01 11:20:24 +0200
commit1f38c2e011df775e3fac1c0200df6e7fea43f25c (patch)
treeb222842eed6f6e4c73c9932089f6cdb703e9b135
parentf6a6df2f488c464d949fcd350d1d96f47969a93c (diff)
Add the possibility to force the UUID on particular items (for the slaves)
Change-Id: Iaac3d3fc03a68d983be5bad438440c718073210d
-rw-r--r--moonv4/moon_db/moon_db/backends/sql.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/moonv4/moon_db/moon_db/backends/sql.py b/moonv4/moon_db/moon_db/backends/sql.py
index 8cb6bb8e..b9ff332c 100644
--- a/moonv4/moon_db/moon_db/backends/sql.py
+++ b/moonv4/moon_db/moon_db/backends/sql.py
@@ -1051,7 +1051,7 @@ class ModelConnector(BaseConnector, ModelDriver):
if not ref:
ref = MetaRule.from_dict(
{
- "id": uuid4().hex,
+ "id": meta_rule_id if meta_rule_id else uuid4().hex,
"value": value
}
)
@@ -1084,7 +1084,7 @@ class ModelConnector(BaseConnector, ModelDriver):
ref_list = query.all()
return {_ref.id: _ref.to_dict() for _ref in ref_list}
- def add_subject_category(self, name, description):
+ def add_subject_category(self, name, description, uuid=None):
with self.get_session_for_write() as session:
query = session.query(SubjectCategory)
query = query.filter_by(name=name)
@@ -1092,7 +1092,7 @@ class ModelConnector(BaseConnector, ModelDriver):
if not ref:
ref = SubjectCategory.from_dict(
{
- "id": uuid4().hex,
+ "id": uuid if uuid else uuid4().hex,
"name": name,
"description": description
}
@@ -1116,7 +1116,7 @@ class ModelConnector(BaseConnector, ModelDriver):
ref_list = query.all()
return {_ref.id: _ref.to_dict() for _ref in ref_list}
- def add_object_category(self, name, description):
+ def add_object_category(self, name, description, uuid=None):
with self.get_session_for_write() as session:
query = session.query(ObjectCategory)
query = query.filter_by(name=name)
@@ -1124,7 +1124,7 @@ class ModelConnector(BaseConnector, ModelDriver):
if not ref:
ref = ObjectCategory.from_dict(
{
- "id": uuid4().hex,
+ "id": uuid if uuid else uuid4().hex,
"name": name,
"description": description
}
@@ -1148,7 +1148,7 @@ class ModelConnector(BaseConnector, ModelDriver):
ref_list = query.all()
return {_ref.id: _ref.to_dict() for _ref in ref_list}
- def add_action_category(self, name, description):
+ def add_action_category(self, name, description, uuid=None):
with self.get_session_for_write() as session:
query = session.query(ActionCategory)
query = query.filter_by(name=name)
@@ -1156,7 +1156,7 @@ class ModelConnector(BaseConnector, ModelDriver):
if not ref:
ref = ActionCategory.from_dict(
{
- "id": uuid4().hex,
+ "id": uuid if uuid else uuid4().hex,
"name": name,
"description": description
}