18 |
18 |
import sys
|
19 |
19 |
import json
|
20 |
20 |
|
|
21 |
from quixote import get_publisher
|
|
22 |
|
21 |
23 |
from qommon.ctl import Command, make_option
|
22 |
24 |
|
23 |
25 |
from wcs.formdef import FormDef
|
24 |
26 |
from wcs.workflows import Workflow
|
25 |
|
from wcs.wf.jump import JumpWorkflowStatusItem, jump_and_perform
|
|
27 |
from wcs.wf.jump import JumpWorkflowStatusItem, jump_and_perform as wcs_jump_and_perform
|
26 |
28 |
|
27 |
29 |
|
28 |
30 |
class CmdTriggerJumps(Command):
|
... | ... | |
137 |
139 |
return False
|
138 |
140 |
return True
|
139 |
141 |
|
|
142 |
def jump_and_perform(formdef, formdata, jump_to):
|
|
143 |
get_publisher().substitutions.reset()
|
|
144 |
get_publisher().substitutions.feed(get_publisher())
|
|
145 |
get_publisher().substitutions.feed(formdef)
|
|
146 |
get_publisher().substitutions.feed(formdata)
|
|
147 |
print 'formdata %s jumps to status %s' % (formdata, jump_to)
|
|
148 |
wcs_jump_and_perform(formdata, jump_to)
|
|
149 |
|
140 |
150 |
def select_and_jump_formdata(formdef, trigger, rows, status_ids=None):
|
141 |
151 |
for formdata, jump_to in get_formdata_accepting_trigger(formdef, trigger, status_ids):
|
142 |
152 |
if rows == '__all__':
|
143 |
|
print 'formdata %s jumps to status %s' % (formdata, jump_to)
|
144 |
|
jump_and_perform(formdata, jump_to)
|
|
153 |
jump_and_perform(formdef, formdata, jump_to)
|
145 |
154 |
else:
|
146 |
155 |
substitution_variables = formdata.get_substitution_variables()
|
147 |
156 |
for row in rows:
|
148 |
157 |
if match_row(substitution_variables, row):
|
149 |
|
print 'formdata %s jumps to status %s' % (formdata, jump_to)
|
150 |
|
jump_and_perform(formdata, jump_to, row.get('data'))
|
|
158 |
jump_and_perform(formdef, formdata, jump_to, row.get('data'))
|
151 |
159 |
break # next formdata
|
152 |
|
-
|