Merge lp:~unifield-team/unifield-server/uf-1825 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 3439
Proposed branch: lp:~unifield-team/unifield-server/uf-1825
Merge into: lp:unifield-server
Diff against target: 44 lines (+27/-0)
1 file modified
bin/workflow/wkf_service.py (+27/-0)
To merge this branch: bzr merge lp:~unifield-team/unifield-server/uf-1825
Reviewer Review Type Date Requested Status
UniField Dev Team Pending
Review via email: mp+151901@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/workflow/wkf_service.py'
2--- bin/workflow/wkf_service.py 2009-10-20 10:52:23 +0000
3+++ bin/workflow/wkf_service.py 2013-03-06 09:35:34 +0000
4@@ -33,6 +33,7 @@
5 self.exportMethod(self.trg_delete)
6 self.exportMethod(self.trg_create)
7 self.exportMethod(self.trg_validate)
8+ self.exportMethod(self.trg_change_subflow)
9 self.exportMethod(self.trg_redirect)
10 self.exportMethod(self.trg_trigger)
11 self.exportMethod(self.clear_cache)
12@@ -80,6 +81,32 @@
13 res2 = instance.validate(cr, id, ident, signal)
14 result = result or res2
15 return result
16+
17+ # change the subflow of workitems attached to the 'main_ids' of 'main_type' object
18+ # by the subflow of the new resource defined by the 'res_type' object and the 'res_ids' ids
19+ def trg_change_subflow(self, uid, main_type, main_ids, res_type, res_ids, new_rid, cr):
20+ # get ids of wkf instances for the old resource (res_id)
21+#CHECKME: shouldn't we get only active instances?
22+ if not res_ids or not main_ids:
23+ return
24+
25+ cr.execute('select id, wkf_id from wkf_instance where res_id in %s and res_type=%s', (tuple(res_ids), res_type))
26+ for old_inst_id, wkf_id in cr.fetchall():
27+ # first active instance for new resource (new_rid), using same wkf
28+ cr.execute(
29+ 'SELECT id '\
30+ 'FROM wkf_instance '\
31+ 'WHERE res_id=%s AND res_type=%s AND wkf_id=%s AND state=%s',
32+ (new_rid, res_type, wkf_id, 'active'))
33+ new_id = cr.fetchone()
34+ if new_id:
35+ cr.execute('select id from wkf_instance where res_type=%s and res_id in %s', (main_type, tuple(main_ids)))
36+ for (inst_id,) in cr.fetchall():
37+ # select all workitems which "wait" for the old instance
38+ cr.execute('select id from wkf_workitem where subflow_id=%s and inst_id = %s', (old_inst_id, inst_id))
39+ for (item_id,) in cr.fetchall():
40+ # redirect all those workitems to the wkf instance of the new resource
41+ cr.execute('update wkf_workitem set subflow_id=%s where id=%s', (new_id[0], item_id))
42
43 # make all workitems which are waiting for a (subflow) workflow instance
44 # for the old resource point to the (first active) workflow instance for

Subscribers

People subscribed via source and target branches

to all changes: