Class: WorkflowTransition
- Inherits:
-
WorkflowRule
- Object
- ActiveRecord::Base
- WorkflowRule
- WorkflowTransition
- Defined in:
- app/models/workflow_transition.rb
Overview
Redmine - project management software Copyright (C) 2006-2016 Jean-Philippe Lang
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Class Method Summary collapse
Methods inherited from WorkflowRule
Class Method Details
.replace_transitions(trackers, roles, transitions) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'app/models/workflow_transition.rb', line 21 def self.replace_transitions(trackers, roles, transitions) trackers = Array.wrap trackers roles = Array.wrap roles transaction do records = WorkflowTransition.where(:tracker_id => trackers.map(&:id), :role_id => roles.map(&:id)).to_a transitions.each do |old_status_id, transitions_by_new_status| transitions_by_new_status.each do |new_status_id, transition_by_rule| transition_by_rule.each do |rule, transition| trackers.each do |tracker| roles.each do |role| w = records.select {|r| r.old_status_id == old_status_id.to_i && r.new_status_id == new_status_id.to_i && r.tracker_id == tracker.id && r.role_id == role.id && !r.destroyed? } if rule == 'always' w = w.select {|r| !r. && !r.assignee} else w = w.select {|r| r. || r.assignee} end if w.size > 1 w[1..-1].each(&:destroy) end w = w.first if transition == "1" || transition == true unless w w = WorkflowTransition.new(:old_status_id => old_status_id, :new_status_id => new_status_id, :tracker_id => tracker.id, :role_id => role.id) records << w end w. = true if rule == "author" w.assignee = true if rule == "assignee" w.save if w.changed? elsif w if rule == 'always' w.destroy elsif rule == 'author' if w.assignee w. = false w.save if w.changed? else w.destroy end elsif rule == 'assignee' if w. w.assignee = false w.save if w.changed? else w.destroy end end end end end end end end end end |