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
=== modified file 'bin/workflow/wkf_service.py'
--- bin/workflow/wkf_service.py 2009-10-20 10:52:23 +0000
+++ bin/workflow/wkf_service.py 2013-03-06 09:35:34 +0000
@@ -33,6 +33,7 @@
33 self.exportMethod(self.trg_delete)33 self.exportMethod(self.trg_delete)
34 self.exportMethod(self.trg_create)34 self.exportMethod(self.trg_create)
35 self.exportMethod(self.trg_validate)35 self.exportMethod(self.trg_validate)
36 self.exportMethod(self.trg_change_subflow)
36 self.exportMethod(self.trg_redirect)37 self.exportMethod(self.trg_redirect)
37 self.exportMethod(self.trg_trigger)38 self.exportMethod(self.trg_trigger)
38 self.exportMethod(self.clear_cache)39 self.exportMethod(self.clear_cache)
@@ -80,6 +81,32 @@
80 res2 = instance.validate(cr, id, ident, signal)81 res2 = instance.validate(cr, id, ident, signal)
81 result = result or res282 result = result or res2
82 return result83 return result
84
85 # change the subflow of workitems attached to the 'main_ids' of 'main_type' object
86 # by the subflow of the new resource defined by the 'res_type' object and the 'res_ids' ids
87 def trg_change_subflow(self, uid, main_type, main_ids, res_type, res_ids, new_rid, cr):
88 # get ids of wkf instances for the old resource (res_id)
89#CHECKME: shouldn't we get only active instances?
90 if not res_ids or not main_ids:
91 return
92
93 cr.execute('select id, wkf_id from wkf_instance where res_id in %s and res_type=%s', (tuple(res_ids), res_type))
94 for old_inst_id, wkf_id in cr.fetchall():
95 # first active instance for new resource (new_rid), using same wkf
96 cr.execute(
97 'SELECT id '\
98 'FROM wkf_instance '\
99 'WHERE res_id=%s AND res_type=%s AND wkf_id=%s AND state=%s',
100 (new_rid, res_type, wkf_id, 'active'))
101 new_id = cr.fetchone()
102 if new_id:
103 cr.execute('select id from wkf_instance where res_type=%s and res_id in %s', (main_type, tuple(main_ids)))
104 for (inst_id,) in cr.fetchall():
105 # select all workitems which "wait" for the old instance
106 cr.execute('select id from wkf_workitem where subflow_id=%s and inst_id = %s', (old_inst_id, inst_id))
107 for (item_id,) in cr.fetchall():
108 # redirect all those workitems to the wkf instance of the new resource
109 cr.execute('update wkf_workitem set subflow_id=%s where id=%s', (new_id[0], item_id))
83110
84 # make all workitems which are waiting for a (subflow) workflow instance111 # make all workitems which are waiting for a (subflow) workflow instance
85 # for the old resource point to the (first active) workflow instance for112 # for the old resource point to the (first active) workflow instance for

Subscribers

People subscribed via source and target branches

to all changes: