Commit dd6bfa1d authored by Roque Porchetto's avatar Roque Porchetto

erp5_wendelin_telecom_ingestion: refactoring in data ingestion reference

parent 89478a9c
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5Type.Log import log
# reference parameter example: telecom.MNE.filename.fif.EOF # reference parameter example: supplier.dataset.filename.fif.EOF
# ingestion reference example: telecom_MNE_filename_fif # ingestion reference example: dataset_filename_fif
# ingestion id example: telecom_MNE_filename_fif_20170615
FALSE = "FALSE" FALSE = "FALSE"
TRUE = "TRUE" TRUE = "TRUE"
today_string = DateTime().strftime('%Y%m%d')
portal = context.getPortalObject() portal = context.getPortalObject()
portal_catalog = portal.portal_catalog portal_catalog = portal.portal_catalog
data_ingestion_reference = '_'.join(reference.split('_')[:-1]) #'_'.join(reference.split('.')[:-1]) try:
data_ingestion_id = '%s_%s' %(data_ingestion_reference, today_string) context.logEntry("Attempt to do a new ingestion with reference: %s" % reference)
# first search for applicable data ingestion # remove supplier and eof from reference
data_ingestion = portal_catalog.getResultValue( data_ingestion_reference = '_'.join(reference.split('_')[1:-1])
portal_type = 'Data Ingestion',
simulation_state = 'planned', data_ingestion = portal_catalog.getResultValue(
reference = data_ingestion_reference) portal_type = 'Data Ingestion',
reference = data_ingestion_reference)
if data_ingestion is None:
document = portal.data_ingestion_module.get(data_ingestion_id) if data_ingestion is None:
if (document is not None):
if document.getSimulationState() == 'planned':
return FALSE
else:
return TRUE
else:
return FALSE return FALSE
else:
if data_ingestion.getSimulationState() == 'planned':
return FALSE return FALSE
context.logEntry("[ERROR] Data Ingestion reference %s already exists" % data_ingestion_reference)
return TRUE
except Exception as e:
context.logEntry("[ERROR] At script ingestionReferenceExists \n[ERROR] " + str(e))
raise e
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