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=""):
self.__class_name = "fml40::{}".format(self.__class__.__name__)
else:
self.__class_name = "ml40::{}".format(self.__class__.__name__)
self.__identifier = ID(identifier).identifier
self.__identifier = identifier
self.__subFeatures = dict()
self.__json_out = dict()
......@@ -94,7 +94,7 @@ def identifier(self, value):
:type value: str
"""
self.__identifier = ID(value).identifier
self.__identifier = value
@property
def subFeatures(self):
......@@ -129,8 +129,9 @@ def to_json(self):
self.__json_out = {
"class": self.class_name,
"identifier": self.identifier,
}
if self.identifier:
self.__json_out["identifier"] = self.identifier
if self.name:
self.__json_out["name"] = self.name
if self.subFeatures:
......
......@@ -15,7 +15,7 @@ def __init__(self, name="", identifier=""):
:param identifier: Identifier of the feature
"""
self.__identifier = ID(identifier).identifier
self.__identifier = identifier
self.__name = name
# TODO: Remove code duplication (feature.py).
......@@ -74,7 +74,7 @@ def identifier(self, value):
:param value: Proposal of the identifier
"""
self.__identifier = ID(value).identifier
self.__identifier = value
def to_json(self):
"""Returns a JSON representation of this role.
......@@ -82,6 +82,7 @@ def to_json(self):
self.__json_out = {
"class": self.__class_name,
"identifier": self.__identifier,
}
if self.identifier:
self.__json_out["identifier"] = self.identifier
return self.__json_out
......@@ -66,8 +66,6 @@ def __init__(
self.__model = model
self.__thing_id = model.get("thingId", "")
if not self.__thing_id:
self.__thing_id = ID().identifier
self.__policy_id = model.get("policyId", "")
self.__grant_type = grant_type
self.__username = username
......@@ -843,8 +841,10 @@ def to_dir_json(self):
for key in self.features.keys():
feature_target = {
"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}
# if the feature has targets, like ml40::Composite
if hasattr(self.features[key], "targets"):
......@@ -906,11 +906,12 @@ def to_subthing_json(self):
json_out = {
"class": "ml40::Thing",
"identifier": self.thing_id,
"name": self.name,
"roles": [],
"features": [],
}
if self.thing_id:
json_out["identifier"] = self.thing_id
for key in self.roles.keys():
json_out["roles"].append(self.roles[key].to_json())
for key in self.features.keys():
......@@ -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():
role_entry = {"association": "roles", "target": self.roles[key].to_json()}
json_out["links"].append(role_entry)
for key in self.features.keys():
feature_target = {
"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}
json_out["links"].append(feature_entry)
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