Commit a47acb52 authored by Klaus Wölfel's avatar Klaus Wölfel

Fix a broken case of Worklist calculation when using security_uid columns

parent 599d5fe8
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
""" """
Most of the code in this file has been taken from patches/WorkflowTool.py Most of the code in this file has been taken from patches/WorkflowTool.py
""" """
from collections import defaultdict
from six import string_types as basestring from six import string_types as basestring
from AccessControl import ClassSecurityInfo, Unauthorized from AccessControl import ClassSecurityInfo, Unauthorized
from Acquisition import aq_base from Acquisition import aq_base
...@@ -947,21 +948,17 @@ def sumCatalogResultByWorklist(grouped_worklist_dict, catalog_result): ...@@ -947,21 +948,17 @@ def sumCatalogResultByWorklist(grouped_worklist_dict, catalog_result):
It is better to avoid reading multiple times the catalog result from It is better to avoid reading multiple times the catalog result from
flexibility point of view: if it must ever be changed into a cursor, this flexibility point of view: if it must ever be changed into a cursor, this
code will keep working nicely without needing to rewind the cursor. code will keep working nicely without needing to rewind the cursor.
This code assumes that all worklists have the same set of criterion ids,
and that when a criterion id is associated with an ExclusionList it is
also true for all worklists.
""" """
worklist_result_dict = {} worklist_result_dict = {}
if len(catalog_result) > 0: if len(catalog_result) > 0:
# Transtype all worklist definitions where needed # Transtype all worklist definitions where needed
criterion_id_list = [] criterion_id_list_by_worklist_dict = defaultdict(list)
class_dict = {name: _sql_cast_dict.get(x['type'], _sql_cast_fallback) class_dict = {name: _sql_cast_dict.get(x['type'], _sql_cast_fallback)
for name, x in six.iteritems(catalog_result.data_dictionary())} for name, x in six.iteritems(catalog_result.data_dictionary())}
for criterion_dict in six.itervalues(grouped_worklist_dict): for worklist_id, criterion_dict in six.iteritems(grouped_worklist_dict):
for criterion_id, criterion_value_list in six.iteritems(criterion_dict): for criterion_id, criterion_value_list in six.iteritems(criterion_dict):
if type(criterion_value_list) is not ExclusionList: if type(criterion_value_list) is not ExclusionList:
criterion_id_list.append(criterion_id) criterion_id_list_by_worklist_dict[worklist_id].append(criterion_id)
expected_class = class_dict[criterion_id] expected_class = class_dict[criterion_id]
if type(criterion_value_list[0]) is not expected_class: if type(criterion_value_list[0]) is not expected_class:
criterion_dict[criterion_id] = frozenset([expected_class(x) for x in criterion_value_list]) criterion_dict[criterion_id] = frozenset([expected_class(x) for x in criterion_value_list])
...@@ -972,7 +969,7 @@ def sumCatalogResultByWorklist(grouped_worklist_dict, catalog_result): ...@@ -972,7 +969,7 @@ def sumCatalogResultByWorklist(grouped_worklist_dict, catalog_result):
result_count = int(result_line[COUNT_COLUMN_TITLE]) result_count = int(result_line[COUNT_COLUMN_TITLE])
for worklist_id, criterion_dict in six.iteritems(grouped_worklist_dict): for worklist_id, criterion_dict in six.iteritems(grouped_worklist_dict):
is_candidate = True is_candidate = True
for criterion_id in criterion_id_list: for criterion_id in criterion_id_list_by_worklist_dict[worklist_id]:
criterion_value_set = criterion_dict[criterion_id] criterion_value_set = criterion_dict[criterion_id]
if result_line[criterion_id] not in criterion_value_set: if result_line[criterion_id] not in criterion_value_set:
is_candidate = False is_candidate = False
......
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