Commit af8a8210 authored by Vincent Pelletier's avatar Vincent Pelletier

Massive code factorisation.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15943 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9a140d31
...@@ -470,7 +470,18 @@ class SimulationTool(BaseTool): ...@@ -470,7 +470,18 @@ class SimulationTool(BaseTool):
sql_kw['input'] = input sql_kw['input'] = input
sql_kw['output'] = output sql_kw['output'] = output
column_value_dict = {} class DictMixIn(dict):
def set(dictionary, key, value):
result = not(not(value))
if result:
dictionary[key] = value
return result
def setUIDList(dictionary, key, value, as_text=0):
uid_list = self._generatePropertyUidList(value, as_text=as_text)
return dictionary.set(key, uid_list)
column_value_dict = DictMixIn()
if omit_mirror_date: if omit_mirror_date:
date_dict = {'query':[], 'operator':'and'} date_dict = {'query':[], 'operator':'and'}
...@@ -494,112 +505,48 @@ class SimulationTool(BaseTool): ...@@ -494,112 +505,48 @@ class SimulationTool(BaseTool):
column_value_dict['date'] = {'query': [to_date], 'range': 'ngt'} column_value_dict['date'] = {'query': [to_date], 'range': 'ngt'}
column_value_dict['mirror_date'] = {'query': [from_date], 'range': 'nlt'} column_value_dict['mirror_date'] = {'query': [from_date], 'range': 'nlt'}
if resource_uid is not None : column_value_dict.set('resource_uid', resource_uid)
column_value_dict['resource_uid'] = resource_uid if column_value_dict.set('section_uid', section_uid):
if section_uid is not None :
column_value_dict['section_uid'] = section_uid
sql_kw['section_filtered'] = 1 sql_kw['section_filtered'] = 1
if node_uid is not None : column_value_dict.set('node_uid', node_uid)
column_value_dict['node_uid'] = node_uid column_value_dict.setUIDList('resource_uid', resource)
column_value_dict.setUIDList('aggregate_uid', item)
resource_uid_list = self._generatePropertyUidList(resource) column_value_dict.setUIDList('node_uid', node)
if resource_uid_list: column_value_dict.setUIDList('payment_uid', payment)
column_value_dict['resource_uid'] = resource_uid_list if column_value_dict.setUIDList('section_uid', section):
item_uid_list = self._generatePropertyUidList(item)
if item_uid_list:
column_value_dict['aggregate_uid'] = item_uid_list
node_uid_list = self._generatePropertyUidList(node)
if node_uid_list:
column_value_dict['node_uid'] = node_uid_list
payment_uid_list = self._generatePropertyUidList(payment)
if payment_uid_list:
column_value_dict['payment_uid'] = payment_uid_list
section_uid_list = self._generatePropertyUidList(section)
if section_uid_list:
column_value_dict['section_uid'] = section_uid_list
sql_kw['section_filtered'] = 1 sql_kw['section_filtered'] = 1
column_value_dict.setUIDList('mirror_section_uid', mirror_section)
mirror_section_uid_list = self._generatePropertyUidList(mirror_section) column_value_dict.setUIDList('variation_text', variation_text,
if mirror_section_uid_list: as_text=1)
column_value_dict['mirror_section_uid'] = mirror_section_uid_list column_value_dict.setUIDList('sub_variation_text', sub_variation_text,
as_text=1)
variation_text_list = self._generatePropertyUidList(variation_text, new_kw['column_value_dict'] = column_value_dict.copy()
as_text=1)
if variation_text_list: related_key_dict = DictMixIn()
column_value_dict['variation_text'] = variation_text_list
sub_variation_text_list = self._generatePropertyUidList(
sub_variation_text, as_text=1)
if sub_variation_text_list:
column_value_dict['sub_variation_text'] = sub_variation_text_list
new_kw['column_value_dict'] = column_value_dict
related_key_dict = {}
# category membership # category membership
resource_category_uid_list = self._generatePropertyUidList( related_key_dict.setUIDList('resource_category_uid', resource_category)
resource_category) related_key_dict.setUIDList('node_category_uid', node_category)
if resource_category_uid_list: related_key_dict.setUIDList('payment_category_uid', payment_category)
related_key_dict['resource_category_uid'] = resource_category_uid_list if related_key_dict.setUIDList('section_category_uid',
section_category):
node_category_uid_list = self._generatePropertyUidList(node_category)
if node_category_uid_list:
related_key_dict['node_category_uid'] = node_category_uid_list
payment_category_uid_list = self._generatePropertyUidList(payment_category)
if payment_category_uid_list:
related_key_dict['payment_category_uid'] = payment_category_uid_list
section_category_uid_list = self._generatePropertyUidList(section_category)
if section_category_uid_list:
related_key_dict['section_category_uid'] = section_category_uid_list
sql_kw['section_filtered'] = 1 sql_kw['section_filtered'] = 1
related_key_dict.setUIDList('mirror_section_category_uid',
mirror_section_category_uid_list = self._generatePropertyUidList( mirror_section_category)
mirror_section_category)
if mirror_section_category_uid_list:
related_key_dict['mirror_section_category_uid'] =\
mirror_section_category_uid_list
# category strict membership # category strict membership
resource_category_strict_membership_uid_list =\ related_key_dict.setUIDList('resource_category_strict_membership_uid',
self._generatePropertyUidList(resource_category_strict_membership) resource_category_strict_membership)
if resource_category_strict_membership_uid_list: related_key_dict.setUIDList('node_category_strict_membership_uid',
related_key_dict['resource_category_strict_membership_uid'] =\ node_category_strict_membership)
resource_category_strict_membership_uid_list related_key_dict.setUIDList('payment_category_strict_membership_uid',
payment_category_strict_membership)
node_category_strict_membership_uid_list =\ if related_key_dict.setUIDList('section_category_strict_membership_uid',
self._generatePropertyUidList(node_category_strict_membership) section_category_strict_membership):
if node_category_strict_membership_uid_list:
related_key_dict['node_category_strict_membership_uid'] =\
node_category_strict_membership_uid_list
payment_category_strict_membership_uid_list =\
self._generatePropertyUidList(payment_category_strict_membership)
if payment_category_strict_membership_uid_list:
related_key_dict['payment_category_strict_membership_uid'] =\
payment_category_strict_membership_uid_list
section_category_strict_membership_uid_list =\
self._generatePropertyUidList(section_category_strict_membership)
if section_category_strict_membership_uid_list:
related_key_dict['section_category_strict_membership_uid'] =\
section_category_strict_membership_uid_list
sql_kw['section_filtered'] = 1 sql_kw['section_filtered'] = 1
related_key_dict.setUIDList(
mirror_section_category_strict_membership_uid_list =\ 'mirror_section_category_strict_membership_uid',
self._generatePropertyUidList( mirror_section_category_strict_membership)
mirror_section_category_strict_membership)
if mirror_section_category_strict_membership_uid_list: new_kw['related_key_dict'] = related_key_dict.copy()
related_key_dict['mirror_section_category_strict_membership_uid'] =\
mirror_section_category_strict_membership_uid_list
new_kw['related_key_dict'] = related_key_dict
#variation_category_uid_list = self._generatePropertyUidList(variation_category) #variation_category_uid_list = self._generatePropertyUidList(variation_category)
#if len(variation_category_uid_list) : #if len(variation_category_uid_list) :
......
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