Commit be176741 authored by Roque Porchetto's avatar Roque Porchetto

erp5_wendelin_telecom_ingestion: slash ( / ) reference separator and directory tree

parent 3728c446
...@@ -3,12 +3,13 @@ from Products.ERP5Type.Log import log ...@@ -3,12 +3,13 @@ from Products.ERP5Type.Log import log
context.logEntry("[NEW INGESTION]") context.logEntry("[NEW INGESTION]")
context.logEntry("Reference: %s" % reference) context.logEntry("Reference: %s" % reference)
record = reference.rsplit('.') record = reference.rsplit('/')
filename = record[2] if (len(record) >= 5) else reference length = len(record)
extension = record[3] if (len(record) >= 5) else "fif" specialise_reference = record[0] if (length >= 5) else "default"
eof = record[4] if (len(record) >= 5) else "eof" aggregate_data_set_reference = record[1] if (length >= 5) else "default"
specialise_reference = record[0] if (len(record) >= 5) else "default" filename = '/'.join(record[2:-2]) if (length >= 5) else reference
aggregate_data_set_reference = record[1] if (len(record) >= 5) else "default" extension = record[length-2] if (length >= 5) else "fif"
eof = record[length-1] if (length >= 5) else "eof"
dict = { 'filename': filename, dict = { 'filename': filename,
'extension': extension, 'extension': extension,
......
...@@ -12,11 +12,11 @@ for data_set in portal_catalog(**kw_dict): ...@@ -12,11 +12,11 @@ for data_set in portal_catalog(**kw_dict):
if not data_set.getReference().endswith("_invalid"): if not data_set.getReference().endswith("_invalid"):
context.logEntry("Invalidating data set and dependencies for: " + data_set.getReference()) context.logEntry("Invalidating data set and dependencies for: " + data_set.getReference())
log("Ivalid Dataset: " + str(data_set.getReference())) log("Ivalid Dataset: " + str(data_set.getReference()))
reference_query = Query(**{'reference': data_set.getReference()+'_%'}) reference_query = Query(**{'reference': data_set.getReference()+'/%'})
kw_dict = {"portal_type": "Data Stream", kw_dict = {"portal_type": "Data Stream",
"query": reference_query} "query": reference_query}
for data_stream in portal_catalog(**kw_dict): for data_stream in portal_catalog(**kw_dict):
if data_stream.getReference().startswith(data_set.getReference()+'_'): if data_stream.getReference().startswith(data_set.getReference()+'/'):
log("Related data stream: " + data_stream.getReference()) log("Related data stream: " + data_stream.getReference())
portal.ERP5Site_invalidateIngestionObjects(data_stream.getReference()) portal.ERP5Site_invalidateIngestionObjects(data_stream.getReference())
log("Invalidating data set") log("Invalidating data set")
......
...@@ -9,7 +9,7 @@ portal_catalog = portal.portal_catalog ...@@ -9,7 +9,7 @@ portal_catalog = portal.portal_catalog
try: try:
# remove supplier and eof from reference # remove supplier and eof from reference
reference = '_'.join(reference.split('.')[1:-1]) #'_'.join(reference.split('.')[:-1]) reference = '/'.join(reference.split('/')[1:-1]) #'_'.join(reference.split('.')[:-1])
log("Reference: " + reference) log("Reference: " + reference)
context.logEntry("Data Ingestion reference: %s" % reference) context.logEntry("Data Ingestion reference: %s" % reference)
...@@ -18,7 +18,7 @@ try: ...@@ -18,7 +18,7 @@ try:
resource_reference = movement_dict.get('resource_reference', None) resource_reference = movement_dict.get('resource_reference', None)
specialise_reference = movement_dict.get('specialise_reference', None) specialise_reference = movement_dict.get('specialise_reference', None)
dataset_reference = movement_dict.get('aggregate_data_set_reference', None) dataset_reference = movement_dict.get('aggregate_data_set_reference', None)
data_ingestion_id = '%s_%s_%s' %(specialise_reference, data_ingestion_reference, today_string) data_ingestion_id = '%s_%s_%s' %(specialise_reference, data_ingestion_reference.replace("/","_"), today_string)
context.logEntry("Data Ingestion ID: %s" % reference) context.logEntry("Data Ingestion ID: %s" % reference)
# search for applicable data ingestion # search for applicable data ingestion
......
...@@ -14,8 +14,12 @@ try: ...@@ -14,8 +14,12 @@ try:
context.logEntry("Attempt to do a new ingestion with reference: %s" % reference) context.logEntry("Attempt to do a new ingestion with reference: %s" % reference)
# remove supplier and eof from reference # remove supplier and eof from reference
data_ingestion_reference = '_'.join(reference.split('.')[1:-1]) data_ingestion_reference = '/'.join(reference.split('/')[1:-1])
EOF = reference.split('.')[-1] EOF = reference.split('/')[-1]
if data_ingestion_reference is "":
context.logEntry("[ERROR] Data Ingestion reference is not well formated")
raise ValueError("Data Ingestion reference is not well formated")
data_ingestion = portal_catalog.getResultValue( data_ingestion = portal_catalog.getResultValue(
portal_type = 'Data Ingestion', portal_type = 'Data Ingestion',
......
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