node_factory.py
NodeFactory
¶
A Factory to create objects of type Node.
Source code in celonis_api/studio/node_factory.py
class NodeFactory:
"""A Factory to create objects of type [Node][celonis_api.studio.node.Node]."""
@staticmethod
def create_node_from_data(parent, celonis: 'Celonis', node_data: typing.Dict) -> Node:
"""Creates a new [Node][celonis_api.studio.node.Node] based on `nodeType` and `assetType`.
Args:
parent: Parent Object.
celonis: Celonis Base Object.
node_data: Dictionary with values for keys `nodeType` and `assetType`.
Returns:
The respective Node Type.
"""
if node_data["nodeType"] == "ASSET" and node_data["assetType"] == "SEMANTIC_MODEL":
return KnowledgeModel(parent, celonis, node_data)
elif node_data["nodeType"] == "FOLDER":
return Folder(parent, celonis, node_data["id"])
elif node_data["nodeType"] == "ASSET" and node_data["assetType"] == "ANALYSIS":
return Analysis(parent, celonis, node_data["id"])
elif node_data["nodeType"] == "ASSET" and node_data["assetType"] == "BOARD":
return View(parent, celonis, node_data["id"])
elif node_data["nodeType"] == "ASSET" and node_data["assetType"] == "SKILL":
return Skill(parent, celonis, node_data["id"])
else:
return Node(parent, celonis, node_data["id"])
create_node_from_data(parent, celonis, node_data)
staticmethod
¶
Creates a new Node based on nodeType
and assetType
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent |
Parent Object. |
required | |
celonis |
Celonis |
Celonis Base Object. |
required |
node_data |
Dict |
Dictionary with values for keys |
required |
Returns:
Type | Description |
---|---|
Node |
The respective Node Type. |
Source code in celonis_api/studio/node_factory.py
@staticmethod
def create_node_from_data(parent, celonis: 'Celonis', node_data: typing.Dict) -> Node:
"""Creates a new [Node][celonis_api.studio.node.Node] based on `nodeType` and `assetType`.
Args:
parent: Parent Object.
celonis: Celonis Base Object.
node_data: Dictionary with values for keys `nodeType` and `assetType`.
Returns:
The respective Node Type.
"""
if node_data["nodeType"] == "ASSET" and node_data["assetType"] == "SEMANTIC_MODEL":
return KnowledgeModel(parent, celonis, node_data)
elif node_data["nodeType"] == "FOLDER":
return Folder(parent, celonis, node_data["id"])
elif node_data["nodeType"] == "ASSET" and node_data["assetType"] == "ANALYSIS":
return Analysis(parent, celonis, node_data["id"])
elif node_data["nodeType"] == "ASSET" and node_data["assetType"] == "BOARD":
return View(parent, celonis, node_data["id"])
elif node_data["nodeType"] == "ASSET" and node_data["assetType"] == "SKILL":
return Skill(parent, celonis, node_data["id"])
else:
return Node(parent, celonis, node_data["id"])