Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fml40-reference-implementation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KWH40
fml40-reference-implementation
Commits
6722bfb5
Commit
6722bfb5
authored
4 years ago
by
Jiahang Chen
Browse files
Options
Downloads
Patches
Plain Diff
deactivate lokal id
parent
e6a7ed9e
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ml/feature.py
+4
-3
4 additions, 3 deletions
ml/feature.py
ml/role.py
+4
-3
4 additions, 3 deletions
ml/role.py
ml/thing.py
+10
-6
10 additions, 6 deletions
ml/thing.py
with
18 additions
and
12 deletions
ml/feature.py
+
4
−
3
View file @
6722bfb5
...
...
@@ -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
:
...
...
This diff is collapsed.
Click to expand it.
ml/role.py
+
4
−
3
View file @
6722bfb5
...
...
@@ -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
This diff is collapsed.
Click to expand it.
ml/thing.py
+
10
−
6
View file @
6722bfb5
...
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment