Commit 6722bfb5 authored by Jiahang Chen's avatar Jiahang Chen
Browse files

deactivate lokal id

parent e6a7ed9e
...@@ -24,7 +24,7 @@ def __init__(self, name="", identifier=""): ...@@ -24,7 +24,7 @@ def __init__(self, name="", identifier=""):
self.__class_name = "fml40::{}".format(self.__class__.__name__) self.__class_name = "fml40::{}".format(self.__class__.__name__)
else: else:
self.__class_name = "ml40::{}".format(self.__class__.__name__) self.__class_name = "ml40::{}".format(self.__class__.__name__)
self.__identifier = ID(identifier).identifier self.__identifier = identifier
self.__subFeatures = dict() self.__subFeatures = dict()
self.__json_out = dict() self.__json_out = dict()
...@@ -94,7 +94,7 @@ def identifier(self, value): ...@@ -94,7 +94,7 @@ def identifier(self, value):
:type value: str :type value: str
""" """
self.__identifier = ID(value).identifier self.__identifier = value
@property @property
def subFeatures(self): def subFeatures(self):
...@@ -129,8 +129,9 @@ def to_json(self): ...@@ -129,8 +129,9 @@ def to_json(self):
self.__json_out = { self.__json_out = {
"class": self.class_name, "class": self.class_name,
"identifier": self.identifier,
} }
if self.identifier:
self.__json_out["identifier"] = self.identifier
if self.name: if self.name:
self.__json_out["name"] = self.name self.__json_out["name"] = self.name
if self.subFeatures: if self.subFeatures:
......
...@@ -15,7 +15,7 @@ def __init__(self, name="", identifier=""): ...@@ -15,7 +15,7 @@ def __init__(self, name="", identifier=""):
:param identifier: Identifier of the feature :param identifier: Identifier of the feature
""" """
self.__identifier = ID(identifier).identifier self.__identifier = identifier
self.__name = name self.__name = name
# TODO: Remove code duplication (feature.py). # TODO: Remove code duplication (feature.py).
...@@ -74,7 +74,7 @@ def identifier(self, value): ...@@ -74,7 +74,7 @@ def identifier(self, value):
:param value: Proposal of the identifier :param value: Proposal of the identifier
""" """
self.__identifier = ID(value).identifier self.__identifier = value
def to_json(self): def to_json(self):
"""Returns a JSON representation of this role. """Returns a JSON representation of this role.
...@@ -82,6 +82,7 @@ def to_json(self): ...@@ -82,6 +82,7 @@ def to_json(self):
self.__json_out = { self.__json_out = {
"class": self.__class_name, "class": self.__class_name,
"identifier": self.__identifier,
} }
if self.identifier:
self.__json_out["identifier"] = self.identifier
return self.__json_out return self.__json_out
...@@ -66,8 +66,6 @@ def __init__( ...@@ -66,8 +66,6 @@ def __init__(
self.__model = model self.__model = model
self.__thing_id = model.get("thingId", "") self.__thing_id = model.get("thingId", "")
if not self.__thing_id:
self.__thing_id = ID().identifier
self.__policy_id = model.get("policyId", "") self.__policy_id = model.get("policyId", "")
self.__grant_type = grant_type self.__grant_type = grant_type
self.__username = username self.__username = username
...@@ -843,8 +841,10 @@ def to_dir_json(self): ...@@ -843,8 +841,10 @@ def to_dir_json(self):
for key in self.features.keys(): for key in self.features.keys():
feature_target = { feature_target = {
"class": self.features[key].to_json()["class"], "class": self.features[key].to_json()["class"],
"identifier": self.features[key].to_json()["identifier"]
} }
if self.features[key].to_json().get("identifier") is not None:
feature_target["identifier"] = self.features[key].to_json()["identifier"]
feature_entry = {"association": "features", "target": feature_target} feature_entry = {"association": "features", "target": feature_target}
# if the feature has targets, like ml40::Composite # if the feature has targets, like ml40::Composite
if hasattr(self.features[key], "targets"): if hasattr(self.features[key], "targets"):
...@@ -906,11 +906,12 @@ def to_subthing_json(self): ...@@ -906,11 +906,12 @@ def to_subthing_json(self):
json_out = { json_out = {
"class": "ml40::Thing", "class": "ml40::Thing",
"identifier": self.thing_id,
"name": self.name, "name": self.name,
"roles": [], "roles": [],
"features": [], "features": [],
} }
if self.thing_id:
json_out["identifier"] = self.thing_id
for key in self.roles.keys(): for key in self.roles.keys():
json_out["roles"].append(self.roles[key].to_json()) json_out["roles"].append(self.roles[key].to_json())
for key in self.features.keys(): for key in self.features.keys():
...@@ -927,15 +928,18 @@ def to_subthing_dir_json(self): ...@@ -927,15 +928,18 @@ def to_subthing_dir_json(self):
""" """
json_out = {"class": "ml40::Thing", "identifier": self.thing_id, "links": []} json_out = {"class": "ml40::Thing", "links": []}
if self.thing_id:
json_out["identifier"] = self.thing_id
for key in self.roles.keys(): for key in self.roles.keys():
role_entry = {"association": "roles", "target": self.roles[key].to_json()} role_entry = {"association": "roles", "target": self.roles[key].to_json()}
json_out["links"].append(role_entry) json_out["links"].append(role_entry)
for key in self.features.keys(): for key in self.features.keys():
feature_target = { feature_target = {
"class": self.features[key].to_json()["class"], "class": self.features[key].to_json()["class"],
"identifier": self.features[key].to_json()["identifier"],
} }
if self.features[key].to_json().get("identifier") is not None:
feature_target["identifier"] = self.features[key].to_json()["identifier"]
feature_entry = {"association": "features", "target": feature_target} feature_entry = {"association": "features", "target": feature_target}
json_out["links"].append(feature_entry) json_out["links"].append(feature_entry)
return json_out return json_out
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment