Commit 49ac2b9e authored by Klaus Wölfel's avatar Klaus Wölfel

wendelin: prevent race condition when creating new data analyses

parent 01850935
...@@ -4,7 +4,7 @@ from Products.ERP5Type.Errors import UnsupportedWorkflowMethod ...@@ -4,7 +4,7 @@ from Products.ERP5Type.Errors import UnsupportedWorkflowMethod
portal = context.getPortalObject() portal = context.getPortalObject()
portal_catalog = portal.portal_catalog portal_catalog = portal.portal_catalog
now = DateTime() today = DateTime().strftime('%d%m%Y')
if not include_delivered: if not include_delivered:
batch_simulation_state = "stopped" batch_simulation_state = "stopped"
...@@ -54,12 +54,22 @@ for movement in portal_catalog(query=query): ...@@ -54,12 +54,22 @@ for movement in portal_catalog(query=query):
for transformation in transformation_list: for transformation in transformation_list:
is_shared_data_analysis = False is_shared_data_analysis = False
data_analysis_id= "%s-%s-%s" % (today, delivery.getId(), transformation.getId())
# Check if analysis already exists # Check if analysis already exists
data_analysis = portal_catalog.getResultValue( data_analysis = portal_catalog.getResultValue(
portal_type="Data Analysis", portal_type="Data Analysis",
specialise_relative_url = transformation.getRelativeUrl(), specialise_relative_url = transformation.getRelativeUrl(),
causality_relative_url = delivery.getRelativeUrl()) causality_relative_url = delivery.getRelativeUrl())
# search again with ID in case data_analysis is not indexed yet
if data_analysis is None:
try:
data_analysis = portal.data_analysis_module[data_analysis_id]
except KeyError:
pass
if data_analysis is not None: if data_analysis is not None:
continue continue
...@@ -90,7 +100,8 @@ for movement in portal_catalog(query=query): ...@@ -90,7 +100,8 @@ for movement in portal_catalog(query=query):
source_project = delivery.getSourceProject(), source_project = delivery.getSourceProject(),
destination = delivery.getDestination(), destination = delivery.getDestination(),
destination_section = delivery.getDestinationSection(), destination_section = delivery.getDestinationSection(),
destination_project = delivery.getDestinationProject()) destination_project = delivery.getDestinationProject(),
id=data_analysis_id)
data_analysis.checkConsistency(fixit=True) data_analysis.checkConsistency(fixit=True)
# create input and output lines # create input and output lines
......
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