Commit b34b5b22 authored by Olof Svensson's avatar Olof Svensson

[Node] add ErrorHandler

parent 1ba331cc
......@@ -61,8 +61,8 @@ class Link(object):
_JSON_SINK_NODE_ID = 'sink_node_id'
_JSON_LINK_ID = 'link_id'
def __init__(self, source_node, sink_node, source_channel, sink_channel,
id=None):
def __init__(self, source_node, sink_node, source_channel='default',
sink_channel='default', id=None):
self.id = get_next_link_free_id() if id is None else id
if isinstance(source_node, int):
self.source_node_id = source_node
......
......@@ -86,6 +86,7 @@ class Node(object):
_JSON_PROCESS_PT = 'process_pt'
_JSON_ID = 'id'
_JSON_PROPERTIES = 'properties'
_JSON_ERROR_HANDLER = 'error_handler'
def __init__(self, processing_pt, id=None, properties=None,
error_handler=None):
......@@ -209,11 +210,19 @@ class Node(object):
:return: json description of the node
:rtype: dict
"""
return {
res = {
self._JSON_PROCESS_PT: self.process_pt,
self._JSON_ID: self.id,
self._JSON_PROPERTIES: self.properties,
}
res.update(self._get_error_handler_json())
return res
def _get_error_handler_json(self):
error_handler_json = self._error_handler.to_json() if self._error_handler else {}
return {
self._JSON_ERROR_HANDLER: error_handler_json,
}
@staticmethod
def from_json(json_data):
......@@ -264,3 +273,16 @@ class WorkflowException(Exception):
self.errorMessage = msg
self.data = data
self.traceBack = traceBack
class ErrorHandler(Node):
'''
TODO
'''
def __init__(self, processing_pt, id=None, properties=None):
super(ErrorHandler, self).__init__(processing_pt=processing_pt, id=id,
properties=properties,
error_handler=None)
def _get_error_handler_json(self):
return {}
\ No newline at end of file
......@@ -123,7 +123,7 @@ class Scheme(object):
:param output_file: name of the output file.
:type: str
"""
if output_file.lower.endswith('.json'):
if output_file.lower().endswith('.json'):
self.save_as_json(output_file)
else:
self.save_as_xml(output_file)
......
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