Commit 730bbcb1 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Skip reindexing Applied Rules unnecessarily when expanding simulation.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37691 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 45d734e1
......@@ -275,3 +275,56 @@ class AppliedRule(XMLObject):
Return a list of movements.
"""
return self.objectValues(portal_type=Rule.movement_type)
security.declareProtected(Permissions.AccessContentsInformation,
'getIndexableChildSimulationMovementValueList')
def getIndexableChildSimulationMovementValueList(self):
return [x for x in self.getIndexableChildValueList()
if x.getPortalType() == 'Simulation Movement']
security.declarePublic('recursiveImmediateReindexSimulationMovement')
def recursiveImmediateReindexSimulationMovement(self, **kw):
"""
Applies immediateReindexObject recursively to Simulation Movements
"""
# Reindex direct children
root_indexable = int(getattr(self.getPortalObject(), 'isIndexable', 1))
for movement in self.objectValues():
if movement.isIndexable and root_indexable:
movement.immediateReindexObject(**kw)
# Go recursively
for movement in self.objectValues():
for applied_rule in movement.objectValues():
applied_rule.recursiveImmediateReindexSimulationMovement(**kw)
security.declarePublic('recursiveReindexObject')
def recursiveReindexSimulationMovement(self, activate_kw=None, **kw):
if self.isIndexable:
if activate_kw is None:
activate_kw = {}
reindex_kw = self.getDefaultReindexParameterDict()
if reindex_kw is not None:
reindex_activate_kw = reindex_kw.pop('activate_kw', None)
if reindex_activate_kw is not None:
reindex_activate_kw = reindex_activate_kw.copy()
if activate_kw is not None:
# activate_kw parameter takes precedence
reindex_activate_kw.update(activate_kw)
activate_kw = reindex_activate_kw
kw.update(reindex_kw)
group_id_list = []
if kw.get("group_id", "") not in ('', None):
group_id_list.append(kw.get("group_id", ""))
if kw.get("sql_catalog_id", "") not in ('', None):
group_id_list.append(kw.get("sql_catalog_id", ""))
group_id = ' '.join(group_id_list)
self.activate(group_method_id='portal_catalog/catalogObjectList',
expand_method_id='getIndexableChildSimulationMovementValueList',
alternate_method_id='alternateReindexObject',
group_id=group_id,
serialization_tag=self.getRootDocumentPath(),
**activate_kw).recursiveImmediateReindexSimulationMovement(**kw)
......@@ -801,7 +801,7 @@ class Delivery(XMLObject, ImmobilisationDelivery, CompositionMixin):
# indexing. The only exception is the simulation state.
# I think, if each simulation movement remembers the previous
# state, we can avoid unnecessary reindexing.
my_applied_rule.recursiveReindexObject(activate_kw=activate_kw)
my_applied_rule.recursiveReindexSimulationMovement(activate_kw=activate_kw)
else:
LOG("ERP5", PROBLEM,
"Could not expand applied rule %s for delivery %s" %\
......@@ -836,8 +836,8 @@ class Delivery(XMLObject, ImmobilisationDelivery, CompositionMixin):
if parent_value not in to_expand_list:
to_expand_list.append(parent_value)
for rule in to_expand_list:
rule.expand(activate_kw=activate_kw,**kw)
rule.recursiveReindexObject(activate_kw=activate_kw)
rule.expand(activate_kw=activate_kw, **kw)
rule.recursiveReindexSimulationMovement(activate_kw=activate_kw)
security.declareProtected( Permissions.AccessContentsInformation,
'getRootCausalityValueList')
......
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