Commit 653ff194 authored by Julien Muchembled's avatar Julien Muchembled

simulation: remove all activity dependencies for indexation of 'delivery' category

They were useless since 'delivery' is indexed in ZODB, and this also fixes
a bug causing local build to fail in the following conditions:
- root document moved to a state that triggers a builder,
  whereas there's no simulation tree yet
- the builder select method has a condition on the root simulation movement

An example is building of task reports, when the ERP is overloaded.

The reason was that in some cases, ERP5 tried to set 2 tags on the same
reindexing activity (built: in updateMovementCollection & expand: in
_updateSimulation), but there's actually no support for multi-valued tags
and for CMFActivity, default activate parameters (here expand:) have lower
precedence (see ActivateObject.activate). So another possible fix is to add
built: to _localBuild after_tag.

This commit also renames expand: into build:
parent e8c3c849
......@@ -55,7 +55,7 @@ try:\n
delivery.aq_explicit.getCausalityState\n
except AttributeError:\n
return\n
delivery.activate(tag=\'expand:\'+delivery.getPath()).Delivery_calculate()\n
delivery.activate(tag=\'build:\'+delivery.getPath()).Delivery_calculate()\n
</string> </value>
</item>
<item>
......
......@@ -363,8 +363,7 @@ class Delivery(XMLObject, ImmobilisationDelivery, SimulableMixin,
if calculate:
path = self.getPath()
self.activate(
# after_tag to built: could be removed
after_tag=('built:'+path, 'expand:'+path),
after_tag='build:'+path,
after_path_and_method_id=(path, '_localBuild'),
).updateCausalityState()
if kw:
......@@ -683,11 +682,7 @@ class Delivery(XMLObject, ImmobilisationDelivery, SimulableMixin,
after_tag = [after_tag]
else:
after_tag = list(after_tag) if after_tag else []
# Now that 'delivery' category relation are indexed in ZODB, this is the
# only method that depends on built: tag (via _updateSimulation), which
# is still required because builders only use catalog to find buildable
# movements and we don't want to miss any for local building.
after_tag.append('expand:' + self.getPath())
after_tag.append('build:' + self.getPath())
sm = getSecurityManager()
newSecurityManager(None, nobody)
try:
......
......@@ -141,7 +141,7 @@ class SimulatedDeliveryBuilder(BuilderMixin):
"""
delivery = delivery_movement.getExplanationValue()
simulation_movement.recursiveReindexObject(activate_kw=dict(
activate_kw or (), tag='built:'+delivery.getPath()))
activate_kw or (), tag='build:'+delivery.getPath()))
BuilderMixin._setDeliveryMovementProperties(
self, delivery_movement,
simulation_movement, property_dict,
......
......@@ -13,7 +13,7 @@
height="744.09448"
id="svg2"
version="1.1"
inkscape:version="0.48.3.1 r9886"
inkscape:version="0.48.5 r10040"
sodipodi:docname="SimulatedDeliveryBuilder.svg">
<title
id="title3064">Interactions and activity dependencies in simulation</title>
......@@ -81,7 +81,7 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.8748889"
inkscape:cx="526.18109"
inkscape:cx="533.47556"
inkscape:cy="370.90424"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
......@@ -153,55 +153,51 @@
<text
xml:space="preserve"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Monospace;-inkscape-font-specification:Monospace"
x="425.1969"
y="379.13065"
x="425.19684"
y="396.84717"
id="text3024-0"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3026-8"
x="425.1969"
y="379.13065">SM.recursiveImmediateReindexObject</tspan><tspan
x="425.19684"
y="396.84717">SM.(recursive)ImmediateReindexObject</tspan><tspan
sodipodi:role="line"
x="425.1969"
y="401.63065"
id="tspan5261"> tag = built:&lt;delivery_path&gt;</tspan></text>
x="425.19684"
y="419.34717"
id="tspan5261"> tag = build:&lt;delivery_path&gt;</tspan></text>
<rect
style="fill:none;stroke:#000000;stroke-width:1.77165353;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect5230-5"
width="407.48029"
width="425.19684"
height="70.866119"
x="407.48035"
y="343.69757" />
x="407.48029"
y="361.41409" />
<text
xml:space="preserve"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Monospace;-inkscape-font-specification:Monospace"
x="478.3465"
x="478.34647"
y="503.14636"
id="text3024-0-0"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3026-8-6"
x="478.3465"
x="478.34647"
y="503.14636">D._updateSimulation(create_root, index_related,</tspan><tspan
sodipodi:role="line"
x="478.3465"
x="478.34647"
y="525.64636"
id="tspan5292"> expand_root, expand_related)</tspan><tspan
sodipodi:role="line"
x="478.3465"
x="478.34647"
y="548.14636"
id="tspan5261-4"> tag = expand:&lt;delivery_path&gt;</tspan><tspan
sodipodi:role="line"
x="478.3465"
y="570.64636"
id="tspan5290"> after_tag = built:&lt;delivery_path&gt;</tspan></text>
id="tspan5290"> tag = build:&lt;delivery_path&gt;</tspan></text>
<rect
style="fill:none;stroke:#000000;stroke-width:1.77165353;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect5230-5-6"
width="549.21259"
height="124.01569"
height="106.29923"
x="460.62994"
y="467.71338"
y="467.71329"
inkscape:connector-avoid="true" />
<text
xml:space="preserve"
......@@ -217,7 +213,7 @@
sodipodi:role="line"
x="70.866165"
y="614.22913"
id="tspan5323"> tag = expand:&lt;delivery_path&gt;</tspan></text>
id="tspan5323"> tag = build:&lt;delivery_path&gt;</tspan></text>
<rect
style="fill:none;stroke:#000000;stroke-width:1.77165353;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect5230-5-5"
......@@ -234,8 +230,8 @@
inkscape:connector-curvature="3"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:0.99999994;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:7.99999992, 7.99999992;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)"
d="m 159.44883,396.84715 301.1811,70.86613"
style="fill:none;stroke:#000000;stroke-width:0.99999994;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:8.00000002, 8.00000002;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)"
d="m 159.44883,396.84716 301.18109,88.58269"
id="path5329"
inkscape:connector-type="polyline"
inkscape:connector-curvature="3"
......@@ -286,16 +282,12 @@
sodipodi:role="line"
x="53.14959"
y="915.41022"
id="tspan5323-4"> after_tag = expand:&lt;delivery_path&gt;</tspan><tspan
sodipodi:role="line"
x="53.14959"
y="937.91022"
id="tspan7567"> built:&lt;delivery_path&gt;</tspan></text>
id="tspan7567"> after_tag = build:&lt;delivery_path&gt;</tspan></text>
<rect
style="fill:none;stroke:#000000;stroke-width:1.77165353;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect5230-5-5-3"
width="425.19687"
height="106.29918"
height="88.582664"
x="35.433037"
y="857.47711"
inkscape:connector-avoid="true" />
......@@ -306,13 +298,6 @@
inkscape:connector-type="polyline"
inkscape:connector-curvature="3"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend-6)"
d="m 354.33071,857.47707 0,-230.31495"
id="path7939"
inkscape:connector-type="polyline"
inkscape:connector-curvature="3"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-start:url(#DotM);marker-end:url(#Arrow1Lend-6);display:inline"
d="m 425.19685,538.57944 35.43307,0"
......@@ -321,16 +306,8 @@
inkscape:connector-curvature="3"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend-6)"
d="m 637.79528,467.7133 0,-53.1496"
id="path8127"
inkscape:connector-type="polyline"
inkscape:connector-curvature="3"
inkscape:transform-center-x="17.716536"
inkscape:transform-center-y="-246.25662" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend-6)"
d="m 425.19685,857.47707 0,-442.91338"
style="fill:none;stroke:#000000;stroke-width:0.99999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend-6)"
d="m 425.19685,857.47707 0,-425.19684"
id="path4597"
inkscape:connector-type="polyline"
inkscape:connector-curvature="3"
......@@ -339,24 +316,24 @@
xml:space="preserve"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Monospace;-inkscape-font-specification:Monospace"
x="566.92914"
y="804.32758"
y="786.61102"
id="text3024-0-3-3"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
x="566.92914"
y="804.32758"
y="786.61102"
id="tspan5323-7">D._localBuild</tspan><tspan
sodipodi:role="line"
x="566.92914"
y="826.82758"
id="tspan3839"> after_tag = expand:&lt;delivery_path&gt;</tspan></text>
y="809.11102"
id="tspan3839"> after_tag = build:&lt;delivery_path&gt;</tspan></text>
<rect
style="fill:none;stroke:#000000;stroke-width:1.77165353;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect5230-5-5-5"
width="425.19684"
height="70.866112"
x="549.21259"
y="768.89447"
y="751.17792"
inkscape:connector-avoid="true" />
<text
xml:space="preserve"
......@@ -372,7 +349,7 @@
sodipodi:role="line"
x="513.77954"
y="702.81171"
id="tspan3839-6"> tag = expand:&lt;delivery_path&gt;</tspan></text>
id="tspan3839-6"> tag = build:&lt;delivery_path&gt;</tspan></text>
<rect
style="fill:none;stroke:#000000;stroke-width:1.77165353;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect5230-5-5-5-2"
......@@ -385,28 +362,28 @@
xml:space="preserve"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Monospace;-inkscape-font-specification:Monospace"
x="513.77942"
y="928.34332"
y="910.62677"
id="text3024-0-3-3-9"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
x="513.77942"
y="928.34332"
y="910.62677"
id="tspan5323-7-1">expand</tspan><tspan
sodipodi:role="line"
x="513.77942"
y="950.84332"
id="tspan3839-2"> tag = expand:&lt;delivery_path&gt;</tspan></text>
y="933.12677"
id="tspan3839-2"> tag = build:&lt;delivery_path&gt;</tspan></text>
<rect
style="fill:none;stroke:#000000;stroke-width:1.77165353;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect5230-5-5-5-7"
width="354.33075"
height="70.866112"
x="496.06296"
y="892.91022"
y="875.19366"
inkscape:connector-avoid="true" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend-6);display:inline"
d="m 921.25984,768.89441 0,-177.16536"
d="m 921.25984,751.17787 0,-177.16535"
id="path4453"
inkscape:connector-type="polyline"
inkscape:connector-curvature="3" />
......@@ -418,39 +395,39 @@
inkscape:connector-curvature="3"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:8, 8;stroke-dashoffset:0;marker-end:url(#Arrow1Lend-6)"
d="m 513.77953,892.91015 0,-177.16535"
style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:8.00000002, 8.00000002;stroke-dashoffset:0;marker-end:url(#Arrow1Lend-6)"
d="m 513.77953,875.19362 0,-159.44882"
id="path4825"
inkscape:connector-type="polyline"
inkscape:connector-curvature="3" />
<path
style="fill:none;stroke:#000000;stroke-width:0.99921262;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:7.99370116, 7.99370116;stroke-dashoffset:0;marker-end:url(#Arrow1Lend-6)"
d="M 496.06299,892.91016 372.04724,627.16215"
style="fill:none;stroke:#000000;stroke-width:0.99921268;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:7.99370115, 7.99370115;stroke-dashoffset:0;marker-end:url(#Arrow1Lend-6)"
d="M 496.06299,875.19362 372.04724,627.16215"
id="path3049"
inkscape:connector-type="polyline"
inkscape:connector-curvature="3" />
<path
style="fill:none;stroke:#000000;stroke-width:0.99921256;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker-end:url(#Arrow1Lend-6)"
d="m 460.62992,875.19362 245.03148,0 c 1.5,0 3,-1.5 3,-3 l 0,-32.43307"
d="m 460.62992,857.47708 245.03148,0 c 1.5,0 3,-1.5 3,-3 l 0,-32.43307"
id="path3048"
inkscape:connector-type="orthogonal"
inkscape:connector-curvature="3"
sodipodi:nodetypes="ccc" />
<path
style="fill:none;stroke:#000000;stroke-width:0.99999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend-6)"
d="m 460.62992,928.34322 35.43308,0"
d="m 460.62992,910.62668 35.43308,0"
id="path4198"
inkscape:connector-type="polyline"
inkscape:connector-curvature="3" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend-6)"
d="m 744.09449,839.76055 0,53.1496"
d="m 744.09449,822.04401 0,53.1496"
id="path4384"
inkscape:connector-type="polyline"
inkscape:connector-curvature="3" />
<path
style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:8, 8;stroke-dashoffset:0;marker-end:url(#Arrow1Lend-6)"
d="m 708.66142,591.72905 0,53.14961"
style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:8.00000004, 8.00000004;stroke-dashoffset:0;marker-end:url(#Arrow1Lend-6)"
d="m 708.66142,574.01253 0,70.86614"
id="path4570"
inkscape:connector-type="polyline"
inkscape:connector-curvature="3" />
......@@ -461,34 +438,28 @@
sodipodi:nodetypes="cc"
inkscape:connector-curvature="3" />
<path
style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:8, 8;stroke-dashoffset:0;marker-end:url(#Arrow1Lend-6)"
d="m 992.12598,591.72905 0,336.61417 -141.73228,0"
style="fill:none;stroke:#000000;stroke-width:0.99999994;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:8.00000011, 8.00000011;stroke-dashoffset:0;marker-end:url(#Arrow1Lend-6)"
d="m 992.12601,574.01253 0,336.61416 -141.73228,0"
id="path4214"
inkscape:connector-type="orthogonal"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#DotM)"
d="m 549.2126,804.32748 -194.88189,0"
style="fill:none;stroke:#000000;stroke-width:0.99921262;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker-end:url(#DotM)"
d="m 549.2126,804.32748 -124.01575,0"
id="path4402"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend-6);display:inline"
d="m 708.66142,768.89441 0,-53.14961"
id="path4590"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0" />
<text
xml:space="preserve"
style="font-size:14px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="519.49603"
y="871.1936"
y="853.47705"
id="text4778"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan4780"
x="519.49603"
y="871.1936">after_path_and_method_id</tspan></text>
y="853.47705">after_path_and_method_id</tspan></text>
<text
xml:space="preserve"
style="font-size:14px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
......@@ -506,44 +477,51 @@
<text
xml:space="preserve"
style="font-size:14px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="875.2049"
y="-69.862999"
x="868.70648"
y="-76.089027"
id="text4786-7"
sodipodi:linespacing="125%"
transform="matrix(0.43080996,0.90244267,-0.90244267,0.43080996,0,0)"><tspan
sodipodi:role="line"
id="tspan4788-5"
x="875.2049"
y="-69.862999">_set*</tspan></text>
x="868.70648"
y="-76.089027">_set*</tspan></text>
<path
style="fill:none;stroke:#000000;stroke-width:0.99921262;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:7.99370079, 7.99370079;stroke-dashoffset:0;marker-end:url(#Arrow1Lend-6)"
d="m 779.52756,892.91015 0,-35.43307 53.14961,0 0,35.43307"
d="m 779.52756,875.19361 0,-35.43307 53.14961,0 0,35.43307"
id="path3068"
inkscape:connector-curvature="0" />
<text
xml:space="preserve"
style="font-size:18px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="35.433071"
y="999.20935"
y="981.49286"
id="text3066"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3068"
x="35.433071"
y="999.20935">This describes activity messages related to Simulation Tool when a Delivery Builder is invoked.</tspan><tspan
y="981.49286">This describes activity messages related to Simulation Tool when a Delivery Builder is invoked.</tspan><tspan
sodipodi:role="line"
x="35.433071"
y="1021.7094"
y="1003.9929"
id="tspan3070">Continuous lines represent dependencies. Dashed lines show calls: if target is squared, then it's by activity.</tspan><tspan
sodipodi:role="line"
x="35.433071"
y="1044.2094"
y="1026.4928"
id="tspan3072" /></text>
<path
style="fill:none;stroke:#000000;stroke-width:0.99921260000000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:7.99370079000000011, 7.99370079000000011;marker-end:url(#Arrow1Lend-6);stroke-dashoffset:0;marker-start:url(#Arrow1Lstart)"
d="m 885.82677,768.89441 c 0,-159.44883 0,-159.44883 -354.33071,-159.44883 -194.88189,0 17.71654,-88.58268 -389.76378,-194.88188"
style="fill:none;stroke:#000000;stroke-width:0.99921256;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:7.99370031, 7.99370031;stroke-dashoffset:0;marker-start:url(#Arrow1Lstart);marker-end:url(#Arrow1Lend-6)"
d="m 885.82677,751.17788 c 0,-159.44883 0,-141.73229 -354.33071,-141.73229 -194.88189,0 17.71654,-88.58274 -389.76378,-194.88194"
id="path3074"
inkscape:connector-curvature="0"
sodipodi:nodetypes="csc" />
<path
style="fill:none;stroke:#000000;stroke-width:0.99999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-start:url(#DotM);marker-end:url(#Arrow1Lend-6);display:inline"
d="m 425.19685,591.72905 -17.71653,0"
id="path8125-9"
inkscape:connector-type="polyline"
inkscape:connector-curvature="3"
sodipodi:nodetypes="cc" />
</g>
</svg>
......@@ -169,28 +169,18 @@ class MovementCollectionUpdaterMixin:
movement.edit(**kw)
for property_id in kw:
movement.clearRecordedProperty(property_id)
movement_list = movement_diff.getNewMovementList()
if not movement_list:
return
if context.isRootAppliedRule():
reindex_kw = {'activate_kw': {
'tag': 'built:' + context.getCausalityValue().getPath()}}
else:
reindex_kw = None
def newMovement(kw={}):
return context.newContent(portal_type=self.movement_type,
reindex_kw=reindex_kw, **kw)
for movement in movement_list:
for movement in movement_diff.getNewMovementList():
d = movement.__dict__
assert movement.isTempObject()
if '_original' in d:
# slow but safe way (required for compensated movements)
newMovement(_getPropertyAndCategoryList(movement))
context.newContent(portal_type=self.movement_type,
**_getPropertyAndCategoryList(movement))
continue
# fast way (we had to make sure such optimization
# does not touch existing persistent data)
del movement.__dict__
movement = newMovement()
movement = context.newContent(portal_type=self.movement_type)
d.update(movement.__dict__)
categories = d.pop('categories')
movement.__dict__ = d
......
......@@ -505,10 +505,7 @@ class SimulableMixin(Base):
self.activate(
activity='SQLQueue',
group_method_id='portal_rules/updateSimulation',
tag='expand:' + path,
# Now that we don't rely on catalog anymore, this after_tag could
# moved to _localBuild, which currently only depends on 'expand:'.
after_tag='built:'+ path,
tag='build:' + path,
priority=3,
)._updateSimulation(**kw)
del tv[key]
......@@ -537,7 +534,7 @@ class SimulableMixin(Base):
if applied_rule is None:
applied_rule = self._createRootAppliedRule()
expand_root = applied_rule is not None
activate_kw = {'tag': 'expand:'+self.getPath()}
activate_kw = {'tag': 'build:'+self.getPath()}
if expand_root:
applied_rule.expand(activate_kw=activate_kw)
else:
......
......@@ -713,28 +713,18 @@ return context.generatePredicate(
self.assertEqual(line, sm.getDeliveryValue())
def test_14_indexRelated(self):
"""Check that simulation is indexed before being updated
"""Check that simulation can be updated even if a SM is not indexed yet
It is important that an update of a simulation tree is able to find all
related simulation movements, otherwise the following happens:
node 1 node 2
start first indexing of SM ...
change simulation state of PL
update simulation (no SM found)
commit result of indexing
-> SM has wrong simulation state
This actually tests the zodb-indexing of delivery category.
"""
root_applied_rule = self._slowReindex()
self.portal.portal_activities.distribute()
self.portal.cmf_activity_sql_connection.manage_test('delete from message')
self.pl.updateSimulation(index_related=1)
self.commit()
# this should distribute nothing as long as the indexing activity
# is not processed
self.portal.portal_activities.distribute()
r, = self.portal.cmf_activity_sql_connection.manage_test(
'select * from message_queue')
self.assertEqual(r.method_id, '_updateSimulation')
self.assertEqual(r.processing_node, -1)
self.tic()
sm, = root_applied_rule.objectValues()
line, = self.pl.getMovementList()
self.assertEqual([sm], [x.getObject() for x in self.portal.portal_catalog
.unrestrictedSearchResults(delivery_uid=line.getUid())])
def test_suite():
......
......@@ -757,6 +757,36 @@ class TestTask(TestTaskMixin, ERP5TypeTestCase):
finally:
portal_type.setTypePropertySheetList(original_property_sheet_list)
def test_08_localBuild(self):
sequence = Sequence(context=self)
sequence("""
Login
CreateOrganisation
CreateOrganisation
CreateResource
CreateProject
CreateRequirement
CreateSimpleTask
CreateCurrency
FillTaskWithData
SetTaskPriceCurrency
Tic
ConfirmTask
""")
self.tic(stop_condition=lambda message_list: all(
m.method_id != '_updateSimulation' for m in message_list))
rar, = sequence['task'].getCausalityRelatedValueList()
sm, = rar.objectValues()
q = self.portal.cmf_activity_sql_connection.manage_test
q('update message set processing_node=-4'
' where method_id="_localBuild" or path=%r' % sm.getPath())
self.commit()
self.portal.portal_activities.process_timer(None, None)
q('update message set processing_node=-1,'
' priority=method_id!="_localBuild"')
sequence("Tic SetTaskReport")
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestTask))
......
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