Commit 45b27bfe authored by Roque's avatar Roque

erp5_wendelin_data_lake_ingestion: do not return invalid data streams (filter by reference)

parent ccc378a2
""" """
This script is called from ebulk client to get list of Data Streams for a This script is called from ebulk client to get list of Data Streams for a Data set.
Data set.
""" """
import re
import json import json
from Products.ERP5Type.Log import log from Products.ERP5Type.Log import log
from Products.ZSQLCatalog.SQLCatalog import Query, SimpleQuery, ComplexQuery
portal = context.getPortalObject() portal = context.getPortalObject()
portal_catalog = portal.portal_catalog
reference_separator = portal.ERP5Site_getIngestionReferenceDictionary()["reference_separator"]
try: try:
data_set = portal.data_set_module.get(data_set_reference) data_set = portal.data_set_module.get(data_set_reference)
if data_set is None or portal.ERP5Site_checkReferenceInvalidated(data_set): if data_set is None or portal.ERP5Site_checkReferenceInvalidated(data_set):
return { "status_code": 0, "result": [] } return { "status_code": 0, "result": [] }
except Exception as e: # fails because unauthorized access except Exception as e: # fails because unauthorized access
log("Unauthorized access to getDataStreamList.") log("Unauthorized access to getDataStreamList: " + str(e))
return { "status_code": 1, "error_message": "401 - Unauthorized access. Please check your user credentials and try again." } return { "status_code": 1, "error_message": "401 - Unauthorized access. Please check your user credentials and try again." }
data_set = portal.data_set_module.get(data_set_reference) data_set = portal.data_set_module.get(data_set_reference)
...@@ -29,10 +23,11 @@ data_stream_list = [] ...@@ -29,10 +23,11 @@ data_stream_list = []
for stream in data_set.DataSet_getDataStreamList(): for stream in data_set.DataSet_getDataStreamList():
if stream.getVersion() == "": if stream.getVersion() == "":
return { "status_code": 2, "result": [] } return { "status_code": 2, "result": [] }
data_stream_list.append({ 'id': 'data_stream_module/'+stream.getId(), if not portal.ERP5Site_checkReferenceInvalidated(stream):
'reference': stream.getReference(), data_stream_list.append({ 'id': 'data_stream_module/'+stream.getId(),
'size': stream.getSize(), 'reference': stream.getReference(),
'hash': stream.getVersion() }) 'size': stream.getSize(),
'hash': stream.getVersion() })
dict = { 'status_code': 0, 'result': data_stream_list } result_dict = { 'status_code': 0, 'result': data_stream_list }
return json.dumps(dict) return json.dumps(result_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