class RubyTeamSite::WFtask
Public Class Methods
Initialize the WFtask
class by getting the task from the workflow system by ID.
# File lib/ruby_teamsite/wftask.rb, line 12 def initialize(task_id) @task_id = task_id.strip @ts_bin = ts_bin @task = `#{@ts_bin}/iwgetwfobj #{task_id.strip}` set_task_info(@task) end
Public Instance Methods
Add a file to the task. Comment is required but sending a blank is acceptable.
# File lib/ruby_teamsite/wftask.rb, line 65 def add_file(f,comment) file_path = "/#{f}" addfile = `#{@ts_bin}/iwaddtaskfile #{@task_id} #{file_path} "#{comment}" 2>&1` refresh return addfile end
Return the areavpath of the task.
# File lib/ruby_teamsite/wftask.rb, line 40 def areavpath return @areavpath end
Callback to the workflow system to transition an external or cgi task.
# File lib/ruby_teamsite/wftask.rb, line 45 def callback(trans_num, comment=nil) # Only do a callback if the task is a cgitask or an externaltask. cb = "" if @task_type == 'cgitask' || @task_type == 'externaltask' cb = `#{@ts_bin}/iwcallback #{@task_id} #{trans_num} "#{comment}" 2>&1` end return cb end
Callback with failure to the workflow system to transition an external or cgi task to it’s failure successor.
# File lib/ruby_teamsite/wftask.rb, line 60 def failure(msg=nil) callback(1,msg) end
Return an array of files attached to this task.
# File lib/ruby_teamsite/wftask.rb, line 81 def files tsk = Nokogiri::XML(@task, nil, 'UTF-8') elmnt_files = tsk.css('files file') files = [] if elmnt_files.empty? == false elmnt_files.each {|f| files << f.attribute('path').to_s} end return files end
Return the id of the task.
# File lib/ruby_teamsite/wftask.rb, line 30 def id return @task_id end
Return the name of the task.
# File lib/ruby_teamsite/wftask.rb, line 20 def name return @task_name end
Remove a file to the task.
# File lib/ruby_teamsite/wftask.rb, line 73 def remove_file(f) file_path = "/#{f}" rmfile = `#{@ts_bin}/iwrmtaskfile #{@task_id} #{file_path} 2>&1` refresh return rmfile end
Callback with success to the workflow system to transition an external or cgi task to it’s success successor.
# File lib/ruby_teamsite/wftask.rb, line 55 def success(msg=nil) callback(0,msg) end
Return the type of the task.
# File lib/ruby_teamsite/wftask.rb, line 25 def type return @task_type end
Return the XML output of the task.
# File lib/ruby_teamsite/wftask.rb, line 35 def xml return @task end
Private Instance Methods
Refreshes the task variables to be current with what the workflow system has
# File lib/ruby_teamsite/wftask.rb, line 123 def refresh @task = `#{@ts_bin}/iwgetwfobj #{@task_id}` set_task_info(@task) end
Set the information for the task.
# File lib/ruby_teamsite/wftask.rb, line 103 def set_task_info(task) tsk = Nokogiri::XML(task, nil, 'UTF-8') # Task name task_name = tsk.root.attribute('name') tname = task_name.to_s @task_name = tname.strip # Task type task_type = tsk.root.node_name ttype = task_type.to_s @task_type = ttype.strip # Task areavpath areavpath = tsk.css('areavpath').attribute('v') avp = areavpath.to_s @areavpath = avp.strip end
Create the location to the bin directory for TeamSite
.
# File lib/ruby_teamsite/wftask.rb, line 94 def ts_bin iwhome = `iwgethome` ts_bin = iwhome + '/bin' ts_bin.gsub!(/\n/,'') ts_bin.strip! return ts_bin end