Commit 3e50bea0 authored by Klaus Wölfel's avatar Klaus Wölfel

data analysis creation: add option to include stopped and deliverred

input data movements in calculation of which data analysis to create
parent 3590fcb8
from DateTime import DateTime from DateTime import DateTime
from Products.ZSQLCatalog.SQLCatalog import AndQuery, OrQuery, Query, NegatedQuery, SimpleQuery from Products.ZSQLCatalog.SQLCatalog import AndQuery, OrQuery, Query
portal = context.getPortalObject() portal = context.getPortalObject()
portal_catalog = portal.portal_catalog portal_catalog = portal.portal_catalog
now = DateTime() now = DateTime()
if not include_delivered:
batch_simulation_state = "stopped"
stream_simulation_state = "started"
else:
batch_simulation_state = ["stopped", "delivered"]
stream_simulation_state = ["started", "stopped", "delivered"]
query = AndQuery( query = AndQuery(
Query(portal_type = ["Data Ingestion Line", "Data Analysis Line"]), Query(portal_type = ["Data Ingestion Line", "Data Analysis Line"]),
Query(**{"stock.quantity": "!=0"}), Query(**{"stock.quantity": "!=0"}),
Query(resource_portal_type = "Data Product"), Query(resource_portal_type = "Data Product"),
# Should be improved to support mor than one analysis per ingestion # Should be improved to support mor than one analysis per ingestion
#SimpleQuery(parent_causality_related_relative_url = None), #SimpleQuery(parent_causality_related_relative_url = None),
OrQuery( OrQuery(Query(simulation_state = batch_simulation_state,
Query(simulation_state = "stopped",
use_relative_url = "use/big_data/ingestion/batch"), use_relative_url = "use/big_data/ingestion/batch"),
AndQuery( Query(simulation_state = stream_simulation_state,
Query(simulation_state = "started"), use_relative_url = "use/big_data/ingestion/stream")))
Query(use_relative_url = "use/big_data/ingestion/stream"))))
for movement in portal_catalog(query): for movement in portal_catalog(query):
if movement.getQuantity() <= 0: if movement.getQuantity() <= 0:
...@@ -44,7 +50,8 @@ for movement in portal_catalog(query): ...@@ -44,7 +50,8 @@ for movement in portal_catalog(query):
portal_type = "Data Analysis", portal_type = "Data Analysis",
title = transformation.getTitle(), title = transformation.getTitle(),
reference = delivery.getReference(), reference = delivery.getReference(),
start_date = now, start_date = delivery.getStartDate(),
stop_date = delivery.getStopDate(),
specialise_value_list = [transformation] + data_supply, specialise_value_list = [transformation] + data_supply,
causality_value = delivery, causality_value = delivery,
source = delivery.getSource(), source = delivery.getSource(),
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string>include_delivered=False</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
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