-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
58 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from common.constants import IDS, NODES_LABEL, MODEL | ||
|
||
class DataModel: | ||
def __init__(self, model): | ||
self.model = model | ||
|
||
# model connivent functions | ||
""" | ||
get model id fields in the given model | ||
""" | ||
def get_model_ids(self): | ||
return self.model.get(IDS, None) | ||
|
||
""" | ||
get id field of a given node in the model | ||
""" | ||
def get_node_id(self, node): | ||
return self.model[MODEL][NODES_LABEL][node].get("id_property", None) | ||
|
||
|
||
""" | ||
get properties of a node in the model | ||
""" | ||
def get_node_props(self, node): | ||
if self.model[MODEL][NODES_LABEL].get(node): | ||
return self.model[MODEL][NODES_LABEL][node].get("properties", None) | ||
|
||
""" | ||
get required properties of a node in the model | ||
""" | ||
def get_node_req_props(self, node): | ||
props = self.get_node_props(self.model, node) | ||
if not props: | ||
return None | ||
return {k: v for (k, v) in props.items() if v.get("required") == True} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters