Commit d67875ef authored by Klaus Wölfel's avatar Klaus Wölfel Committed by Klaus Wölfel

data model: split ingestion policy script (tag parsing) form ingestion...

data model: split ingestion policy script (tag parsing) form ingestion operation (writing to data stream)
parent 238c1b62
Pipeline #1500 skipped
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
############################################################################## ##############################################################################
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type.Core.Folder import Folder from Products.ERP5Type.Core.Folder import Folder
from zExceptions import BadRequest from zExceptions import BadRequest, NotFound
class IngestionPolicy(Folder): class IngestionPolicy(Folder):
""" """
...@@ -60,9 +60,38 @@ class IngestionPolicy(Folder): ...@@ -60,9 +60,38 @@ class IngestionPolicy(Folder):
if self.REQUEST.method != 'POST': if self.REQUEST.method != 'POST':
raise BadRequest('Only POST request is allowed.') raise BadRequest('Only POST request is allowed.')
script_id = self.getScriptId() reference = self.REQUEST.get('reference')
if script_id is not None: data_chunk = self.REQUEST.get('data_chunk')
script = getattr(self, script_id, None) tag_parsing_script_id = self.getScriptId()
if script is not None:
# leave it all to responsible script who should do real ingestion if tag_parsing_script_id is None:
script(**kw) raise NotFound('No tag parsing script found.')
\ No newline at end of file
tag_parsing_script = getattr(self, tag_parsing_script_id, None)
if tag_parsing_script is None:
raise NotFound('No tag parsing script found.')
# the script parses the fluentd tag (reference) and returns a dictionary
# which describes the ingestion movement. Then we use this dictionary to
# search for an existing movement and if we do not find one, we create
# a new one.
movement_dict = tag_parsing_script(reference)
# to simplyfy the catalog query, at the moment we assume that aggregate
# and resource are defined on Data Ingestion Line and the rest is
# defined on Data Ingestion. This assumption should be dropped later and
# simulation be used instead.
ingestion_operation, parameter_dict = \
self.IngestionPolicy_getIngestionOperationAndParameterDict(movement_dict,
reference)
if ingestion_operation is None:
raise NotFound('No ingestion operation found.')
ingestion_script_id = ingestion_operation.getScriptId()
if ingestion_script_id is None:
raise NotFound('No ingestion operation script id defined.')
ingestion_script = getattr(self, ingestion_script_id, None)
if ingestion_script is None:
raise NotFound('No such ingestion script found: %s' %ingestion_script_id)
ingestion_script(data_chunk=data_chunk, **parameter_dict)
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