def render(self): wi = getWorkItem(None, self.request, 'sample', 'c') if wi is None: return u"" p_uid = ISearchableObject(wi).process_inst_uid() return u"""<a href="%s">%s</a>""" % ( self.request.resource_url(self.context, '@@startc', {'p_uid': p_uid}), u"Start C")
def render(self): # need the permission, the action context, the action context's state wi = getWorkItem(None, self.request, 'sample', 'd') if wi is None: return u"" p_uid = ISearchableObject(wi).process_inst_uid() return u"""<a href="%s">%s</a>""" % ( self.request.resource_url(self.context, '@@startd', {'p_uid': p_uid}), u"Start D")
def test_subprocess_elementary(self): spaction, sp, pd = self._process_valid_subprocess() spaction._init_contexts([ActionSP]) self.def_container.add_definition(pd) self.def_container.add_definition(sp) start_wi = pd.start_process('sp')['sp'] actions_sp = start_wi.actions self.assertEqual(len(actions_sp), 1) action_sp = actions_sp[0] self.assertIs(action_sp.workitem, start_wi) self.assertEqual(action_sp.node_id, 'sp') self.assertEqual(isinstance(action_sp, ActionSP), True) objecta= ObjectA() self.app['objecta'] = objecta action_sp.before_execution(objecta, self.request) action_sp.execute(objecta, self.request, None, **{}) wi_sa = getWorkItem(objecta, self.request, 'sub_process', 'sa') proc = action_sp.process workitems = proc.getWorkItems() self.assertEqual(len(workitems), 3) self.assertIn(wi_sa, workitems.values()) workitems_keys = workitems.keys() wi_sp = workitems['sample.sp'] self.assertIn('sample.sp', workitems_keys)# action is not valide with self.assertRaises(Exception): wi_sp.actions[0].validate(objecta, self.request) self.assertIn('sample.y', workitems_keys) self.assertIn('sub_process.sa', workitems_keys) wi_sa.consume().start_test_activity() workitems = proc.getWorkItems() self.assertEqual(len(workitems), 4) workitems_keys = workitems.keys() self.assertIn('sample.sp', workitems_keys)# action is not valide with self.assertRaises(Exception): wi_sp.actions[0].validate(objecta, self.request) self.assertIn('sample.y', workitems_keys) self.assertIn('sub_process.sb', workitems_keys) self.assertIn('sub_process.sc', workitems_keys) wi_sb = workitems['sub_process.sb'].consume() wi_sb.start_test_activity() workitems = proc.getWorkItems() self.assertEqual(len(workitems), 1) workitems_keys = workitems.keys() self.assertIn('sample.y', workitems_keys) wi_y = workitems['sample.y'].consume() wi_y.start_test_activity() wi_y.node.finish_behavior(wi_y) workitems = proc.getWorkItems() self.assertEqual(len(workitems), 0)
def render(self): wi = getWorkItem(None, self.request, 'sample', 'a') wi.start() return HTTPFound(self.request.resource_url(self.context,'@@index'))
def __call__(self, form): work_item = getWorkItem(None, form.request, 'process_id', 'activity_id') work_item.lock() data = form.extractData() work_item.start(*data)
def test_subprocess_multiinstance(self): spaction, sp, pd = self._process_valid_subprocess() spaction._init_contexts([ActionSPMI]) self.def_container.add_definition(pd) self.def_container.add_definition(sp) objecta= ObjectA() objecta.is_executed = False objectb= ObjectA() objectb.is_executed = False objectc= ObjectA() self.app['objecta'] = objecta self.app['objectb'] = objectb self.app['objectc'] = objectc self.request.objects = [objecta, objectb] start_wi = pd.start_process('sp')['sp'] actions_sp = start_wi.actions self.assertEqual(len(actions_sp), 3)# multi instance action and 2 actioninstance (objecta, objectb) actions = dict([(a.item.__name__, a) for a in actions_sp \ if hasattr(a, 'item') and \ a.item in self.request.objects]) self.assertEqual(len(actions), 2) action_sp = actions['objecta'] action_sp2 = actions['objectb'] #sub_process 1 ('objecta') action_sp.before_execution(objectc, self.request) action_sp.execute(objectc, self.request, None, **{}) wi_sa = getWorkItem(objectc, self.request, 'sub_process', 'sa') proc = action_sp.process item = action_sp.sub_process.execution_context.involved_entity('item') self.assertIs(item, objecta) items = proc.execution_context.find_involved_entity('item') self.assertEqual(len(items), 1) self.assertIn(objecta, items) workitems = proc.getWorkItems() self.assertEqual(len(workitems), 3) self.assertIn(wi_sa, workitems.values()) workitems_keys = workitems.keys() wi_sp = workitems['sample.sp'] self.assertIn('sample.sp', workitems_keys)# action is not valide with self.assertRaises(Exception): wi_sp.actions[0].validate(objectc, self.request) self.assertIn('sample.y', workitems_keys) self.assertIn('sub_process.sa', workitems_keys) wi_sa.consume().start_test_activity() workitems = proc.getWorkItems() self.assertEqual(len(workitems), 4) workitems_keys = workitems.keys() self.assertIn('sample.sp', workitems_keys)# action is not valide with self.assertRaises(Exception): wi_sp.actions[0].validate(objectc, self.request) self.assertIn('sample.y', workitems_keys) self.assertIn('sub_process.sb', workitems_keys) self.assertIn('sub_process.sc', workitems_keys) wi_sb = workitems['sub_process.sb'].consume() wi_sb.start_test_activity() workitems = proc.getWorkItems() self.assertEqual(len(workitems), 2) workitems_keys = workitems.keys() self.assertIn('sample.y', workitems_keys) self.assertIn('sample.sp', workitems_keys) wi_y = workitems['sample.y'].consume() wi_y.start_test_activity() wi_y.node.finish_behavior(wi_y) workitems = proc.getWorkItems() workitems_keys = workitems.keys() self.assertEqual(len(workitems), 1) self.assertIn('sample.sp', workitems_keys) #sub_process 2 ('objectb') action_sp2.before_execution(objectc, self.request) action_sp2.execute(objectc, self.request, None, **{}) wi_sa = getWorkItem(objectc, self.request, 'sub_process', 'sa') proc = action_sp2.process item = action_sp2.sub_process.execution_context.involved_entity('item') self.assertIs(item, objectb) items = proc.execution_context.find_involved_entity('item') self.assertEqual(len(items), 1) self.assertIn(objectb, items) workitems = proc.getWorkItems() self.assertEqual(len(workitems), 2) self.assertIn(wi_sa, workitems.values()) workitems_keys = workitems.keys() wi_sp = workitems['sample.sp'] self.assertIn('sample.sp', workitems_keys)# action is not valide with self.assertRaises(Exception): wi_sp.actions[0].validate(objectc, self.request) self.assertIn('sub_process.sa', workitems_keys) wi_sa.consume().start_test_activity() workitems = proc.getWorkItems() self.assertEqual(len(workitems), 3) workitems_keys = workitems.keys() self.assertIn('sample.sp', workitems_keys)# action is not valide with self.assertRaises(Exception): wi_sp.actions[0].validate(objectc, self.request) self.assertIn('sub_process.sb', workitems_keys) self.assertIn('sub_process.sc', workitems_keys) wi_sb = workitems['sub_process.sb'].consume() wi_sb.start_test_activity() workitems = proc.getWorkItems() self.assertEqual(len(workitems), 0)