Commit b8895c26 authored by Vincent Pelletier's avatar Vincent Pelletier

Move related key name generation from _generateKeywordDict to...

Move related key name generation from _generateKeywordDict to _generateSQLKeywordDictFromKeywordDict. This removes the need of the "table" parameter in the first method, so remove it aswell, and update caller.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15869 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3b546d9d
...@@ -360,7 +360,7 @@ class SimulationTool(BaseTool): ...@@ -360,7 +360,7 @@ class SimulationTool(BaseTool):
return {'input': omit_input, 'output': omit_output} return {'input': omit_input, 'output': omit_output}
def _generateSQLKeywordDict(self, table='stock', **kw): def _generateSQLKeywordDict(self, table='stock', **kw):
sql_kw, new_kw = self._generateKeywordDict(table=table, **kw) sql_kw, new_kw = self._generateKeywordDict(**kw)
return self._generateSQLKeywordDictFromKeywordDict(table=table, return self._generateSQLKeywordDictFromKeywordDict(table=table,
sql_kw=sql_kw, new_kw=new_kw) sql_kw=sql_kw, new_kw=new_kw)
...@@ -376,6 +376,10 @@ class SimulationTool(BaseTool): ...@@ -376,6 +376,10 @@ class SimulationTool(BaseTool):
column_value_dict = new_kw.pop('column_value_dict', {}) column_value_dict = new_kw.pop('column_value_dict', {})
for key, value in column_value_dict.iteritems(): for key, value in column_value_dict.iteritems():
new_kw['%s.%s' % (table, key)] = value new_kw['%s.%s' % (table, key)] = value
# Related keys
related_key_dict = new_kw.pop('related_key_dict', {})
for key, value in related_key_dict.iteritems():
new_kw['%s_%s' % (table, key)] = value
# Simulation states matched with input and output omission # Simulation states matched with input and output omission
def joinQueriesIfNeeded(query_a, query_b, operator): def joinQueriesIfNeeded(query_a, query_b, operator):
if None not in (query_a, query_b): if None not in (query_a, query_b):
...@@ -407,7 +411,7 @@ class SimulationTool(BaseTool): ...@@ -407,7 +411,7 @@ class SimulationTool(BaseTool):
sql_kw.update(self.portal_catalog.buildSQLQuery(**new_kw)) sql_kw.update(self.portal_catalog.buildSQLQuery(**new_kw))
return sql_kw return sql_kw
def _generateKeywordDict(self, table='stock', def _generateKeywordDict(self,
# dates # dates
from_date=None, to_date=None, at_date=None, from_date=None, to_date=None, at_date=None,
omit_mirror_date=1, omit_mirror_date=1,
...@@ -534,54 +538,56 @@ class SimulationTool(BaseTool): ...@@ -534,54 +538,56 @@ class SimulationTool(BaseTool):
new_kw['column_value_dict'] = column_value_dict new_kw['column_value_dict'] = column_value_dict
related_key_dict = {}
# category membership # category membership
resource_category_uid_list = self._generatePropertyUidList( resource_category_uid_list = self._generatePropertyUidList(
resource_category) resource_category)
if resource_category_uid_list: if resource_category_uid_list:
new_kw[table + '_resource_category_uid'] = resource_category_uid_list related_key_dict['resource_category_uid'] = resource_category_uid_list
node_category_uid_list = self._generatePropertyUidList(node_category) node_category_uid_list = self._generatePropertyUidList(node_category)
if node_category_uid_list: if node_category_uid_list:
new_kw[table + '_node_category_uid'] = node_category_uid_list related_key_dict['node_category_uid'] = node_category_uid_list
payment_category_uid_list = self._generatePropertyUidList(payment_category) payment_category_uid_list = self._generatePropertyUidList(payment_category)
if payment_category_uid_list: if payment_category_uid_list:
new_kw[table + '_payment_category_uid'] = payment_category_uid_list related_key_dict['payment_category_uid'] = payment_category_uid_list
section_category_uid_list = self._generatePropertyUidList(section_category) section_category_uid_list = self._generatePropertyUidList(section_category)
if section_category_uid_list: if section_category_uid_list:
new_kw[table + '_section_category_uid'] = section_category_uid_list related_key_dict['section_category_uid'] = section_category_uid_list
sql_kw['section_filtered'] = 1 sql_kw['section_filtered'] = 1
mirror_section_category_uid_list = self._generatePropertyUidList( mirror_section_category_uid_list = self._generatePropertyUidList(
mirror_section_category) mirror_section_category)
if mirror_section_category_uid_list: if mirror_section_category_uid_list:
new_kw[table + '_mirror_section_category_uid'] =\ related_key_dict['mirror_section_category_uid'] =\
mirror_section_category_uid_list mirror_section_category_uid_list
# category strict membership # category strict membership
resource_category_strict_membership_uid_list =\ resource_category_strict_membership_uid_list =\
self._generatePropertyUidList(resource_category_strict_membership) self._generatePropertyUidList(resource_category_strict_membership)
if resource_category_strict_membership_uid_list: if resource_category_strict_membership_uid_list:
new_kw[table + '_resource_category_strict_membership_uid'] =\ related_key_dict['resource_category_strict_membership_uid'] =\
resource_category_strict_membership_uid_list resource_category_strict_membership_uid_list
node_category_strict_membership_uid_list =\ node_category_strict_membership_uid_list =\
self._generatePropertyUidList(node_category_strict_membership) self._generatePropertyUidList(node_category_strict_membership)
if node_category_strict_membership_uid_list: if node_category_strict_membership_uid_list:
new_kw[table + '_node_category_strict_membership_uid'] =\ related_key_dict['node_category_strict_membership_uid'] =\
node_category_strict_membership_uid_list node_category_strict_membership_uid_list
payment_category_strict_membership_uid_list =\ payment_category_strict_membership_uid_list =\
self._generatePropertyUidList(payment_category_strict_membership) self._generatePropertyUidList(payment_category_strict_membership)
if payment_category_strict_membership_uid_list: if payment_category_strict_membership_uid_list:
new_kw[table + '_payment_category_strict_membership_uid'] =\ related_key_dict['payment_category_strict_membership_uid'] =\
payment_category_strict_membership_uid_list payment_category_strict_membership_uid_list
section_category_strict_membership_uid_list =\ section_category_strict_membership_uid_list =\
self._generatePropertyUidList(section_category_strict_membership) self._generatePropertyUidList(section_category_strict_membership)
if section_category_strict_membership_uid_list: if section_category_strict_membership_uid_list:
new_kw[table + '_section_category_strict_membership_uid'] =\ related_key_dict['section_category_strict_membership_uid'] =\
section_category_strict_membership_uid_list section_category_strict_membership_uid_list
sql_kw['section_filtered'] = 1 sql_kw['section_filtered'] = 1
...@@ -589,9 +595,11 @@ class SimulationTool(BaseTool): ...@@ -589,9 +595,11 @@ class SimulationTool(BaseTool):
self._generatePropertyUidList( self._generatePropertyUidList(
mirror_section_category_strict_membership) mirror_section_category_strict_membership)
if mirror_section_category_strict_membership_uid_list: if mirror_section_category_strict_membership_uid_list:
new_kw[table + '_mirror_section_category_strict_membership_uid'] =\ related_key_dict['mirror_section_category_strict_membership_uid'] =\
mirror_section_category_strict_membership_uid_list 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) :
# new_kw['variationCategory'] = variation_category_uid_list # new_kw['variationCategory'] = 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