class RubyTeamSite::WFtask

Public Class Methods

new(task_id) click to toggle source

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_file(f,comment) click to toggle source

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
areavpath() click to toggle source

Return the areavpath of the task.

# File lib/ruby_teamsite/wftask.rb, line 40
def areavpath
  return @areavpath
end
callback(trans_num, comment=nil) click to toggle source

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
failure(msg=nil) click to toggle source

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
files() click to toggle source

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
id() click to toggle source

Return the id of the task.

# File lib/ruby_teamsite/wftask.rb, line 30
def id
  return @task_id 
end
name() click to toggle source

Return the name of the task.

# File lib/ruby_teamsite/wftask.rb, line 20
def name
  return @task_name 
end
remove_file(f) click to toggle source

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
success(msg=nil) click to toggle source

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
type() click to toggle source

Return the type of the task.

# File lib/ruby_teamsite/wftask.rb, line 25
def type
  return @task_type
end
xml() click to toggle source

Return the XML output of the task.

# File lib/ruby_teamsite/wftask.rb, line 35
def xml
  return @task
end

Private Instance Methods

refresh() click to toggle source

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_task_info(task) click to toggle source

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
ts_bin() click to toggle source

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