myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [2524] branches/gianni-meandre: Merge branch 'mas


From: noreply
Subject: [myexperiment-hackers] [2524] branches/gianni-meandre: Merge branch 'master' of /home/gianni/ myexp-merge/myexperiment-meandre into local/gianni-meandre
Date: Thu, 30 Sep 2010 07:42:20 -0400 (EDT)

Revision
2524
Author
giannioneill
Date
2010-09-30 07:42:20 -0400 (Thu, 30 Sep 2010)

Log Message

Merge branch 'master' of /home/gianni/myexp-merge/myexperiment-meandre into local/gianni-meandre

Modified Paths

Added Paths

Diff

Added: branches/gianni-meandre/app/models/meandre_infrastructure.rb (0 => 2524)


--- branches/gianni-meandre/app/models/meandre_infrastructure.rb	                        (rev 0)
+++ branches/gianni-meandre/app/models/meandre_infrastructure.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,169 @@
+# myExperiment: app/models/meandre_infrastructure.rb
+#
+# Copyright (c) 2008 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+require 'acts_as_runner'
+require 'enactor/client'
+require 'document/data'
+require 'document/report'
+require 'curb'
+require 'zip/zip'
+require 'json'
+
+class MeandreInfrastructure < ActiveRecord::Base
+  
+  acts_as_runner
+  
+  validates_presence_of :username
+  validates_presence_of :crypted_password
+  validates_presence_of :url
+  
+  encrypts :password, :mode => :symmetric, :key => Conf.sym_encryption_key
+  
+ 
+  def update_details(details)
+    if details[:url]
+      #normalise urls
+      unless details[:url] =~ /\/$/
+        details[:url] += '/'
+      end
+      self.url = ""
+    end
+    self.username = details[:username] if details[:username]
+    self.password = details[:password] if details[:password]
+  end
+
+  def verify_job_completed?(last_update)
+    false
+  end
+
+  def service_valid?
+    c = Curl::Easy.new(self.url+'public/services/ping.txt');
+    c.perform
+    c.body_str.include?('pong')
+  end
+
+  def upload_flow(workflow)
+    pwdstring = 'admin:admin' #TODO: get this from DB
+    url = "" 
+    c = Curl::Easy.new("#{url}services/repository/add.json")
+    c.userpwd = "#{username}:#{crypted_password.decrypt}"
+    c.multipart_form_post = true
+    flow_file = Tempfile.new('flow')
+    flow_file.write(workflow.content_blob.data)
+    flow_file.close(false)
+
+    fields = []
+    files = []
+    zip = Zip::ZipFile.open(flow_file.path)
+    repo_content = ''
+    details = nil
+    urls = ''
+    details = nil
+    Zip::ZipFile.foreach(flow_file.path) do |file|
+      if file.name == 'repository/repository.ttl'
+        #for some reason Curb segfaults when we use a block
+        #so we use a Tempfile as a workaround
+        parser = MeandreParser.new(zip.read(file))
+        details = parser.find_details()
+        t = Tempfile.new('repo')
+        t.write(parser.get_ttl())
+        t.close(false)
+        fields << Curl::PostField.file('repository', t.path, t.path.hash.to_s)
+        files << t
+      elsif file.name.ends_with?('.jar')
+        t = Tempfile.new('component')
+        t.write(zip.read(file))
+        t.close(false)
+        fields << Curl::PostField.file('context', t.path, t.path.hash.to_s)
+        files << t 
+      end
+      fields << Curl::PostField.content('overwrite','true')
+    end
+    begin
+      c.http_post(*fields)
+    rescue
+      return nil
+    end
+    details.uri
+  end
+
+  def find_remote_flow(workflow)
+    parser = MeandreParser.new(workflow.content_blob.data)
+    details = parser.find_details
+    workflow_uri = details.uri
+    c = Curl::Easy.new("#{url}services/repository/list_flows.json")
+    c.userpwd = "#{username}:#{crypted_password.decrypt}"
+    c.perform
+    remote_workflows = JSON.parse(c.body_str)
+    remote_workflows.each do |remote_workflow|
+      return workflow_uri if remote_workflow['meandre_uri'] == workflow_uri
+    end
+    nil
+  end
+
+  def get_remote_runnable_uri(workflow)
+    unless workflow
+      return nil
+    end 
+    if workflow.processor_class == WorkflowProcessors::Meandre
+      return upload_flow(workflow)
+    elsif workflow.processor_class == WorkflowProcessors::MeandreTtl
+      return find_remote_flow(workflow)
+    end
+    nil
+  end
+
+  def submit_job(job) 
+    workflow = Workflow.find(:first, :conditions => {:id => job.runnable_id})
+    remote_uri = get_remote_runnable_uri(workflow)
+    c = Curl::Easy.new("#{url}services/auxiliar/run_tuned_flow.txt")
+    c.userpwd = "#{username}:#{crypted_password.decrypt}"
+    c.multipart_form_post=false
+    inputs = workflow.processor_class.new(workflow.content_blob.data).get_workflow_model_input_ports
+    fields = [];
+    inputs.each do |i|
+      fields << 'flow_uri='+remote_uri
+      fields << 'flow_component_instance='+i.component_uri
+      fields << 'property_name='+i.name
+      fields << 'property_value='+job.details.input_value(i)
+    end
+    body_str = ""
+    c.on_body do |data|
+      body_str += data
+      flow_id = /Unique flow ID: (.*)$/.match(body_str)
+      if flow_id
+        return flow_id[1]
+      end
+      data.length
+    end
+    c.http_post(*fields)
+  end
+
+  def get_job_status(remote_uri)
+    c = Curl::Easy.new("#{url}services/jobs/list_jobs_statuses.json")
+    c.userpwd = "#{username}:#{crypted_password.decrypt}"
+    c.perform
+    statuses = JSON.parse(c.body_str)
+    statuses.each do |status|
+      if status['job_id'] == remote_uri
+        if status['status'] == 'R'
+          return 'running'
+        else
+          return 'complete'
+        end
+      end
+    end
+    'unknown'
+  end
+
+  def get_job_report(remote_uri)
+    nil
+  end
+  
+  def job_type
+    MeandreJob
+  end
+  
+end

Added: branches/gianni-meandre/app/models/meandre_job.rb (0 => 2524)


--- branches/gianni-meandre/app/models/meandre_job.rb	                        (rev 0)
+++ branches/gianni-meandre/app/models/meandre_job.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,35 @@
+# myExperiment: app/models/meandre_job.rb
+#
+# Copyright (c) 2008 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+class MeandreJob < ActiveRecord::Base
+  
+  serialize :inputs_data
+
+  has_one :job, :foreign_key=>'details_id'
+  
+  def run_errors
+    @run_errors ||= [ ]
+  end
+  
+  def has_inputs?
+    return self.inputs_data
+  end
+  
+  def save_inputs(params)
+    self.inputs_data = params
+  end
+
+  #in meandre properties (inputs) have defaults, this method
+  #returns the user supplied input, or the default if the
+  #user supplied input is not set
+  def input_value(prop)
+    if self.inputs_data.nil? || self.inputs_data[prop.uri].nil?
+      return prop.value
+    end
+    self.inputs_data[prop.uri]
+  end
+protected
+  
+end

Added: branches/gianni-meandre/app/models/runner.rb (0 => 2524)


--- branches/gianni-meandre/app/models/runner.rb	                        (rev 0)
+++ branches/gianni-meandre/app/models/runner.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,69 @@
+# myExperiment: app/models/runner.rb
+#
+# Copyright (c) 2008 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+class Runner < ActiveRecord::Base
+  belongs_to :contributor, :polymorphic => true
+  validates_presence_of :contributor
+  before_save :save_details
+  has_many :jobs
+
+  @details=nil
+
+  @@runner_classes = [TavernaEnactor,MeandreInfrastructure]
+
+  def self.runner_classes
+    @@runner_classes
+  end
+
+  def self.get_class_by_name(name)
+    @@runner_classes.each do |c|
+      return c if c.name == name
+    end
+    logger.debug('No such runner class '+name.to_s)
+  end
+
+
+  def self.find_by_contributor(contributor_type, contributor_id)
+    Runner.find(:all, :conditions => ["contributor_type = ? AND contributor_id = ?", contributor_type, contributor_id])
+  end
+
+  def self.find_by_groups(user)
+    return nil unless user.is_a?(User)
+    
+    runners = []
+    user.all_networks.each do |n|
+      runners = runners + find_by_contributor('Network', n.id)
+    end
+    
+    return runners
+  end
+  
+  def self.for_user(user)
+    return [ ] if user.nil? or !user.is_a?(User)
+    
+    # Return the runners that are owned by the user, and are owned by groups that the user is a part of.
+    runners = Runner.find_by_contributor('User', user.id)
+    return runners + find_by_groups(user)
+  end
+
+  def save_details
+    self.details.save!
+    self.details_type = details.class.to_s
+    self.details_id = details.id
+  end
+
+  def details=(d)
+    @details=d
+  end
+
+  def details
+    if address@hidden
+      @runner_class = self.class.get_class_by_name(self.details_type)
+      @details = @runner_class.find(self.details_id)
+    end
+    @details
+  end
+
+end

Added: branches/gianni-meandre/app/models/taverna_job.rb (0 => 2524)


--- branches/gianni-meandre/app/models/taverna_job.rb	                        (rev 0)
+++ branches/gianni-meandre/app/models/taverna_job.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,144 @@
+# myExperiment: app/models/taverna_job.rb
+#
+# Copyright (c) 2008 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+class TavernaJob < ActiveRecord::Base
+  
+  serialize :inputs_data
+
+  has_one :job, :foreign_key=>'details_id'
+  
+  
+  def inputs_data=(data)
+    if job.allow_run?
+      self[:inputs_data] = data
+    end
+  end
+  
+  def current_input_type(input_name)
+    return 'none' if input_name.blank? or !self.inputs_data or self.inputs_data.empty?
+    
+    vals = self.inputs_data[input_name]
+    
+    return 'none' if vals.blank?
+    
+    if vals.is_a?(Array)
+      return 'list'
+    else
+      return 'single' 
+    end
+  end
+  
+  def has_inputs?
+    return self.inputs_data
+  end
+  
+  def report
+    begin
+      if self.job_uri
+        return runner.details.get_job_report(self.job_uri)
+      else
+        return nil
+      end
+    rescue Exception => ex
+      logger.error("ERROR occurred whilst fetching report for job #{self.job_uri}. Exception: #{ex}")
+      logger.error(ex.backtrace)
+      return nil
+    end
+  end
+  
+  # Note: this will return outputs in a format as defined by the Runner.
+  def outputs_data
+    begin
+      if completed?
+        return runner.details.get_job_outputs(self.job_uri)
+      else
+        return nil
+      end
+    rescue Exception => ex
+      logger.error("ERROR occurred whilst fetching outputs for job #{self.job_uri}. Exception: #{ex}")
+      logger.error(ex.backtrace)
+      return nil
+    end
+  end
+  
+  def outputs_as_xml
+    begin
+      if completed? and (xml_doc = runner.details.get_job_outputs_xml(self.job_uri))
+        return xml_doc.to_s
+      else
+        return 'Error: could not retrieve outputs XML document.'
+      end
+    rescue Exception => ex
+      logger.error("ERROR occurred whilst fetching outputs XML for job #{self.job_uri}. Exception: #{ex}")
+      logger.error(ex.backtrace)
+      return nil
+    end
+  end
+  
+  # Returns the size of the outputs in Bytes.
+  def outputs_size
+    begin
+      if completed?
+        return runner.details.get_job_output_size(self.job_uri)
+      else
+        return nil
+      end
+    rescue Exception => ex
+      logger.error("ERROR occurred whilst getting outputs size for job #{self.job_uri}. Exception: #{ex}")
+      logger.error(ex.backtrace)
+      return nil
+    end
+  end
+  
+  def get_output_type(output_data)
+    # Delegate out to the runner to handle it's own specific output format
+    runner.get_output_type(output_data)
+  end
+  
+  def get_output_mime_types(output_data)
+    # Delegate out to the runner to handle it's own specific output format
+    runner.get_output_mime_types(output_data)
+  end
+  
+  def update_outputs
+    unless self.outputs_uri
+      self.outputs_uri = runner.details.get_job_outputs_uri(self.job_uri)
+    end
+  end
+  
+  def save_inputs(params)
+    inputs_hash = { }
+    
+    input_ports = job.runnable.get_input_ports(@job.runnable_version)
+    
+    input_ports.each do |i|
+      case params["#{i.name}_input_type".to_sym]
+      when "none"
+        inputs_hash[i.name] = nil
+      when "single"
+        inputs_hash[i.name] = params["#{i.name}_single_input".to_sym]
+      when "list"
+        h = params["#{i.name}_list_input".to_sym]
+        if h and h.is_a?(Hash)
+          # Need to sort because we need to assume that order is important!
+          h = h.sort {|a,b| a[0]<=>b[0]}
+          vals = [ ]
+          h.each do |v|
+            vals << v[1]
+          end
+          inputs_hash[i.name] = vals
+        else
+          flash[:error] += "Failed to read list of inputs for port: #{i.name}. "
+        end
+      when "file"
+        inputs_hash[i.name] = params["#{i.name}_file_input".to_sym].read
+      end
+    end
+    
+    @job.details.inputs_data = inputs_hash
+  end
+protected
+  
+end

Added: branches/gianni-meandre/app/views/blobs/application_rdf+xml/_details.rhtml (0 => 2524)


--- branches/gianni-meandre/app/views/blobs/application_rdf+xml/_details.rhtml	                        (rev 0)
+++ branches/gianni-meandre/app/views/blobs/application_rdf+xml/_details.rhtml	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,28 @@
+<h3>
+Collection Details
+</h3>
+<ul>
+<% @handler.audio_files.each do |f| %>
+	<li><%=f%></li>
+<% end %>
+</ul>
+
+
+<h3>
+Make experiment from collection
+</h3>
+<% form_tag({:action="" do%>
+  <center>
+  Workflow: <%=select_tag('workflow', options_for_select([['Select a workflow', -1]] + Workflow.meandre_flows.map{|x| [x.title, x.id]}))%>
+  <img style="display: none;" src="" id="spinner" /><br/>
+  <%= observe_field :workflow, :url ="" { :controller=>'workflows', :action ="" :get_inputs},
+    :update => :input,
+	:before => "Element.show('spinner')",
+	:success => "Element.hide('spinner')",
+	:with => 'id'
+  %>
+  Input: <%=select_tag('input', options_for_select(['Select a workflow', -1]))%><br/>
+  Runner: <%=select_tag('runner', options_for_select(Runner.find(:all).map{|x| [x.title, x.id]}))%><br/>
+  <%=submit_tag 'Create Experiment'%>
+  </center>
+<% end%>

Added: branches/gianni-meandre/app/views/blobs/make_experiment.rhtml (0 => 2524)


--- branches/gianni-meandre/app/views/blobs/make_experiment.rhtml	                        (rev 0)
+++ branches/gianni-meandre/app/views/blobs/make_experiment.rhtml	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1 @@
+Hello, World!! <address@hidden>

Added: branches/gianni-meandre/app/views/blobs/text_html/_details.rhtml (0 => 2524)


--- branches/gianni-meandre/app/views/blobs/text_html/_details.rhtml	                        (rev 0)
+++ branches/gianni-meandre/app/views/blobs/text_html/_details.rhtml	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1 @@
+This is a HTML file!!!

Added: branches/gianni-meandre/app/views/jobs/meandre_job/_inputs.rhtml (0 => 2524)


--- branches/gianni-meandre/app/views/jobs/meandre_job/_inputs.rhtml	                        (rev 0)
+++ branches/gianni-meandre/app/views/jobs/meandre_job/_inputs.rhtml	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,26 @@
+<p class="note_text" style="text-align: center;">
+    Remember to click 'save' when you are done with setting/editing the input data.
+</p>
+
+<br/>
+
+<% form_tag save_inputs_job_path(@experiment, @job), :multipart => true do -%>
+  <center>
+  <table class="simple">
+  <% s_field_counter = 0 -%>
+  <tr><th>Name</th><th>Value</th></tr> 
+  <% inputs.each do |i| -%>
+    <tr><td><%= i.name %></td><td><%=text_field_tag i.uri, @job.details.input_value(i)%></td></tr>
+  <% end -%>
+  
+  <script>field_counter = <%= s_field_counter -%></script>
+  
+  <p class="note_text" style="text-align: center;">
+    Remember to click 'save' when you are done with setting/editing the input data.
+  </p>
+  <p>
+    <center><%= submit_tag "Save Input Data", :disable_with => "Saving..." -%></center>
+  </p>
+  </table>
+  </center>
+<% end %>

Added: branches/gianni-meandre/app/views/jobs/meandre_job/_status_info.rhtml (0 => 2524)


--- branches/gianni-meandre/app/views/jobs/meandre_job/_status_info.rhtml	                        (rev 0)
+++ branches/gianni-meandre/app/views/jobs/meandre_job/_status_info.rhtml	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,100 @@
+<% if @stop_timer -%>
+	<script>
+		stop_timer = true;
+		Element.remove('refresh_timer_text');
+	</script>
+<% end %>
+
+<% if job -%>
+
+	<% if job.allow_run? -%>
+		
+		<p style="text-align: center;"><b>This job has not been submitted yet.</b></p>
+		
+		<br/>
+		
+		<p class="note_text" style="text-align: center;">
+			Remember to save any input data first, before submitting this job.
+		</p>
+					
+		<p>
+			<% form_tag submit_job_job_path(experiment, job) do -%>
+				<center><%= submit_tag "Submit Job", :disable_with => "Submitting..." -%></center>
+			<% end -%>
+		</p>
+		
+	<% else -%>
+		
+		<% unless job.last_status.blank? -%>
+			<p style="text-align: center;">
+				Status:
+				<font style="color: #990000; font-weight: bold;"><%= h job.last_status -%></font>,
+				last checked at <%= datetime job.last_status_at -%>.
+			</p>			
+		<% else -%>
+			<p class="none_text" style="text-align: center;">
+				Status not available
+			</p>
+		<% end -%>
+		
+		<div class="box_simple" style="margin: 1em 0 2em 0; font-size: 93%;">
+			<p>
+				Job submitted at 
+				<b><%= datetime job.submitted_at -%></b>
+			</p>
+			<p>
+				Job started at 
+				<% unless job.started_at.blank? -%>
+					<b><%= datetime job.started_at -%></b>
+				<% else -%>
+					<span class="none_text">unknown</span>
+				<% end -%>
+			</p>
+			<p>
+				Job completed at 
+				<% unless job.completed_at.blank? -%>
+					<b><%= datetime job.completed_at -%></b>
+				<% else -%>
+					<span class="none_text">unknown</span>
+				<% end -%>
+			</p>
+			<% # TODO: download Job Manifest %>
+		</div>	
+		
+		<h4>Progress Report</h4>
+		
+		<% if (report = job.report) -%>
+			<table class="job_report">
+			  <tr>
+			    <th>Processor</th>
+			    <th>Status</th>
+			    <th>Detail</th>
+			    <th>Time</th>
+			  </tr>
+			
+				<% for processor in report.processors -%>
+				  <tr>
+				    <td><%= h processor.name -%></td>
+				    <td><%= h processor.status -%></td>
+						<td>
+							<% if processor.status == 'ITERATING' -%>
+								<%= h processor.number -%> of <%= h processor.total -%>
+							<% end %>
+						</td>
+				    <td><%= h processor.time -%></td>
+				  </tr>
+				<% end %>
+			</table>
+		<% else %>
+			<p class="none_text">Report unavailable at this time</p>
+		<% end %>
+		
+		<br/><br/>
+		
+		<ul class="sectionIcons">
+		  <li><%= icon('rerun', rerun_job_path(experiment, job), nil, { :confirm => 'Note: this will create a new Job with the settings and input data copied from this Job. Continue?', :method => :post }, 'Rerun Job') %></li>
+		</ul>
+		
+	<% end -%>
+
+<% end -%>

Modified: branches/gianni-meandre/app/views/jobs/new.rhtml (2523 => 2524)


--- branches/gianni-meandre/app/views/jobs/new.rhtml	2010-09-30 10:42:55 UTC (rev 2523)
+++ branches/gianni-meandre/app/views/jobs/new.rhtml	2010-09-30 11:42:20 UTC (rev 2524)
@@ -86,4 +86,4 @@
 		</div>
 	</center>
 
-<% end -%>
\ No newline at end of file
+<% end -%>

Added: branches/gianni-meandre/app/views/jobs/taverna_job/_inputs.rhtml (0 => 2524)


--- branches/gianni-meandre/app/views/jobs/taverna_job/_inputs.rhtml	                        (rev 0)
+++ branches/gianni-meandre/app/views/jobs/taverna_job/_inputs.rhtml	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,96 @@
+<p class="note_text" style="text-align: center;">
+    Remember to click 'save' when you are done with setting/editing the input data.
+  </p>
+
+<br/>
+
+<% form_tag save_inputs_job_path(@experiment, @job), :multipart => true do -%>
+  <% s_field_counter = 0 -%>
+  
+  <% inputs.each do |i| -%>
+    <% input_type = @job.details.current_input_type(i.name) -%>
+    
+    <h4>Input Port: <%= i.name %></h4>
+    
+    <p class="box_standout" style="font-size: 93%; margin-bottom: 0.6em; padding: 0.2em 0.5em;">
+      <b>Description: </b>
+      <% unless i.description.blank? -%>
+        <%= h i.description -%>
+      <% else -%>
+        <span class="none_text">none</span>
+      <% end -%>
+    </p>
+    
+    <div class="box_editing" style="padding-top: 0;">
+      <table style="font-size: 93%; margin-bottom: 0.5em; margin-left: 0;">
+        <tr>
+          <td>
+            <%= radio_button_tag "#{i.name}_input_type", 'none', (input_type == 'none'), : "_javascript_:update_inputs_states('#{escape_javascript i.name}', this.value);" -%>
+            No input
+          </td>
+          <td>
+            <%= radio_button_tag "#{i.name}_input_type", 'single', (input_type == 'single'), : "_javascript_:update_inputs_states('#{escape_javascript i.name}', this.value);" -%>
+            Single input
+          </td>
+          <td>
+            <%= radio_button_tag "#{i.name}_input_type", 'list', (input_type == 'list'), : "_javascript_:update_inputs_states('#{escape_javascript i.name}', this.value);" -%>
+            List of inputs
+          </td>
+          <td>
+            <%= radio_button_tag "#{i.name}_input_type", 'file', false, : "_javascript_:update_inputs_states('#{escape_javascript i.name}', this.value);" -%>
+            From file
+          </td>
+        </tr>
+      </table>
+      
+      <div id="<%= i.name -%>_single_input_box" class="box_editing_inner" style="display: none; width: 440px;">
+        <center>
+          <%= text_area_tag "#{i.name}_single_input", 
+                            input_type == 'single' ? h(@job.details.inputs_data[i.name]) : nil, 
+                            :size => "50x10" -%>
+        </center>
+      </div>
+      
+      <div id="<%= i.name -%>_list_input_box" class="box_editing_inner" style="display: none; width: 635px;">
+        <div id="<%= i.name -%>_list" style="margin-bottom: 0.5em;">
+          <%- if input_type == 'none' or @job.details.inputs_data[i.name].nil? %>
+            <p><%= text_field_tag "#{i.name}_list_input[0]", nil, :size => 90 -%></p>
+          <% else -%>
+            <% @job.details.inputs_data[i.name].each do |val| -%>
+              <% s_field_counter = s_field_counter + 1 -%>
+              <% p_id = i.name + '_p_' + s_field_counter.to_s -%>
+              <p id="<%= p_id %>">
+                <%= text_field_tag "#{i.name}_list_input[#{s_field_counter}]", val, :size => 90 -%>
+                &nbsp;&nbsp;<small>[<a href=""  p_id %>'); return false;">delete</a>]</small>
+              </p>
+            <% end -%>
+          <% end -%>
+        </div>
+        <p style="font-size: 93%; font-weight: bold;">
+          <a href=""  escape_javascript i.name -%>', '<%= escape_javascript i.name -%>_list'); return false;">Add another input</a>
+        </p>
+      </div>
+      
+      <div id="<%= i.name -%>_file_input_box" class="box_editing_inner" style="display: none; width: 500px;">
+        <p style="font-size: 85%; color: #333333; padding-top: 0; text-align: center;">
+          Note: this will create a single input for this port, with the contents of the file as the input data.
+        </p>
+        <center><%= file_field_tag "#{i.name}_file_input", :size => 60 -%></center>
+      </div>
+    </div>
+    
+    <script>update_inputs_states('<%= escape_javascript i.name -%>', '<%= input_type -%>')</script>
+    
+    <br/><br/>
+  <% end -%>
+  
+  <script>field_counter = <%= s_field_counter -%></script>
+  
+  <p class="note_text" style="text-align: center;">
+    Remember to click 'save' when you are done with setting/editing the input data.
+  </p>
+  
+  <p>
+    <center><%= submit_tag "Save Input Data", :disable_with => "Saving..." -%></center>
+  </p>
+<% end %>

Added: branches/gianni-meandre/app/views/jobs/taverna_job/_status_info.rhtml (0 => 2524)


--- branches/gianni-meandre/app/views/jobs/taverna_job/_status_info.rhtml	                        (rev 0)
+++ branches/gianni-meandre/app/views/jobs/taverna_job/_status_info.rhtml	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,117 @@
+<% if @stop_timer -%>
+	<script>
+		stop_timer = true;
+		Element.remove('refresh_timer_text');
+	</script>
+<% end %>
+
+<% if job -%>
+
+	<% if job.allow_run? -%>
+		
+		<p style="text-align: center;"><b>This job has not been submitted yet.</b></p>
+		
+		<br/>
+		
+		<p class="note_text" style="text-align: center;">
+			Remember to save any input data first, before submitting this job.
+		</p>
+					
+		<p>
+			<% form_tag submit_job_job_path(experiment, job) do -%>
+				<center><%= submit_tag "Submit Job", :disable_with => "Submitting..." -%></center>
+			<% end -%>
+		</p>
+		
+	<% else -%>
+		
+		<% unless job.last_status.blank? -%>
+			<p style="text-align: center;">
+				Status:
+				<font style="color: #990000; font-weight: bold;"><%= h job.last_status -%></font>,
+				last checked at <%= datetime job.last_status_at -%>.
+			</p>			
+		<% else -%>
+			<p class="none_text" style="text-align: center;">
+				Status not available
+			</p>
+		<% end -%>
+		
+		<div class="box_simple" style="margin: 1em 0 2em 0; font-size: 93%;">
+			<p>
+				Job submitted at 
+				<b><%= datetime job.submitted_at -%></b>
+			</p>
+			<p>
+				Job started at 
+				<% unless job.started_at.blank? -%>
+					<b><%= datetime job.started_at -%></b>
+				<% else -%>
+					<span class="none_text">unknown</span>
+				<% end -%>
+			</p>
+			<p>
+				Job completed at 
+				<% unless job.completed_at.blank? -%>
+					<b><%= datetime job.completed_at -%></b>
+				<% else -%>
+					<span class="none_text">unknown</span>
+				<% end -%>
+			</p>
+			<p>
+				Job inputs URI:
+				<% unless job.inputs_uri.blank? -%>
+					<%= link_to job.inputs_uri, job.inputs_uri, :target => '_blank' -%>
+				<% else -%>
+					<span class="none_text">not available</span>
+				<% end -%>
+			</p>
+			<p>
+				Job outputs URI:
+				<% unless job.outputs_uri.blank? -%>
+					<%= link_to job.outputs_uri, job.outputs_uri, :target => '_blank' -%>
+				<% else -%>
+					<span class="none_text">not available</span>
+				<% end -%>
+			</p>
+			
+			<% # TODO: download Job Manifest %>
+		</div>	
+		
+		<h4>Progress Report</h4>
+		
+		<% if (report = job.report) -%>
+			<table class="job_report">
+			  <tr>
+			    <th>Processor</th>
+			    <th>Status</th>
+			    <th>Detail</th>
+			    <th>Time</th>
+			  </tr>
+			
+				<% for processor in report.processors -%>
+				  <tr>
+				    <td><%= h processor.name -%></td>
+				    <td><%= h processor.status -%></td>
+						<td>
+							<% if processor.status == 'ITERATING' -%>
+								<%= h processor.number -%> of <%= h processor.total -%>
+							<% end %>
+						</td>
+				    <td><%= h processor.time -%></td>
+				  </tr>
+				<% end %>
+			</table>
+		<% else %>
+			<p class="none_text">Report unavailable at this time</p>
+		<% end %>
+		
+		<br/><br/>
+		
+		<ul class="sectionIcons">
+		  <li><%= icon('rerun', rerun_job_path(experiment, job), nil, { :confirm => 'Note: this will create a new Job with the settings and input data copied from this Job. Continue?', :method => :post }, 'Rerun Job') %></li>
+		</ul>
+		
+	<% end -%>
+
+<% end -%>

Modified: branches/gianni-meandre/app/views/runners/edit.rhtml (2523 => 2524)


--- branches/gianni-meandre/app/views/runners/edit.rhtml	2010-09-30 10:42:55 UTC (rev 2523)
+++ branches/gianni-meandre/app/views/runners/edit.rhtml	2010-09-30 11:42:20 UTC (rev 2524)
@@ -55,4 +55,4 @@
 			<center><%= submit_tag "Update", :disable_with => "Updating..." %></center>
 		<% end -%>
 	</div>
-</center>
\ No newline at end of file
+</center>

Copied: branches/gianni-meandre/app/views/runners/meandre_infrastructure/_new.rhtml (from rev 2523, branches/gianni-meandre/app/views/runners/new.rhtml) (0 => 2524)


--- branches/gianni-meandre/app/views/runners/meandre_infrastructure/_new.rhtml	                        (rev 0)
+++ branches/gianni-meandre/app/views/runners/meandre_infrastructure/_new.rhtml	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,52 @@
+<center>
+	<div class="box_form" style="width:  550px; margin: 1em 0; text-align: left;">
+		<p style="text-align: center; font-size: 85%;">Note: the runner will NOT be verified / validated on creation.</p>
+		
+			<p><b>Title</b></p>
+			<%= text_field_tag "runner_MeandreInfrastructure[title]", nil, :size =>  86 %>
+			
+			<p><b>Description</b></p>
+			<%= text_area_tag "runner_MeandreInfrastructure[description]", nil, :size => "65x6" %>
+			
+			<p><b>URL</b></p>
+			<%= text_field_tag "runner_MeandreInfrastructure[url]", nil, :size =>  86 %>
+			
+			<br/><br/>
+			
+			<fieldset>
+				<legend>Access Credentials</legend>
+				
+				<p><b>Username</b></p>
+				<%= text_field_tag "runner_MeandreInfrastructure[username]", nil, :size => 30 %>
+				
+				<p><b>Password</b> (will be encrypted)</p>
+				<%= text_field_tag "runner_MeandreInfrastructure[password]", nil, :size => 30 %>
+			</fieldset>
+			
+			<br/>
+			
+			<fieldset>
+				<legend>Ownership</legend>
+				
+				<p style="font-size: 93%;">
+					<b>By default, this Runner will be owned by you.</b>
+				</p>
+				<p style="font-size: 93%;">
+					However, you can assign it to one of your Groups, 
+					which will allow members of that Group to use it in their Jobs. 
+					Note that only the admin of the Group can then change the URL and Access Credentials. 
+				</p>
+				
+				<p>
+					<%= check_box_tag('assign_to_group', "1", false, :style => "vertical-align: middle;") -%> 
+					<span style="vertical-align: middle;">Assign to Group:</span>
+					<%= select_tag "assign_to_group_id", 
+												 options_from_collection_for_select(current_user.all_networks, "id", "title"), 
+												 :style => "vertical-align: middle;" -%>
+			 	</p> 
+			</fieldset>
+			
+			<br/><br/>
+			<center><%= submit_tag "Create", :disable_with => "Creating..." %></center>
+	</div>
+</center>

Modified: branches/gianni-meandre/app/views/runners/new.rhtml (2523 => 2524)


--- branches/gianni-meandre/app/views/runners/new.rhtml	2010-09-30 10:42:55 UTC (rev 2523)
+++ branches/gianni-meandre/app/views/runners/new.rhtml	2010-09-30 11:42:20 UTC (rev 2524)
@@ -55,4 +55,4 @@
 			<center><%= submit_tag "Create", :disable_with => "Creating..." %></center>
 		<% end -%>
 	</div>
-</center>
\ No newline at end of file
+</center>

Added: branches/gianni-meandre/app/views/runners/taverna_enactor/_details.rhtml (0 => 2524)


--- branches/gianni-meandre/app/views/runners/taverna_enactor/_details.rhtml	                        (rev 0)
+++ branches/gianni-meandre/app/views/runners/taverna_enactor/_details.rhtml	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,19 @@
+<h2>Status</h2>
+
+<ul class="sectionIcons" style="margin-top: 1.5em; text-align: left;">
+	<li style="margin-left: 0;">
+		<%= link_to_remote "#{image_tag 'refresh.gif'} Verify Status",
+									 :url =""
+									 :method => :get,
+									 :update => 'status_box',
+									 :success => "new Effect.Highlight('status_box', { duration: 1.5 });",
+									 :loading => "Element.show('refresh_indicator')",
+                   :complete => "Element.hide('refresh_indicator')" -%>
+		
+		<%= image_tag "spinner.gif", :id => "refresh_indicator", :style => "display: none; margin-left: 1em;" -%>
+	</li>
+</ul>
+
+<div id="status_box" style="margin-top: 1.5em; font-weight: bold; color: #990000;">
+	<% render :partial => "status", :locals => { :service_valid => @runner.service_valid? } -%>
+</div>

Added: branches/gianni-meandre/app/views/runners/taverna_enactor/_edit.rhtml (0 => 2524)


--- branches/gianni-meandre/app/views/runners/taverna_enactor/_edit.rhtml	                        (rev 0)
+++ branches/gianni-meandre/app/views/runners/taverna_enactor/_edit.rhtml	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,49 @@
+<% form_tag runner_path(@runner), :method => :put do -%>
+	<%= hidden_field_tag "runner_type", @runner.details_type %>
+	<p><b>Title</b></p>
+	<%= text_field_tag "runner_TavernaEnactor[title]", @runner.title, :size =>  86 %>
+	
+	<p><b>Description</b></p>
+	<%= text_area_tag "runner_TavernaEnactor[description]", @runner.description, :size => "65x6" %>
+	
+	<p><b>URL</b></p>
+	<%= text_field_tag "runner_TavernaEnactor[url]", @runner.details.url, :size =>  86 %>
+	
+	<br/><br/>
+	
+	<fieldset>
+		<legend>Access Credentials</legend>
+		
+		<p><b>Username</b></p>
+		<%= text_field_tag "runner_TavernaEnactor[username]", @runner.details.username, :size => 30 %>
+		
+		<p><b>Password</b> (will be encrypted)</p>
+		<%= text_field_tag "runner_TavernaEnactor[password]", @runner.details.crypted_password.decrypt, :size => 30 %>
+	</fieldset>
+	
+	<br/>
+	
+	<fieldset>
+		<legend>Ownership</legend>
+		
+		<p style="font-size: 93%;">
+			<b>By default, this Runner will be owned by you.</b>
+		</p>
+		<p style="font-size: 93%;">
+			However, you can assign it to one of your Groups, 
+			which will allow members of that Group to use it in their Jobs. 
+			Note that only the admin of the Group can then change the URL and Access Credentials. 
+		</p>
+		
+		<p>
+			<%= check_box_tag 'assign_to_group', "1", (@runner.contributor_type == 'Network'), :style => "vertical-align: middle;" -%> 
+			<span style="vertical-align: middle;">Assign to Group:</span>
+			<%= select_tag "assign_to_group_id", 
+										 options_from_collection_for_select(current_user.all_networks, "id", "title", (@runner.contributor_type == 'Network' ? @runner.contributor_id : nil)), 
+										 :style => "vertical-align: middle;" -%>
+		</p> 
+	</fieldset>
+	
+	<br/><br/>
+	<center><%= submit_tag "Update", :disable_with => "Updating..." %></center>
+<% end -%>

Copied: branches/gianni-meandre/app/views/runners/taverna_enactor/_new.rhtml (from rev 2523, branches/gianni-meandre/app/views/runners/new.rhtml) (0 => 2524)


--- branches/gianni-meandre/app/views/runners/taverna_enactor/_new.rhtml	                        (rev 0)
+++ branches/gianni-meandre/app/views/runners/taverna_enactor/_new.rhtml	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,52 @@
+<center>
+	<div class="box_form" style="width:  550px; margin: 1em 0; text-align: left;">
+		<p style="text-align: center; font-size: 85%;">Note: the runner will NOT be verified / validated on creation.</p>
+		
+			<p><b>Title</b></p>
+			<%= text_field_tag "runner_TavernaEnactor[title]", nil, :size =>  86 %>
+			
+			<p><b>Description</b></p>
+			<%= text_area_tag "runner_TavernaEnactor[description]", nil, :size => "65x6" %>
+			
+			<p><b>URL</b></p>
+			<%= text_field_tag "runner_TavernaEnactor[url]", nil, :size =>  86 %>
+			
+			<br/><br/>
+			
+			<fieldset>
+				<legend>Access Credentials</legend>
+				
+				<p><b>Username</b></p>
+				<%= text_field_tag "runner_TavernaEnactor[username]", nil, :size => 30 %>
+				
+				<p><b>Password</b> (will be encrypted)</p>
+				<%= text_field_tag "runner_TavernaEnactor[password]", nil, :size => 30 %>
+			</fieldset>
+			
+			<br/>
+			
+			<fieldset>
+				<legend>Ownership</legend>
+				
+				<p style="font-size: 93%;">
+					<b>By default, this Runner will be owned by you.</b>
+				</p>
+				<p style="font-size: 93%;">
+					However, you can assign it to one of your Groups, 
+					which will allow members of that Group to use it in their Jobs. 
+					Note that only the admin of the Group can then change the URL and Access Credentials. 
+				</p>
+				
+				<p>
+					<%= check_box_tag('assign_to_group', "1", false, :style => "vertical-align: middle;") -%> 
+					<span style="vertical-align: middle;">Assign to Group:</span>
+					<%= select_tag "assign_to_group_id", 
+												 options_from_collection_for_select(current_user.all_networks, "id", "title"), 
+												 :style => "vertical-align: middle;" -%>
+			 	</p> 
+			</fieldset>
+			
+			<br/><br/>
+			<center><%= submit_tag "Create", :disable_with => "Creating..." %></center>
+	</div>
+</center>

Added: branches/gianni-meandre/app/views/workflows/_get_available.rhtml (0 => 2524)


--- branches/gianni-meandre/app/views/workflows/_get_available.rhtml	                        (rev 0)
+++ branches/gianni-meandre/app/views/workflows/_get_available.rhtml	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1 @@
+<%=options_for_select(results.map{|x| [x['meandre_uri_name'], x['meandre_uri']]})%>

Added: branches/gianni-meandre/app/views/workflows/import.rhtml (0 => 2524)


--- branches/gianni-meandre/app/views/workflows/import.rhtml	                        (rev 0)
+++ branches/gianni-meandre/app/views/workflows/import.rhtml	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,82 @@
+<% t "New" -%>
+
+<%= _javascript__include_tag :fckeditor %>
+<%= _javascript__include_tag "osp.js" %>
+
+<h1>Import  Workflow</h1>
+
+<center>
+	<%= error_messages_for :workflow %>
+</center>
+
+<% form_tag({:action ="" :create}, :multipart => true) do %>
+
+  <!-- Workflow File -->
+	
+	<p class="step_text">1. Meandre Server</p>
+	<center>
+    <%=select_tag('runner', options_for_select(@runners.map{|x| [x.title, x.id]}))%>
+    </select>
+	</center>
+
+  <p class="step_text">2. Select Workflow</p>
+
+	<center>
+	<%=select_tag('workflow_uri', render(:partial => "get_available", :locals=>{:results=>@workflows}))%> 
+	<img style="display: none;" src="" id="spinner" />
+	</center>
+
+  <%= observe_field :runner, :url ="" { :action ="" :get_available },
+    :update => :suggest,
+	:before => "Element.show('spinner')",
+	:success => "Element.hide('spinner')",
+    :with => 'runner',
+    :update => 'workflow_uri'
+  %>
+
+  
+  <br />
+	
+	<!-- Main metadata -->
+	
+	<p class="step_text">3. Main metadata</p>
+  
+	<%= render :partial => "main_metadata_form", :locals => { :new_version => false } -%>
+	
+	<br/>
+	
+	<!-- Other metadata and settings -->
+	
+	<p class="step_text" style="text-align: center;">4. Other metadata and settings</p>
+	
+	<!-- Tags -->
+  <%= render :partial => "tags/tags_form", :locals => { :edit => false, :taggable => @workflow } -%>
+                
+  <!-- Credit and Attribution -->
+  <%= render :partial => "contributions/credit_attribution_form", :locals => { :edit => false, :contributable => @workflow } -%>
+                
+  <!-- Sharing -->              
+  <%= render :partial => "contributions/sharing_form", :locals => { :edit => false, :contributable => @workflow, :update_perms => true } -%>
+                
+  <!-- License/Rights -->
+  <%= render :partial => "contributions/license_form", :locals => { :object => :workflow, :contributable => @workflow, :edit => false } -%>
+  
+	
+	<!-- Terms and conditions -->
+	
+	<p class="step_text">5. Terms and conditions</p>
+	
+  <%= render :partial => 'contributions/terms_and_conditions' %>
+	
+	<br/>
+
+	<!-- Upload and Continue -->
+	
+	<p class="step_text">6. Upload and Continue</p>
+
+  <p style="text-align: center;">
+    <%= submit_tag "Upload and Continue", :disable_with => "Uploading..." %>
+  </p>
+  
+<% end %>
+

Added: branches/gianni-meandre/app/views/workflows/meandre/_inputs.rhtml (0 => 2524)


--- branches/gianni-meandre/app/views/workflows/meandre/_inputs.rhtml	                        (rev 0)
+++ branches/gianni-meandre/app/views/workflows/meandre/_inputs.rhtml	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1 @@
+<%=options_for_select inputs.map{|i| [i.name, i.uri]}%>

Added: branches/gianni-meandre/app/views/workflows/meandre/_internals.rhtml (0 => 2524)


--- branches/gianni-meandre/app/views/workflows/meandre/_internals.rhtml	                        (rev 0)
+++ branches/gianni-meandre/app/views/workflows/meandre/_internals.rhtml	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,50 @@
+<% cache(:controller => 'workflows_cache', :action ="" 'internals', :id => workflow.id, :version => version) do -%>
+
+	<% if (model = workflow.get_workflow_model_object(version)) -%>
+    
+	<!-- nodes -->
+    <% nodes = model.find_nodes -%>
+    <div class="fold">
+      <div class="foldTitle">
+        <%= info_icon_with_tooltip "This is information extracted about components from the workflow" %>
+        Components (<%= nodes.nil? ? 0 : nodes.length -%>)
+      </div>
+      <div class="foldContent" style="display: none;">
+        <% unless nodes.blank? -%>
+          <table class="simple">
+            <% nodes.each do |a| -%>
+              <tr>
+                <td><%=h a.name -%></td>
+              </tr>
+            <% end %>
+          </table>
+        <% else %>
+          <p class="none_text">None</p>
+        <% end %>
+      </div>
+    </div>
+    <% end %>
+   
+	<!-- Inputs -->
+    <% inputs = model.get_workflow_inputs -%>
+    <div class="fold">
+      <div class="foldTitle">
+        <%= info_icon_with_tooltip "This is information extracted about inputs from the workflow" %>
+        Properties (<%= nodes.nil? ? 0 : inputs.length -%>)
+      </div>
+      <div class="foldContent" style="display: none;">
+        <% unless inputs.blank? -%>
+          <table class="simple">
+            <% inputs.each do |a| -%>
+              <tr>
+                <td><%=h a.name -%></td><td><%=h a.value%></td>
+              </tr>
+            <% end %>
+          </table>
+        <% else %>
+          <p class="none_text">None</p>
+        <% end %>
+      </div>
+    </div>
+  
+<% end %>

Added: branches/gianni-meandre/app/views/workflows/meandre/_run_options.rhtml (0 => 2524)


--- branches/gianni-meandre/app/views/workflows/meandre/_run_options.rhtml	                        (rev 0)
+++ branches/gianni-meandre/app/views/workflows/meandre/_run_options.rhtml	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,5 @@
+<div style="margin: 0 0.5em;">
+	<h4>
+		Run this Workflow in Meandre...
+	</h4>
+</div>

Added: branches/gianni-meandre/app/views/workflows/meandre_ttl/_internals.rhtml (0 => 2524)


--- branches/gianni-meandre/app/views/workflows/meandre_ttl/_internals.rhtml	                        (rev 0)
+++ branches/gianni-meandre/app/views/workflows/meandre_ttl/_internals.rhtml	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1 @@
+link ../meandre/_internals.rhtml
\ No newline at end of file
Property changes on: branches/gianni-meandre/app/views/workflows/meandre_ttl/_internals.rhtml
___________________________________________________________________

Added: svn:special

Added: branches/gianni-meandre/app/views/workflows/meandre_ttl/_run_options.rhtml (0 => 2524)


--- branches/gianni-meandre/app/views/workflows/meandre_ttl/_run_options.rhtml	                        (rev 0)
+++ branches/gianni-meandre/app/views/workflows/meandre_ttl/_run_options.rhtml	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,5 @@
+<div style="margin: 0 0.5em;">
+	<h4>
+		Run this Workflow in Meandre...
+	</h4>
+</div>

Added: branches/gianni-meandre/db/migrate/089_create_meandre_infrastructures.rb (0 => 2524)


--- branches/gianni-meandre/db/migrate/089_create_meandre_infrastructures.rb	                        (rev 0)
+++ branches/gianni-meandre/db/migrate/089_create_meandre_infrastructures.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,13 @@
+class CreateMeandreInfrastructures < ActiveRecord::Migration
+  def self.up
+    create_table :meandre_infrastructures do |t|
+      t.column :url, :string
+      t.column :username, :string
+      t.column :crypted_password, :string
+     end
+  end
+
+  def self.down
+    drop_table :meandre_infrastructures
+  end
+end

Added: branches/gianni-meandre/db/migrate/090_create_runners.rb (0 => 2524)


--- branches/gianni-meandre/db/migrate/090_create_runners.rb	                        (rev 0)
+++ branches/gianni-meandre/db/migrate/090_create_runners.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,21 @@
+class CreateRunners < ActiveRecord::Migration
+  def self.up
+    create_table :runners do |t|
+      t.column :title, :string
+      t.column :description, :text
+      t.column :contributor_id, :integer
+      t.column :contributor_type, :string
+      
+      t.column :created_at, :datetime
+      t.column :updated_at, :datetime
+
+      t.column :details_type, :string
+      t.column :details_id, :integer
+
+    end
+  end
+
+  def self.down
+    drop_table :runners
+  end
+end

Added: branches/gianni-meandre/db/migrate/091_create_taverna_jobs.rb (0 => 2524)


--- branches/gianni-meandre/db/migrate/091_create_taverna_jobs.rb	                        (rev 0)
+++ branches/gianni-meandre/db/migrate/091_create_taverna_jobs.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,13 @@
+class CreateTavernaJobs < ActiveRecord::Migration
+  def self.up
+    create_table :taverna_jobs do |t|
+      t.column :inputs_uri, :string
+      t.column :inputs_data, :binary, :limit => 104857600 # in bytes; = 100MB
+      t.column :outputs_uri, :string
+    end
+  end
+
+  def self.down
+    drop_table :taverna_jobs
+  end
+end

Added: branches/gianni-meandre/db/migrate/092_create_meandre_jobs.rb (0 => 2524)


--- branches/gianni-meandre/db/migrate/092_create_meandre_jobs.rb	                        (rev 0)
+++ branches/gianni-meandre/db/migrate/092_create_meandre_jobs.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,11 @@
+class CreateMeandreJobs < ActiveRecord::Migration
+  def self.up
+    create_table :meandre_jobs do |t|
+      t.column :inputs_data, :binary, :limit => 104857600 # in bytes; = 100MB
+    end
+  end
+
+  def self.down
+    drop_table :meandre_jobs
+  end
+end

Added: branches/gianni-meandre/db/migrate/093_create_delayed_jobs.rb (0 => 2524)


--- branches/gianni-meandre/db/migrate/093_create_delayed_jobs.rb	                        (rev 0)
+++ branches/gianni-meandre/db/migrate/093_create_delayed_jobs.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,20 @@
+class CreateDelayedJobs < ActiveRecord::Migration
+  def self.up
+    create_table :delayed_jobs, :force => true do |t|
+      t.column :priority, :integer, :default => 0      # Allows some jobs to jump to the front of the queue
+      t.column :attempts, :integer, :default => 0      # Provides for retries, but still fail eventually.
+      t.column :handler, :text                      # YAML-encoded string of the object that will do work
+      t.column :last_error, :string                   # reason for last failure (See Note below)
+      t.column :run_at, :datetime                       # When to run. Could be Time.now for immediately, or sometime in the future.
+      t.column :locked_at, :datetime                    # Set when a client is working on this object
+      t.column :failed_at, :datetime                    # Set when all retries have failed (actually, by default, the record is deleted instead)
+      t.column :locked_by, :string                    # Who is working on this object (if locked)
+    end
+
+    add_index :delayed_jobs, :locked_by
+  end
+
+  def self.down
+    drop_table :delayed_jobs
+  end
+end

Modified: branches/gianni-meandre/lib/acts_as_runner.rb (2523 => 2524)


--- branches/gianni-meandre/lib/acts_as_runner.rb	2010-09-30 10:42:55 UTC (rev 2523)
+++ branches/gianni-meandre/lib/acts_as_runner.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -37,4 +37,4 @@
 
 ActiveRecord::Base.class_eval do
   include Jits::Acts::Runner
-end
\ No newline at end of file
+end

Added: branches/gianni-meandre/lib/file_processors/file_collection.rb (0 => 2524)


--- branches/gianni-meandre/lib/file_processors/file_collection.rb	                        (rev 0)
+++ branches/gianni-meandre/lib/file_processors/file_collection.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,77 @@
+# myExperiment: lib/file_processors/application_rdf_xml.rb
+#
+# Copyright (c) 2008 University of Manchester and the University of Southampton.
+# See license.txt for details.
+require 'rdf/redland'
+
+module FileProcessors
+  class FileCollection < Interface
+    
+    #MIME-type handled by this class
+    def self.mime_type
+      "application/rdf+xml"
+    end
+    
+    def self.can_infer_metadata?
+      false
+    end
+
+    def self.recognises_file?(file_data)
+      return true #TODO: implement this
+    end
+    
+
+    # Begin Object Initializer
+
+    def initialize(file_data)
+      super(file_data)
+      @world = Redland::librdf_new_world
+      Redland::librdf_world_open @world
+      @storage = Redland::librdf_new_storage @world, "memory", "store", ""
+      raise "failed to create storage" if address@hidden
+      
+      @model = Redland::librdf_new_model @world, @storage, ""
+      raise "failed to create model" if address@hidden
+      
+      parser = Redland::librdf_new_parser @world, "rdfxml", "", nil
+      raise "failed to create parser" if !parser
+      
+      base_uri = Redland::librdf_new_uri @world, 'dontsegfault' #this string must not be null or librdf segfaults????
+      Redland::librdf_parser_parse_string_into_model parser, file_data, base_uri, @model
+    end
+
+    # End Object Initializer
+    
+    
+    # Begin Instance Methods
+    def audio_files
+      audiofiles = []
+      predicate = Redland::librdf_new_node_from_uri_string @world, 'http://www.openarchives.org/ore/terms/aggregates'
+      search = Redland::librdf_new_statement_from_nodes @world, nil, predicate, nil
+      stream = Redland::librdf_model_find_statements @model, search
+      
+      while Redland::librdf_stream_end(stream) == 0
+        statement = Redland::librdf_stream_get_object stream
+        object = Redland::librdf_statement_get_object statement
+        uri = Redland::librdf_node_get_uri object
+        audiofiles << Redland::librdf_uri_to_string(uri)
+
+        Redland::librdf_stream_next stream
+      end
+
+      return audiofiles
+    end
+
+    def valid_workflows
+      workflows = []
+      #Workflow.find(:all).each do |w|
+        #workflows << w if w.processor_class == WorkflowProcessors::Meandre
+      #end
+      workflows
+    end
+    
+
+    # End Instance Methods
+    
+  end
+end

Added: branches/gianni-meandre/lib/file_processors/interface.rb (0 => 2524)


--- branches/gianni-meandre/lib/file_processors/interface.rb	                        (rev 0)
+++ branches/gianni-meandre/lib/file_processors/interface.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,38 @@
+# myExperiment: lib/file_processors/interface.rb
+#
+# Copyright (c) 2008 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+module FileProcessors
+  class Interface
+    
+    #MIME-type handled by this class
+    def self.mime_type
+      ""
+    end
+    
+    def self.can_infer_metadata?
+      false
+    end
+    
+    def self.is_valid_file?
+      false
+    end
+
+    # Begin Object Initializer
+
+    def initialize(file_data)
+      @file_data = file_data
+    end
+
+    # End Object Initializer
+    
+    
+    # Begin Instance Methods
+
+    
+
+    # End Instance Methods
+    
+  end
+end

Added: branches/gianni-meandre/lib/file_types_handler.rb (0 => 2524)


--- branches/gianni-meandre/lib/file_types_handler.rb	                        (rev 0)
+++ branches/gianni-meandre/lib/file_types_handler.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,60 @@
+# myExperiment: lib/file_types_handler.rb
+#
+# Copyright (c) 2008 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+# Helper class to deal with File types and processors.
+# Based on the WorkflowTypesHandler
+
+class FileTypesHandler
+  
+  # Gets all the workflow processor classes that have been defined in the \lib\file_processors directory.
+  # Note: for performance reasons this is a "load once" method and thus requires a server restart if new processor classes are added.
+  def self.processor_classes
+    if @@processor_classes.nil?
+      @@processor_classes = [ ]
+      
+      ObjectSpace.each_object(Class) do |c|
+        if c < FileProcessors::Interface
+          @@processor_classes << c
+        end
+      end
+    end
+    
+    return @@processor_classes
+  end
+
+  def self.for_mime_type(type)
+    if @@mime_type_map.nil?
+      @@mime_type_map = {}
+      processor_classes.each do |c|
+        @@mime_type_map[c.mime_type] = [] if @@mime_type_map[c.mime_type].nil?
+        @@mime_type_map[c.mime_type] << c
+      end
+    end
+    @@mime_type_map[type]
+  end
+
+  def self.for_file(type, file_data)
+    self.for_mime_type(type).each do |c|
+      return c if c.recognises_file?(file_data)
+    end
+  end
+
+protected
+
+  # List of all the processor classes available.
+  @@processor_classes = nil
+  
+  @@mime_type_map = nil
+end
+
+# We need to first retrieve all classes in the workflow_processors directory
+# so that they are then accessible via the ObjectSpace.
+# We assume (and this is a rails convention for anything in the /lib/ directory), 
+# that filenames for example "my_class.rb" correspond to class names for example MyClass.
+Dir.chdir(File.join(RAILS_ROOT, "lib/file_processors")) do
+  Dir.glob("*.rb").each do |f|
+    ("file_processors/" + f.gsub(/.rb/, '')).camelize.constantize
+  end
+end

Added: branches/gianni-meandre/lib/meandre_parser.rb (0 => 2524)


--- branches/gianni-meandre/lib/meandre_parser.rb	                        (rev 0)
+++ branches/gianni-meandre/lib/meandre_parser.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,234 @@
+require 'rdf/redland'
+
+class Node
+	@uri
+	@name
+	attr_accessor :uri, :name
+end
+
+class Link
+	@source
+	@target
+	attr_accessor :source, :target
+end
+
+class Details
+	@name
+	@desc
+  @uri
+	attr_accessor :name, :desc, :uri
+end
+
+class Property
+	@name
+  @uri
+  @value
+  @component_uri
+	attr_accessor :name, :uri, :value, :component_uri
+end
+
+class MeandreParser
+	def initialize(rdfstring)
+		@world = Redland::librdf_new_world
+		Redland::librdf_world_open @world
+		@storage = Redland::librdf_new_storage @world, "memory", "store", ""
+		raise "failed to create storage" if address@hidden
+		
+		@model = Redland::librdf_new_model @world, @storage, ""
+		raise "failed to create model" if address@hidden
+		
+		parser = Redland::librdf_new_parser @world, "turtle", "", nil
+		raise "failed to create parser" if !parser
+		
+		base_uri = Redland::librdf_new_uri @world, 'dontsegfault' #this string must not be null or librdf segfaults????
+		
+		Redland::librdf_parser_parse_string_into_model parser, rdfstring, base_uri, @model
+		
+		#Redland::librdf_free_parser parser
+		#Redland::librdf_free_stream stream
+	end
+
+	def find_nodes()
+		predicate = Redland::librdf_new_node_from_uri_string @world, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'
+		object = Redland::librdf_new_node_from_uri_string @world, 'http://www.meandre.org/ontology/instance_configuration'
+		search = Redland::librdf_new_statement_from_nodes @world, nil, predicate, object
+		stream = Redland::librdf_model_find_statements @model, search
+		
+		nodes = Array.new
+		while Redland::librdf_stream_end(stream) == 0
+			node = Node.new
+			statement=Redland::librdf_stream_get_object stream
+			subject = Redland::librdf_statement_get_subject statement
+			uri = Redland::librdf_node_get_uri subject
+			
+			node_details = get_properties subject
+			node.uri = Redland::librdf_uri_to_string uri
+			node.name = node_details['http://www.meandre.org/ontology/instance_name']
+			
+			nodes.push node
+			
+			Redland::librdf_stream_next stream
+		end
+		
+		nodes
+	end
+	
+	def find_links()
+		predicate = Redland::librdf_new_node_from_uri_string @world, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'
+		object = Redland::librdf_new_node_from_uri_string @world, 'http://www.meandre.org/ontology/data_connector_configuration'
+		search = Redland::librdf_new_statement_from_nodes @world, nil, predicate, object
+		stream = Redland::librdf_model_find_statements @model, search
+
+		source_predicate = Redland::librdf_new_node_from_uri_string @world, 'http://www.meandre.org/ontology/connector_instance_source'
+		target_predicate = Redland::librdf_new_node_from_uri_string @world, 'http://www.meandre.org/ontology/connector_instance_target'
+
+		links = Array.new
+		while Redland::librdf_stream_end(stream) == 0
+			statement=Redland::librdf_stream_get_object stream
+			subject = Redland::librdf_statement_get_subject statement
+			source_search = Redland::librdf_new_statement_from_nodes @world, subject, source_predicate, nil
+			source_stream = Redland::librdf_model_find_statements @model, source_search
+			source_statement = Redland::librdf_stream_get_object source_stream
+			source = Redland::librdf_statement_get_object source_statement
+			source_uri = Redland::librdf_node_get_uri source
+			
+			target_search = Redland::librdf_new_statement_from_nodes @world, subject, target_predicate, nil
+			target_stream = Redland::librdf_model_find_statements @model, target_search
+			target_statement = Redland::librdf_stream_get_object target_stream
+			target = Redland::librdf_statement_get_object target_statement
+			target_uri = Redland::librdf_node_get_uri target
+			
+			link = Link.new
+			link.source = Redland::librdf_uri_to_string source_uri
+			link.target = Redland::librdf_uri_to_string target_uri
+			links.push link
+			
+			Redland::librdf_stream_next stream
+		end
+		
+		links
+	end
+	
+	def make_dot()
+		nodes = find_nodes
+		links = find_links
+		
+		dot = ""
+		dot += "digraph workflow{\n"
+		nodes.each do |node|
+			dot += "\"#{node.uri}\" [label=\"#{node.name}\"]\n"
+		end
+
+		links.each do |link|
+			dot += "\"#{link.source}\" -> \"#{link.target}\"\n"
+		end
+		dot += "}"
+		
+		dot
+	end
+	
+	def find_details()
+		predicate = Redland::librdf_new_node_from_uri_string @world, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'
+		object = Redland::librdf_new_node_from_uri_string @world, 'http://www.meandre.org/ontology/flow_component'
+		search = Redland::librdf_new_statement_from_nodes @world, nil, predicate, object
+		stream = Redland::librdf_model_find_statements @model, search
+		
+		workflow_statement = Redland::librdf_stream_get_object stream
+		workflow = Redland::librdf_statement_get_subject workflow_statement	
+	  workflow_uri = Redland::librdf_node_get_uri workflow	
+		details = Details.new
+		workflow_details = get_properties(workflow)
+		details.name = workflow_details['http://www.meandre.org/ontology/name']
+		details.desc = workflow_details['http://purl.org/dc/elements/1.1/description']
+    details.uri = Redland::librdf_uri_to_string workflow_uri
+		details
+	end
+	
+  #serialise to ttl
+  def get_ttl()
+    serializer = Redland::librdf_new_serializer(@world, 'turtle', 'application/x-turtle', nil)
+    return Redland::librdf_serializer_serialize_model_to_string(serializer, nil, @model)
+  end
+
+  #sets the input string on a myExperimentInput component
+  def set_inputs(inputs)
+    details = find_details 
+    input_uri = details.uri + 'instance/my-experiment-input/0/property/uri' 
+    input_node = Redland::librdf_new_node_from_uri_string(@world, input_uri)
+    property_node = Redland::librdf_new_node_from_uri_string(@world, 'http://www.meandre.org/ontology/value')
+    value_node = Redland::librdf_new_node_from_literal(@world, inputs)
+
+    search = Redland::librdf_new_statement_from_nodes(@world, input_node, property_node, nil)
+    stream = Redland::librdf_model_find_statements(@model, search)
+    if Redland::librdf_stream_end(stream) == 0
+      statement = Redland::librdf_stream_get_object(stream)
+      Redland::librdf_statement_set_object(statement, value_node)
+      Redland::librdf_model_add_statement(@model, statement)
+    end
+  end
+
+  #gets the input string property uri of the PushString component
+  def get_inputs()
+    details = find_details 
+    input_uri = details.uri + 'instance/push-string/0' 
+    return input_uri
+  end
+
+  def get_workflow_inputs()
+    predicate = Redland::librdf_new_node_from_uri_string(@world, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type')
+    object = Redland::librdf_new_node_from_uri_string(@world, 'http://www.meandre.org/ontology/property')
+    search = Redland::librdf_new_statement_from_nodes(@world, nil, predicate, object)
+    stream = Redland::librdf_model_find_statements(@model, search)
+    details = []
+    while Redland::librdf_stream_end(stream) == 0
+      statement = Redland::librdf_stream_get_object(stream)
+      subject = Redland::librdf_statement_get_subject(statement)
+      uri = Redland::librdf_node_get_uri(subject)
+      props = get_properties(subject)
+      detail = Property.new
+      detail.uri = Redland::librdf_uri_to_string(uri)
+      detail.name = props['http://www.meandre.org/ontology/key'] 
+      detail.value = props['http://www.meandre.org/ontology/value'] 
+      detail.component_uri = get_parent_component(detail.uri)
+      details << detail
+      Redland::librdf_stream_next(stream)
+    end
+    #properties beginning with wb_ are meandre internal ones (e.g: position)
+    details.reject{|x| x.name.starts_with?('wb_')}
+  end
+
+  #find which componen ta given property uri belongs to 
+  def get_parent_component(uri)
+    predicate = Redland::librdf_new_node_from_uri_string(@world, 'http://www.meandre.org/ontology/property_set')
+    object = Redland::librdf_new_node_from_uri_string(@world, uri)
+    search = Redland::librdf_new_statement_from_nodes(@world, nil, predicate, object)
+    stream = Redland::librdf_model_find_statements(@model, search)
+    statement = Redland::librdf_stream_get_object(stream)
+    subject = Redland::librdf_statement_get_subject(statement)
+    uri = Redland::librdf_node_get_uri(subject)
+    Redland::librdf_uri_to_string(uri)
+  end
+
+	#helper method that extracts literals from a given subject
+	def get_properties(subject)
+		search = Redland::librdf_new_statement_from_nodes @world, subject, nil, nil
+		stream = Redland::librdf_model_find_statements @model, search
+		
+		props = Hash.new
+		while Redland::librdf_stream_end(stream) == 0
+			statement = Redland::librdf_stream_get_object stream
+			predicate = Redland::librdf_statement_get_predicate statement
+			object = Redland::librdf_statement_get_object statement
+			if Redland::librdf_node_is_literal object
+				predicate_uri = Redland::librdf_node_get_uri predicate
+				predicate_uri_string = Redland::librdf_uri_to_string predicate_uri
+				literal = Redland::librdf_node_get_literal_value object
+				props[predicate_uri_string] = literal
+        #logger.debug("Got LITERAL -- "+literal)
+			end
+			Redland::librdf_stream_next stream
+		end
+		
+		props
+	end
+end

Added: branches/gianni-meandre/lib/workflow_processors/meandre.rb (0 => 2524)


--- branches/gianni-meandre/lib/workflow_processors/meandre.rb	                        (rev 0)
+++ branches/gianni-meandre/lib/workflow_processors/meandre.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,141 @@
+# myExperiment: lib/workflow_processors/meandre.rb
+#
+# Copyright (c) 2008 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+module WorkflowProcessors
+  
+ require 'file_upload'
+ require 'meandre_parser'
+ require 'zip/zip'
+ require 'tempfile'
+
+  class Meandre < WorkflowProcessors::Interface
+    Mime::Type.register "application/octet-stream", :meandre
+    
+    # Begin Class Methods
+    
+    # These: 
+    # - provide information about the Workflow Type supported by this processor,
+    # - provide information about the processor's capabilites, and
+    # - provide any general functionality.
+  
+    # MUST be unique across all processors
+    def self.display_name 
+      "Meandre"
+    end
+    
+    def self.display_data_format
+      "Meandre"
+    end
+    
+    # All the file extensions supported by this workflow processor.
+    # Must be all in lowercase.
+    def self.file_extensions_supported
+      [ "mau" ]
+    end
+    
+    def self.can_determine_type_from_file?
+      true
+    end
+    
+    def self.recognised?(file)
+	  true
+    end
+    
+    def self.can_infer_metadata?
+      true
+    end
+    
+    def self.can_generate_preview_image?
+      true
+    end
+    
+    def self.can_generate_preview_svg?
+      true
+    end
+    
+    # End Class Methods
+    
+    
+    # Begin Object Initializer
+
+    def initialize(workflow_definition)
+      super(workflow_definition)
+	  i = Tempfile.new("meandre_zip");
+	  i.write(workflow_definition);
+	  i.close(false);
+	  rdf = ""
+	  Zip::ZipFile.open(i.path) do |zipfile|
+			rdf = zipfile.read("repository/repository.ttl")
+	  end
+	  @parser = MeandreParser.new(rdf)
+	  @details = @parser.find_details
+    end
+
+    # End Object Initializer
+    
+    
+    # Begin Instance Methods
+    
+    # These provide more specific functionality for a given workflow definition, such as parsing for metadata and image generation.
+    
+    def get_title
+		return @details.name;
+	end
+    
+    def get_description
+		return @details.desc
+    end
+    
+    def get_preview_image
+		#return nil if @parser.nil? || RUBY_PLATFORM =~ /mswin32/
+
+		title = @details.name
+		filename = title.gsub(/[^\w\.\-]/,'_').downcase
+		i = Tempfile.new("image")
+		i.write @parser.make_dot
+		i.close(false)
+
+		img = StringIO.new(`dot -Tpng #{i.path}`)
+		img.extend FileUpload
+		img.original_filename = "#{filename}.png"
+		img.content_type = "image/png"
+		
+		img
+    end
+
+    def get_preview_svg
+	#return nil if @parser.nil? || RUBY_PLATFORM =~ /mswin32/
+
+		title = @details.name
+		filename = title.gsub(/[^\w\.\-]/,'_').downcase
+		i = Tempfile.new("image")
+		i.write @parser.make_dot
+		i.close(false)
+
+		img = StringIO.new(`dot -Tsvg #{i.path}`)
+		img.extend FileUpload
+		img.content_type = "image/svg+xml"
+		img.original_filename = "#{filename}.svg"
+		
+		img
+    end
+
+    def get_workflow_model_object
+		@parser
+	end
+    
+    def get_workflow_model_input_ports
+      @parser.get_workflow_inputs
+    end
+    
+    def get_search_terms
+    end
+
+    def get_components
+    end
+
+    # End Instance Methods
+  end
+end

Added: branches/gianni-meandre/lib/workflow_processors/meandre_ttl.rb (0 => 2524)


--- branches/gianni-meandre/lib/workflow_processors/meandre_ttl.rb	                        (rev 0)
+++ branches/gianni-meandre/lib/workflow_processors/meandre_ttl.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,131 @@
+# myExperiment: lib/workflow_processors/meandre.rb
+#
+# Copyright (c) 2008 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+module WorkflowProcessors
+  
+ require 'file_upload'
+ require 'meandre_parser'
+
+  class MeandreTtl < WorkflowProcessors::Interface
+    Mime::Type.register "application/octet-stream", :meandre_ttl
+    
+    # Begin Class Methods
+    
+    # These: 
+    # - provide information about the Workflow Type supported by this processor,
+    # - provide information about the processor's capabilites, and
+    # - provide any general functionality.
+  
+    # MUST be unique across all processors
+    def self.display_name 
+      "Meandre(TTL)"
+    end
+    
+    def self.display_data_format
+      "Meandre"
+    end
+    
+    # All the file extensions supported by this workflow processor.
+    # Must be all in lowercase.
+    def self.file_extensions_supported
+      [ "ttl" ]
+    end
+    
+    def self.can_determine_type_from_file?
+      true
+    end
+    
+    def self.recognised?(file)
+      true
+    end
+    
+    def self.can_infer_metadata?
+      true
+    end
+    
+    def self.can_generate_preview_image?
+      true
+    end
+    
+    def self.can_generate_preview_svg?
+      true
+    end
+    
+    # End Class Methods
+    
+    
+    # Begin Object Initializer
+
+    def initialize(workflow_definition)
+      super(workflow_definition)
+      @parser = MeandreParser.new(workflow_definition)
+      @details = @parser.find_details
+    end
+
+    # End Object Initializer
+    
+    
+    # Begin Instance Methods
+    
+    # These provide more specific functionality for a given workflow definition, such as parsing for metadata and image generation.
+    
+    def get_title
+		  return @details.name;
+    end
+    
+    def get_description
+      return @details.desc
+    end
+    
+    def get_preview_image
+		#return nil if @parser.nil? || RUBY_PLATFORM =~ /mswin32/
+
+		title = @details.name
+		filename = title.gsub(/[^\w\.\-]/,'_').downcase
+		i = Tempfile.new("image")
+		i.write @parser.make_dot
+		i.close(false)
+
+		img = StringIO.new(`dot -Tpng #{i.path}`)
+		img.extend FileUpload
+		img.original_filename = "#{filename}.png"
+		img.content_type = "image/png"
+		
+		img
+    end
+
+    def get_preview_svg
+	#return nil if @parser.nil? || RUBY_PLATFORM =~ /mswin32/
+
+		title = @details.name
+		filename = title.gsub(/[^\w\.\-]/,'_').downcase
+		i = Tempfile.new("image")
+		i.write @parser.make_dot
+		i.close(false)
+
+		img = StringIO.new(`dot -Tsvg #{i.path}`)
+		img.extend FileUpload
+		img.content_type = "image/svg+xml"
+		img.original_filename = "#{filename}.svg"
+		
+		img
+    end
+
+    def get_workflow_model_object
+      @parser
+    end
+    
+    def get_workflow_model_input_ports
+    end
+    
+    def get_search_terms
+    end
+
+    def get_components
+    end
+
+    # End Instance Methods
+  end
+end

Added: branches/gianni-meandre/test/fixtures/meandre_infrastructures.yml (0 => 2524)


--- branches/gianni-meandre/test/fixtures/meandre_infrastructures.yml	                        (rev 0)
+++ branches/gianni-meandre/test/fixtures/meandre_infrastructures.yml	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,5 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+one:
+  id: 1
+two:
+  id: 2

Added: branches/gianni-meandre/test/unit/meandre_infrastructure_test.rb (0 => 2524)


--- branches/gianni-meandre/test/unit/meandre_infrastructure_test.rb	                        (rev 0)
+++ branches/gianni-meandre/test/unit/meandre_infrastructure_test.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,10 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class MeandreInfrastructureTest < Test::Unit::TestCase
+  fixtures :meandre_infrastructures
+
+  # Replace this with your real tests.
+  def test_truth
+    assert true
+  end
+end

Added: branches/gianni-meandre/vendor/plugins/delayed_job/.gitignore (0 => 2524)


--- branches/gianni-meandre/vendor/plugins/delayed_job/.gitignore	                        (rev 0)
+++ branches/gianni-meandre/vendor/plugins/delayed_job/.gitignore	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1 @@
+*.gem

Added: branches/gianni-meandre/vendor/plugins/delayed_job/MIT-LICENSE (0 => 2524)


--- branches/gianni-meandre/vendor/plugins/delayed_job/MIT-LICENSE	                        (rev 0)
+++ branches/gianni-meandre/vendor/plugins/delayed_job/MIT-LICENSE	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,20 @@
+Copyright (c) 2005 Tobias Luetke
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOa AND
+NONINFRINGEMENT. IN NO EVENT SaALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file

Added: branches/gianni-meandre/vendor/plugins/delayed_job/README.textile (0 => 2524)


--- branches/gianni-meandre/vendor/plugins/delayed_job/README.textile	                        (rev 0)
+++ branches/gianni-meandre/vendor/plugins/delayed_job/README.textile	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,121 @@
+h1. Delayed::Job
+
+Delayed_job (or DJ) encapsulates the common pattern of asynchronously executing longer tasks in the background. 
+
+It is a direct extraction from Shopify where the job table is responsible for a multitude of core tasks. Amongst those tasks are:
+
+* sending massive newsletters
+* image resizing
+* http downloads
+* updating smart collections
+* updating solr, our search server, after product changes
+* batch imports 
+* spam checks 
+
+h2. Setup
+
+The library evolves around a delayed_jobs table which can be created by using:
+<pre><code>
+  script/generate delayed_job_migration
+</code></pre>
+
+The created table looks as follows: 
+
+<pre><code>
+  create_table :delayed_jobs, :force => true do |table|
+    table.integer  :priority, :default => 0      # Allows some jobs to jump to the front of the queue
+    table.integer  :attempts, :default => 0      # Provides for retries, but still fail eventually.
+    table.text     :handler                      # YAML-encoded string of the object that will do work
+    table.string   :last_error                   # reason for last failure (See Note below)
+    table.datetime :run_at                       # When to run. Could be Time.now for immediately, or sometime in the future.
+    table.datetime :locked_at                    # Set when a client is working on this object
+    table.datetime :failed_at                    # Set when all retries have failed (actually, by default, the record is deleted instead)
+    table.string   :locked_by                    # Who is working on this object (if locked)
+    table.timestamps
+  end
+</code></pre>
+
+On failure, the job is scheduled again in 5 seconds + N ** 4, where N is the number of retries.
+
+The default @MAX_ATTEMPTS@ is @address@hidden After this, the job either deleted (default), or left in the database with "failed_at" set.
+With the default of 25 attempts, the last retry will be 20 days later, with the last interval being almost 100 hours.
+
+The default @MAX_RUN_TIME@ is @address@hidden If your job takes longer than that, another computer could pick it up. It's up to you to
+make sure your job doesn't exceed this time. You should set this to the longest time you think the job could take.
+
+By default, it will delete failed jobs (and it always deletes successful jobs). If you want to keep failed jobs, set
address@hidden::Job.destroy_failed_jobs = address@hidden The failed jobs will be marked with non-null failed_at.
+
+Here is an example of changing job parameters in Rails:
+
+<pre><code>
+  # config/initializers/delayed_job_config.rb
+  Delayed::Job.destroy_failed_jobs = false
+  silence_warnings do
+    Delayed::Job.const_set("MAX_ATTEMPTS", 3)
+    Delayed::Job.const_set("MAX_RUN_TIME", 5.minutes)
+  end
+</code></pre>
+
+Note: If your error messages are long, consider changing last_error field to a :text instead of a :string (255 character limit).
+
+
+h2. Usage
+
+Jobs are simple ruby objects with a method called perform. Any object which responds to perform can be stuffed into the jobs table.
+Job objects are serialized to yaml so that they can later be resurrected by the job runner. 
+
+<pre><code>
+  class NewsletterJob < Struct.new(:text, :emails)
+    def perform
+      emails.each { |e| NewsletterMailer.deliver_text_to_email(text, e) }
+    end    
+  end  
+  
+  Delayed::Job.enqueue NewsletterJob.new('lorem ipsum...', Customers.find(:all).collect(&:email))
+</code></pre>
+
+There is also a second way to get jobs in the queue: send_later. 
+
+<pre><code>
+  BatchImporter.new(Shop.find(1)).send_later(:import_massive_csv, massive_csv)
+</code></pre>
+
+This will simply create a @Delayed::PerformableMethod@ job in the jobs table which serializes all the parameters you pass to it. There are some special smarts for active record objects
+which are stored as their text representation and loaded from the database fresh when the job is actually run later.
+                                                                                                                              
+                                                                                                                    
+h2. Running the jobs
+
+You can invoke @rake jobs:work@ which will start working off jobs. You can cancel the rake task with @address@hidden 
+
+You can also run by writing a simple @script/job_runner@, and invoking it externally:
+  
+<pre><code>
+  #!/usr/bin/env ruby
+  require File.dirname(__FILE__) + '/../config/environment'
+  
+  Delayed::Worker.new.start  
+</code></pre>
+
+Workers can be running on any computer, as long as they have access to the database and their clock is in sync. You can even
+run multiple workers on per computer, but you must give each one a unique name. (TODO: put in an example)
+Keep in mind that each worker will check the database at least every 5 seconds.
+
+Note: The rake task will exit if the database has any network connectivity problems.
+
+h3. Cleaning up
+
+You can invoke @rake jobs:clear@ to delete all jobs in the queue.
+
+h3. Changes
+
+* 1.7.0: Added failed_at column which can optionally be set after a certain amount of failed job attempts. By default failed job attempts are destroyed after about a month. 
+
+* 1.6.0: Renamed locked_until to locked_at. We now store when we start a given job instead of how long it will be locked by the worker. This allows us to get a reading on how long a job took to execute.                    
+
+* 1.5.0: Job runners can now be run in parallel. Two new database columns are needed: locked_until and locked_by. This allows us to use   pessimistic locking instead of relying on row level locks. This enables us to run as many worker processes as we need to speed up queue processing.
+
+* 1.2.0: Added #send_later to Object for simpler job creation
+
+* 1.0.0: Initial release

Added: branches/gianni-meandre/vendor/plugins/delayed_job/delayed_job.gemspec (0 => 2524)


--- branches/gianni-meandre/vendor/plugins/delayed_job/delayed_job.gemspec	                        (rev 0)
+++ branches/gianni-meandre/vendor/plugins/delayed_job/delayed_job.gemspec	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,41 @@
+#version = File.read('README.textile').scan(/^\*\s+([\d\.]+)/).flatten
+
+Gem::Specification.new do |s|
+  s.name     = "delayed_job"
+  s.version  = "1.7.0"
+  s.date     = "2008-11-28"
+  s.summary  = "Database-backed asynchronous priority queue system -- Extracted from Shopify"
+  s.email    = "address@hidden"
+  s.homepage = "http://github.com/tobi/delayed_job/tree/master"
+  s.description = "Delated_job (or DJ) encapsulates the common pattern of asynchronously executing longer tasks in the background. It is a direct extraction from Shopify where the job table is responsible for a multitude of core tasks."
+  s.authors  = ["Tobias Lütke"]
+
+  # s.bindir = "bin"
+  # s.executables = ["delayed_job"]
+  # s.default_executable = "delayed_job"
+
+  s.has_rdoc = false
+  s.rdoc_options = ["--main", "README.textile"]
+  s.extra_rdoc_files = ["README.textile"]
+
+  # run git ls-files to get an updated list
+  s.files = %w[
+    MIT-LICENSE
+    README.textile
+    delayed_job.gemspec
+    init.rb
+    lib/delayed/job.rb
+    lib/delayed/message_sending.rb
+    lib/delayed/performable_method.rb
+    lib/delayed/worker.rb
+    lib/delayed_job.rb
+    tasks/jobs.rake
+    tasks/tasks.rb
+  ]
+  s.test_files = %w[
+    spec/database.rb
+    spec/delayed_method_spec.rb
+    spec/job_spec.rb
+    spec/story_spec.rb
+  ]
+end

Added: branches/gianni-meandre/vendor/plugins/delayed_job/generators/delayed_job_migration/delayed_job_migration_generator.rb (0 => 2524)


--- branches/gianni-meandre/vendor/plugins/delayed_job/generators/delayed_job_migration/delayed_job_migration_generator.rb	                        (rev 0)
+++ branches/gianni-meandre/vendor/plugins/delayed_job/generators/delayed_job_migration/delayed_job_migration_generator.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,15 @@
+class DelayedJobMigrationGenerator < Rails::Generator::Base
+  def manifest
+    record do |m|
+      options = {
+        :migration_file_name => 'create_delayed_jobs'
+      }
+
+      m.migration_template 'migration.rb', 'db/migrate', options
+    end
+  end
+  
+  def banner
+    "Usage: #{$0} #{spec.name}"
+  end
+end

Added: branches/gianni-meandre/vendor/plugins/delayed_job/generators/delayed_job_migration/templates/migration.rb (0 => 2524)


--- branches/gianni-meandre/vendor/plugins/delayed_job/generators/delayed_job_migration/templates/migration.rb	                        (rev 0)
+++ branches/gianni-meandre/vendor/plugins/delayed_job/generators/delayed_job_migration/templates/migration.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,22 @@
+class CreateDelayedJobs < ActiveRecord::Migration
+  def self.up
+    create_table :delayed_jobs, :force => true do |t|
+      t.integer  :priority, :default => 0      # Allows some jobs to jump to the front of the queue
+      t.integer  :attempts, :default => 0      # Provides for retries, but still fail eventually.
+      t.text     :handler                      # YAML-encoded string of the object that will do work
+      t.string   :last_error                   # reason for last failure (See Note below)
+      t.datetime :run_at                       # When to run. Could be Time.now for immediately, or sometime in the future.
+      t.datetime :locked_at                    # Set when a client is working on this object
+      t.datetime :failed_at                    # Set when all retries have failed (actually, by default, the record is deleted instead)
+      t.string   :locked_by                    # Who is working on this object (if locked)
+
+      t.timestamps
+    end
+
+    add_index :delayed_jobs, :locked_by
+  end
+
+  def self.down
+    drop_table :delayed_jobs
+  end
+end

Added: branches/gianni-meandre/vendor/plugins/delayed_job/init.rb (0 => 2524)


--- branches/gianni-meandre/vendor/plugins/delayed_job/init.rb	                        (rev 0)
+++ branches/gianni-meandre/vendor/plugins/delayed_job/init.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1 @@
+require File.dirname(__FILE__) + '/lib/delayed_job'

Added: branches/gianni-meandre/vendor/plugins/delayed_job/lib/delayed/job.rb (0 => 2524)


--- branches/gianni-meandre/vendor/plugins/delayed_job/lib/delayed/job.rb	                        (rev 0)
+++ branches/gianni-meandre/vendor/plugins/delayed_job/lib/delayed/job.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,272 @@
+module Delayed
+
+  class DeserializationError < StandardError
+  end
+
+  # A job object that is persisted to the database.
+  # Contains the work object as a YAML field.
+  class Job < ActiveRecord::Base
+    MAX_ATTEMPTS = 25
+    MAX_RUN_TIME = 4.hours
+    set_table_name :delayed_jobs
+
+    # By default failed jobs are destroyed after too many attempts.
+    # If you want to keep them around (perhaps to inspect the reason
+    # for the failure), set this to false.
+    cattr_accessor :destroy_failed_jobs
+    self.destroy_failed_jobs = true
+
+    # Every worker has a unique name which by default is the pid of the process.
+    # There are some advantages to overriding this with something which survives worker retarts:
+    # Workers can safely resume working on tasks which are locked by themselves. The worker will assume that it crashed before.
+    cattr_accessor :worker_name
+    self.worker_name = "host:#{Socket.gethostname} pid:#{Process.pid}" rescue "pid:#{Process.pid}"
+
+    NextTaskSQL         = '(run_at <= ? AND (locked_at IS NULL OR locked_at < ?) OR (locked_by = ?)) AND failed_at IS NULL'
+    NextTaskOrder       = 'priority DESC, run_at ASC'
+
+    ParseObjectFromYaml = /\!ruby\/\w+\:([^\s]+)/
+
+    cattr_accessor :min_priority, :max_priority
+    self.min_priority = nil
+    self.max_priority = nil
+
+    # When a worker is exiting, make sure we don't have any locked jobs.
+    def self.clear_locks!
+      update_all("locked_by = null, locked_at = null", ["locked_by = ?", worker_name])
+    end
+
+    def failed?
+      failed_at
+    end
+    alias_method :failed, :failed?
+
+    def payload_object
+      @payload_object ||= deserialize(self['handler'])
+    end
+
+    def name
+      @name ||= begin
+        payload = payload_object
+        if payload.respond_to?(:display_name)
+          payload.display_name
+        else
+          payload.class.name
+        end
+      end
+    end
+
+    def payload_object=(object)
+      self['handler'] = object.to_yaml
+    end
+
+    # Reschedule the job in the future (when a job fails).
+    # Uses an exponential scale depending on the number of failed attempts.
+    def reschedule(message, backtrace = [], time = nil)
+      if self.attempts < MAX_ATTEMPTS
+        time ||= Job.db_time_now + (attempts ** 4) + 5
+
+        self.attempts    += 1
+        self.run_at       = time
+        self.last_error   = message + "\n" + backtrace.join("\n")
+        self.unlock
+        save!
+      else
+        logger.info "* [JOB] PERMANENTLY removing #{self.name} because of #{attempts} consequetive failures."
+        destroy_failed_jobs ? destroy : update_attribute(:failed_at, Delayed::Job.db_time_now)
+      end
+    end
+
+
+    # Try to run one job. Returns true/false (work done/work failed) or nil if job can't be locked.
+    def run_with_lock(max_run_time, worker_name)
+      logger.info "* [JOB] aquiring lock on #{name}"
+      unless lock_exclusively!(max_run_time, worker_name)
+        # We did not get the lock, some other worker process must have
+        logger.warn "* [JOB] failed to aquire exclusive lock for #{name}"
+        return nil # no work done
+      end
+
+      begin
+        runtime =  Benchmark.realtime do
+          invoke_job # TODO: raise error if takes longer than max_run_time
+          destroy
+        end
+        # TODO: warn if runtime > max_run_time ?
+        logger.info "* [JOB] #{name} completed after %.4f" % runtime
+        return true  # did work
+      rescue Exception => e
+        reschedule e.message, e.backtrace
+        log_exception(e)
+        return false  # work failed
+      end
+    end
+
+    # Add a job to the queue
+    def self.enqueue(*args, &block)
+      object = block_given? ? EvaledJob.new(&block) : args.shift
+
+      unless object.respond_to?(:perform) || block_given?
+        raise ArgumentError, 'Cannot enqueue items which do not respond to perform'
+      end
+    
+      priority = args.first || 0
+      run_at   = args[1]
+
+      Job.create(:payload_object => object, :priority => priority.to_i, :run_at => run_at)
+    end
+
+    # Find a few candidate jobs to run (in case some immediately get locked by others).
+    # Return in random order prevent everyone trying to do same head job at once.
+    def self.find_available(limit = 5, max_run_time = MAX_RUN_TIME)
+
+      time_now = db_time_now
+
+      sql = NextTaskSQL.dup
+
+      conditions = [time_now, time_now - max_run_time, worker_name]
+
+      if self.min_priority
+        sql << ' AND (priority >= ?)'
+        conditions << min_priority
+      end
+
+      if self.max_priority
+        sql << ' AND (priority <= ?)'
+        conditions << max_priority
+      end
+
+      conditions.unshift(sql)
+
+      records = ActiveRecord::Base.silence do
+        find(:all, :conditions => conditions, :order => NextTaskOrder, :limit => limit)
+      end
+
+      records.sort_by { rand() }
+    end
+
+    # Run the next job we can get an exclusive lock on.
+    # If no jobs are left we return nil
+    def self.reserve_and_run_one_job(max_run_time = MAX_RUN_TIME)
+
+      # We get up to 5 jobs from the db. In case we cannot get exclusive access to a job we try the next.
+      # this leads to a more even distribution of jobs across the worker processes
+      find_available(5, max_run_time).each do |job|
+        t = job.run_with_lock(max_run_time, worker_name)
+        return t unless t == nil  # return if we did work (good or bad)
+      end
+
+      nil # we didn't do any work, all 5 were not lockable
+    end
+
+    # Lock this job for this worker.
+    # Returns true if we have the lock, false otherwise.
+    def lock_exclusively!(max_run_time, worker = worker_name)
+      now = self.class.db_time_now
+      affected_rows = if locked_by != worker
+        # We don't own this job so we will update the locked_by name and the locked_at
+        self.class.update_all(["locked_at = ?, locked_by = ?", now, worker], ["id = ? and (locked_at is null or locked_at < ?)", id, (now - max_run_time.to_i)])
+      else
+        # We already own this job, this may happen if the job queue crashes.
+        # Simply resume and update the locked_at
+        self.class.update_all(["locked_at = ?", now], ["id = ? and locked_by = ?", id, worker])
+      end
+      if affected_rows == 1
+        self.locked_at    = now
+        self.locked_by    = worker
+        return true
+      else
+        return false
+      end
+    end
+
+    # Unlock this job (note: not saved to DB)
+    def unlock
+      self.locked_at    = nil
+      self.locked_by    = nil
+    end
+
+    # This is a good hook if you need to report job processing errors in additional or different ways
+    def log_exception(error)
+      logger.error "* [JOB] #{name} failed with #{error.class.name}: #{error.message} - #{attempts} failed attempts"
+      logger.error(error)
+    end
+
+    # Do num jobs and return stats on success/failure.
+    # Exit early if interrupted.
+    def self.work_off(num = 100)
+      success, failure = 0, 0
+
+      num.times do
+        case self.reserve_and_run_one_job
+        when true
+            success += 1
+        when false
+            failure += 1
+        else
+          break  # leave if no work could be done
+        end
+        break if $exit # leave if we're exiting
+      end
+
+      return [success, failure]
+    end
+
+    # Moved into its own method so that new_relic can trace it.
+    def invoke_job
+      payload_object.perform
+    end
+
+  private
+
+    def deserialize(source)
+      handler = YAML.load(source) rescue nil
+
+      unless handler.respond_to?(:perform)
+        if handler.nil? && source =~ ParseObjectFromYaml
+          handler_class = $1
+        end
+        attempt_to_load(handler_class || handler.class)
+        handler = YAML.load(source)
+      end
+
+      return handler if handler.respond_to?(:perform)
+
+      raise DeserializationError,
+        'Job failed to load: Unknown handler. Try to manually require the appropiate file.'
+    rescue TypeError, LoadError, NameError => e
+      raise DeserializationError,
+        "Job failed to load: #{e.message}. Try to manually require the required file."
+    end
+
+    # Constantize the object so that ActiveSupport can attempt
+    # its auto loading magic. Will raise LoadError if not successful.
+    def attempt_to_load(klass)
+       klass.constantize
+    end
+
+    # Get the current time (GMT or local depending on DB)
+    # Note: This does not ping the DB to get the time, so all your clients
+    # must have syncronized clocks.
+    def self.db_time_now
+      Time.now.utc
+    end
+
+  protected
+
+    def before_save
+      self.run_at ||= self.class.db_time_now
+    end
+
+  end
+
+  class EvaledJob
+    def initialize
+      @job = yield
+    end
+
+    def perform
+      eval(@job)
+    end
+  end
+end

Added: branches/gianni-meandre/vendor/plugins/delayed_job/lib/delayed/message_sending.rb (0 => 2524)


--- branches/gianni-meandre/vendor/plugins/delayed_job/lib/delayed/message_sending.rb	                        (rev 0)
+++ branches/gianni-meandre/vendor/plugins/delayed_job/lib/delayed/message_sending.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,17 @@
+module Delayed
+  module MessageSending
+    def send_later(method, *args)
+      Delayed::Job.enqueue Delayed::PerformableMethod.new(self, method.to_sym, args)
+    end
+    
+    module ClassMethods
+      def handle_asynchronously(method)
+        without_name = "#{method}_without_send_later"
+        define_method("#{method}_with_send_later") do |*args|
+          send_later(without_name, *args)
+        end
+        alias_method_chain method, :send_later
+      end
+    end
+  end                               
+end
\ No newline at end of file

Added: branches/gianni-meandre/vendor/plugins/delayed_job/lib/delayed/performable_method.rb (0 => 2524)


--- branches/gianni-meandre/vendor/plugins/delayed_job/lib/delayed/performable_method.rb	                        (rev 0)
+++ branches/gianni-meandre/vendor/plugins/delayed_job/lib/delayed/performable_method.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,55 @@
+module Delayed
+  class PerformableMethod < Struct.new(:object, :method, :args)
+    CLASS_STRING_FORMAT = /^CLASS\:([A-Z][\w\:]+)$/
+    AR_STRING_FORMAT    = /^AR\:([A-Z][\w\:]+)\:(\d+)$/
+
+    def initialize(object, method, args)
+      raise NoMethodError, "undefined method `#{method}' for #{self.inspect}" unless object.respond_to?(method)
+
+      self.object = dump(object)
+      self.args   = args.map { |a| dump(a) }
+      self.method = method.to_sym
+    end
+    
+    def display_name  
+      case self.object
+      when CLASS_STRING_FORMAT then "#{$1}.#{method}"
+      when AR_STRING_FORMAT    then "#{$1}##{method}"
+      else "Unknown##{method}"
+      end      
+    end    
+
+    def perform
+      load(object).send(method, *args.map{|a| load(a)})
+    rescue ActiveRecord::RecordNotFound
+      # We cannot do anything about objects which were deleted in the meantime
+      true
+    end
+
+    private
+
+    def load(arg)
+      case arg
+      when CLASS_STRING_FORMAT then $1.constantize
+      when AR_STRING_FORMAT    then $1.constantize.find($2)
+      else arg
+      end
+    end
+
+    def dump(arg)
+      case arg
+      when Class              then class_to_string(arg)
+      when ActiveRecord::Base then ar_to_string(arg)
+      else arg
+      end
+    end
+
+    def ar_to_string(obj)
+      "AR:#{obj.class}:#{obj.id}"
+    end
+
+    def class_to_string(obj)
+      "CLASS:#{obj.name}"
+    end
+  end
+end
\ No newline at end of file

Added: branches/gianni-meandre/vendor/plugins/delayed_job/lib/delayed/worker.rb (0 => 2524)


--- branches/gianni-meandre/vendor/plugins/delayed_job/lib/delayed/worker.rb	                        (rev 0)
+++ branches/gianni-meandre/vendor/plugins/delayed_job/lib/delayed/worker.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,54 @@
+module Delayed
+  class Worker
+    SLEEP = 5
+
+    cattr_accessor :logger
+    self.logger = if defined?(Merb::Logger)
+      Merb.logger
+    elsif defined?(RAILS_DEFAULT_LOGGER)
+      RAILS_DEFAULT_LOGGER
+    end
+
+    def initialize(options={})
+      @quiet = options[:quiet]
+      Delayed::Job.min_priority = options[:min_priority] if options.has_key?(:min_priority)
+      Delayed::Job.max_priority = options[:max_priority] if options.has_key?(:max_priority)
+    end
+
+    def start
+      say "*** Starting job worker #{Delayed::Job.worker_name}"
+
+      trap('TERM') { say 'Exiting...'; $exit = true }
+      trap('INT')  { say 'Exiting...'; $exit = true }
+
+      loop do
+        result = nil
+
+        realtime = Benchmark.realtime do
+          result = Delayed::Job.work_off
+        end
+
+        count = result.sum
+
+        break if $exit
+
+        if count.zero?
+          sleep(SLEEP)
+        else
+          say "#{count} jobs processed at %.4f j/s, %d failed ..." % [count / realtime, result.last]
+        end
+
+        break if $exit
+      end
+
+    ensure
+      Delayed::Job.clear_locks!
+    end
+
+    def say(text)
+      puts text unless @quiet
+      logger.info text if logger
+    end
+
+  end
+end

Added: branches/gianni-meandre/vendor/plugins/delayed_job/lib/delayed_job.rb (0 => 2524)


--- branches/gianni-meandre/vendor/plugins/delayed_job/lib/delayed_job.rb	                        (rev 0)
+++ branches/gianni-meandre/vendor/plugins/delayed_job/lib/delayed_job.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,13 @@
+autoload :ActiveRecord, 'activerecord'
+
+require File.dirname(__FILE__) + '/delayed/message_sending'
+require File.dirname(__FILE__) + '/delayed/performable_method'
+require File.dirname(__FILE__) + '/delayed/job'
+require File.dirname(__FILE__) + '/delayed/worker'
+
+Object.send(:include, Delayed::MessageSending)   
+Module.send(:include, Delayed::MessageSending::ClassMethods)
+
+if defined?(Merb::Plugins)
+  Merb::Plugins.add_rakefiles File.dirname(__FILE__) / '..' / 'tasks' / 'tasks'
+end

Added: branches/gianni-meandre/vendor/plugins/delayed_job/spec/database.rb (0 => 2524)


--- branches/gianni-meandre/vendor/plugins/delayed_job/spec/database.rb	                        (rev 0)
+++ branches/gianni-meandre/vendor/plugins/delayed_job/spec/database.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,43 @@
+$:.unshift(File.dirname(__FILE__) + '/../lib')
+$:.unshift(File.dirname(__FILE__) + '/../../rspec/lib')
+
+require 'rubygems'
+require 'active_record'
+gem 'sqlite3-ruby'
+
+require File.dirname(__FILE__) + '/../init'
+require 'spec'
+  
+ActiveRecord::Base.logger = Logger.new('/tmp/dj.log')
+ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => '/tmp/jobs.sqlite')
+ActiveRecord::Migration.verbose = false
+ActiveRecord::Base.default_timezone = :utc if Time.zone.nil?
+
+ActiveRecord::Schema.define do
+
+  create_table :delayed_jobs, :force => true do |table|
+    table.integer  :priority, :default => 0
+    table.integer  :attempts, :default => 0
+    table.text     :handler
+    table.string   :last_error
+    table.datetime :run_at
+    table.datetime :locked_at
+    table.string   :locked_by
+    table.datetime :failed_at
+    table.timestamps
+  end
+
+  create_table :stories, :force => true do |table|
+    table.string :text
+  end
+
+end
+
+
+# Purely useful for test cases...
+class Story < ActiveRecord::Base
+  def tell; text; end       
+  def whatever(n, _); tell*n; end
+  
+  handle_asynchronously :whatever
+end

Added: branches/gianni-meandre/vendor/plugins/delayed_job/spec/delayed_method_spec.rb (0 => 2524)


--- branches/gianni-meandre/vendor/plugins/delayed_job/spec/delayed_method_spec.rb	                        (rev 0)
+++ branches/gianni-meandre/vendor/plugins/delayed_job/spec/delayed_method_spec.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,128 @@
+require File.dirname(__FILE__) + '/database'
+
+class SimpleJob
+  cattr_accessor :runs; self.runs = 0
+  def perform; @@runs += 1; end
+end
+
+class RandomRubyObject  
+  def say_hello
+    'hello'
+  end
+end
+
+class ErrorObject
+
+  def throw
+    raise ActiveRecord::RecordNotFound, '...'
+    false
+  end
+
+end
+
+class StoryReader
+
+  def read(story)
+    "Epilog: #{story.tell}"
+  end
+
+end
+
+class StoryReader
+
+  def read(story)
+    "Epilog: #{story.tell}"
+  end
+
+end
+
+describe 'random ruby objects' do
+  before       { Delayed::Job.delete_all }
+
+  it "should respond_to :send_later method" do
+
+    RandomRubyObject.new.respond_to?(:send_later)
+
+  end
+
+  it "should raise a ArgumentError if send_later is called but the target method doesn't exist" do
+    lambda { RandomRubyObject.new.send_later(:method_that_deos_not_exist) }.should raise_error(NoMethodError)
+  end
+
+  it "should add a new entry to the job table when send_later is called on it" do
+    Delayed::Job.count.should == 0
+
+    RandomRubyObject.new.send_later(:to_s)
+
+    Delayed::Job.count.should == 1
+  end
+
+  it "should add a new entry to the job table when send_later is called on the class" do
+    Delayed::Job.count.should == 0
+
+    RandomRubyObject.send_later(:to_s)
+
+    Delayed::Job.count.should == 1
+  end
+
+  it "should run get the original method executed when the job is performed" do
+
+    RandomRubyObject.new.send_later(:say_hello)
+
+    Delayed::Job.count.should == 1
+  end
+
+  it "should ignore ActiveRecord::RecordNotFound errors because they are permanent" do
+
+    ErrorObject.new.send_later(:throw)
+
+    Delayed::Job.count.should == 1
+
+    Delayed::Job.reserve_and_run_one_job
+
+    Delayed::Job.count.should == 0
+
+  end
+
+  it "should store the object as string if its an active record" do
+    story = Story.create :text => 'Once upon...'
+    story.send_later(:tell)
+
+    job =  Delayed::Job.find(:first)
+    job.payload_object.class.should   == Delayed::PerformableMethod
+    job.payload_object.object.should  == "AR:Story:#{story.id}"
+    job.payload_object.method.should  == :tell
+    job.payload_object.args.should    == []
+    job.payload_object.perform.should == 'Once upon...'
+  end
+
+  it "should store arguments as string if they an active record" do
+
+    story = Story.create :text => 'Once upon...'
+
+    reader = StoryReader.new
+    reader.send_later(:read, story)
+
+    job =  Delayed::Job.find(:first)
+    job.payload_object.class.should   == Delayed::PerformableMethod
+    job.payload_object.method.should  == :read
+    job.payload_object.args.should    == ["AR:Story:#{story.id}"]
+    job.payload_object.perform.should == 'Epilog: Once upon...'
+  end                 
+  
+  it "should call send later on methods which are wrapped with handle_asynchronously" do
+    story = Story.create :text => 'Once upon...'
+  
+    Delayed::Job.count.should == 0
+  
+    story.whatever(1, 5)
+  
+    Delayed::Job.count.should == 1
+    job =  Delayed::Job.find(:first)
+    job.payload_object.class.should   == Delayed::PerformableMethod
+    job.payload_object.method.should  == :whatever_without_send_later
+    job.payload_object.args.should    == [1, 5]
+    job.payload_object.perform.should == 'Once upon...'
+  end
+
+end

Added: branches/gianni-meandre/vendor/plugins/delayed_job/spec/job_spec.rb (0 => 2524)


--- branches/gianni-meandre/vendor/plugins/delayed_job/spec/job_spec.rb	                        (rev 0)
+++ branches/gianni-meandre/vendor/plugins/delayed_job/spec/job_spec.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,345 @@
+require File.dirname(__FILE__) + '/database'
+
+class SimpleJob
+  cattr_accessor :runs; self.runs = 0
+  def perform; @@runs += 1; end
+end
+
+class ErrorJob
+  cattr_accessor :runs; self.runs = 0
+  def perform; raise 'did not work'; end
+end             
+
+module M
+  class ModuleJob
+    cattr_accessor :runs; self.runs = 0
+    def perform; @@runs += 1; end    
+  end
+  
+end
+
+describe Delayed::Job do
+  before  do               
+    Delayed::Job.max_priority = nil
+    Delayed::Job.min_priority = nil      
+    
+    Delayed::Job.delete_all
+  end
+  
+  before(:each) do
+    SimpleJob.runs = 0
+  end
+
+  it "should set run_at automatically if not set" do
+    Delayed::Job.create(:payload_object => ErrorJob.new ).run_at.should_not == nil
+  end
+
+  it "should not set run_at automatically if already set" do
+    later = 5.minutes.from_now
+    Delayed::Job.create(:payload_object => ErrorJob.new, :run_at => later).run_at.should == later
+  end
+
+  it "should raise ArgumentError when handler doesn't respond_to :perform" do
+    lambda { Delayed::Job.enqueue(Object.new) }.should raise_error(ArgumentError)
+  end
+
+  it "should increase count after enqueuing items" do
+    Delayed::Job.enqueue SimpleJob.new
+    Delayed::Job.count.should == 1
+  end
+
+  it "should be able to set priority when enqueuing items" do
+    Delayed::Job.enqueue SimpleJob.new, 5
+    Delayed::Job.first.priority.should == 5
+  end
+
+  it "should be able to set run_at when enqueuing items" do
+    later = (Delayed::Job.db_time_now+5.minutes)
+    Delayed::Job.enqueue SimpleJob.new, 5, later
+
+    # use be close rather than equal to because millisecond values cn be lost in DB round trip
+    Delayed::Job.first.run_at.should be_close(later, 1)
+  end
+
+  it "should call perform on jobs when running work_off" do
+    SimpleJob.runs.should == 0
+
+    Delayed::Job.enqueue SimpleJob.new
+    Delayed::Job.work_off
+
+    SimpleJob.runs.should == 1
+  end
+                     
+                     
+  it "should work with eval jobs" do
+    $eval_job_ran = false
+
+    Delayed::Job.enqueue do <<-JOB
+      $eval_job_ran = true
+    JOB
+    end
+
+    Delayed::Job.work_off
+
+    $eval_job_ran.should == true
+  end
+                   
+  it "should work with jobs in modules" do
+    M::ModuleJob.runs.should == 0
+
+    Delayed::Job.enqueue M::ModuleJob.new
+    Delayed::Job.work_off
+
+    M::ModuleJob.runs.should == 1
+  end
+                   
+  it "should re-schedule by about 1 second at first and increment this more and more minutes when it fails to execute properly" do
+    Delayed::Job.enqueue ErrorJob.new
+    Delayed::Job.work_off(1)
+
+    job = Delayed::Job.find(:first)
+
+    job.last_error.should =~ /did not work/
+    job.last_error.should =~ /job_spec.rb:10:in `perform'/
+    job.attempts.should == 1
+
+    job.run_at.should > Delayed::Job.db_time_now - 10.minutes
+    job.run_at.should < Delayed::Job.db_time_now + 10.minutes
+  end
+
+  it "should raise an DeserializationError when the job class is totally unknown" do
+
+    job = Delayed::Job.new
+    job['handler'] = "--- !ruby/object:JobThatDoesNotExist {}"
+
+    lambda { job.payload_object.perform }.should raise_error(Delayed::DeserializationError)
+  end
+
+  it "should try to load the class when it is unknown at the time of the deserialization" do
+    job = Delayed::Job.new
+    job['handler'] = "--- !ruby/object:JobThatDoesNotExist {}"
+
+    job.should_receive(:attempt_to_load).with('JobThatDoesNotExist').and_return(true)
+
+    lambda { job.payload_object.perform }.should raise_error(Delayed::DeserializationError)
+  end
+
+  it "should try include the namespace when loading unknown objects" do
+    job = Delayed::Job.new
+    job['handler'] = "--- !ruby/object:Delayed::JobThatDoesNotExist {}"
+    job.should_receive(:attempt_to_load).with('Delayed::JobThatDoesNotExist').and_return(true)
+    lambda { job.payload_object.perform }.should raise_error(Delayed::DeserializationError)
+  end
+
+  it "should also try to load structs when they are unknown (raises TypeError)" do
+    job = Delayed::Job.new
+    job['handler'] = "--- !ruby/struct:JobThatDoesNotExist {}"
+
+    job.should_receive(:attempt_to_load).with('JobThatDoesNotExist').and_return(true)
+
+    lambda { job.payload_object.perform }.should raise_error(Delayed::DeserializationError)
+  end
+
+  it "should try include the namespace when loading unknown structs" do
+    job = Delayed::Job.new
+    job['handler'] = "--- !ruby/struct:Delayed::JobThatDoesNotExist {}"
+
+    job.should_receive(:attempt_to_load).with('Delayed::JobThatDoesNotExist').and_return(true)
+    lambda { job.payload_object.perform }.should raise_error(Delayed::DeserializationError)
+  end
+  
+  it "should be failed if it failed more than MAX_ATTEMPTS times and we don't want to destroy jobs" do
+    default = Delayed::Job.destroy_failed_jobs
+    Delayed::Job.destroy_failed_jobs = false
+
+    @job = Delayed::Job.create :payload_object => SimpleJob.new, :attempts => 50
+    @job.reload.failed_at.should == nil
+    @job.reschedule 'FAIL'
+    @job.reload.failed_at.should_not == nil
+
+    Delayed::Job.destroy_failed_jobs = default
+  end
+
+  it "should be destroyed if it failed more than MAX_ATTEMPTS times and we want to destroy jobs" do
+    default = Delayed::Job.destroy_failed_jobs
+    Delayed::Job.destroy_failed_jobs = true
+
+    @job = Delayed::Job.create :payload_object => SimpleJob.new, :attempts => 50
+    @job.should_receive(:destroy)
+    @job.reschedule 'FAIL'
+
+    Delayed::Job.destroy_failed_jobs = default
+  end
+
+  it "should never find failed jobs" do
+    @job = Delayed::Job.create :payload_object => SimpleJob.new, :attempts => 50, :failed_at => Delayed::Job.db_time_now
+    Delayed::Job.find_available(1).length.should == 0
+  end
+
+  context "when another worker is already performing an task, it" do
+
+    before :each do
+      Delayed::Job.worker_name = 'worker1'
+      @job = Delayed::Job.create :payload_object => SimpleJob.new, :locked_by => 'worker1', :locked_at => Delayed::Job.db_time_now - 5.minutes
+    end
+
+    it "should not allow a second worker to get exclusive access" do
+      @job.lock_exclusively!(4.hours, 'worker2').should == false
+    end
+
+    it "should allow a second worker to get exclusive access if the timeout has passed" do
+      @job.lock_exclusively!(1.minute, 'worker2').should == true
+    end      
+    
+    it "should be able to get access to the task if it was started more then max_age ago" do
+      @job.locked_at = 5.hours.ago
+      @job.save
+
+      @job.lock_exclusively! 4.hours, 'worker2'
+      @job.reload
+      @job.locked_by.should == 'worker2'
+      @job.locked_at.should > 1.minute.ago
+    end
+
+    it "should not be found by another worker" do
+      Delayed::Job.worker_name = 'worker2'
+
+      Delayed::Job.find_available(1, 6.minutes).length.should == 0
+    end
+
+    it "should be found by another worker if the time has expired" do
+      Delayed::Job.worker_name = 'worker2'
+
+      Delayed::Job.find_available(1, 4.minutes).length.should == 1
+    end
+
+    it "should be able to get exclusive access again when the worker name is the same" do
+      @job.lock_exclusively! 5.minutes, 'worker1'
+      @job.lock_exclusively! 5.minutes, 'worker1'
+      @job.lock_exclusively! 5.minutes, 'worker1'
+    end                                        
+  end            
+  
+  context "#name" do
+    it "should be the class name of the job that was enqueued" do
+      Delayed::Job.create(:payload_object => ErrorJob.new ).name.should == 'ErrorJob'
+    end
+
+    it "should be the method that will be called if its a performable method object" do
+      Delayed::Job.send_later(:clear_locks!)
+      Delayed::Job.last.name.should == 'Delayed::Job.clear_locks!'
+
+    end
+    it "should be the instance method that will be called if its a performable method object" do
+      story = Story.create :text => "..."                 
+      
+      story.send_later(:save)
+      
+      Delayed::Job.last.name.should == 'Story#save'
+    end
+  end
+  
+  context "worker prioritization" do
+    
+    before(:each) do
+      Delayed::Job.max_priority = nil
+      Delayed::Job.min_priority = nil      
+    end
+  
+    it "should only work_off jobs that are >= min_priority" do
+      Delayed::Job.min_priority = -5
+      Delayed::Job.max_priority = 5
+      SimpleJob.runs.should == 0
+    
+      Delayed::Job.enqueue SimpleJob.new, -10
+      Delayed::Job.enqueue SimpleJob.new, 0
+      Delayed::Job.work_off
+    
+      SimpleJob.runs.should == 1
+    end
+  
+    it "should only work_off jobs that are <= max_priority" do
+      Delayed::Job.min_priority = -5
+      Delayed::Job.max_priority = 5
+      SimpleJob.runs.should == 0
+    
+      Delayed::Job.enqueue SimpleJob.new, 10
+      Delayed::Job.enqueue SimpleJob.new, 0
+
+      Delayed::Job.work_off
+
+      SimpleJob.runs.should == 1
+    end                         
+   
+  end
+  
+  context "when pulling jobs off the queue for processing, it" do
+    before(:each) do
+      @job = Delayed::Job.create(
+        :payload_object => SimpleJob.new, 
+        :locked_by => 'worker1', 
+        :locked_at => Delayed::Job.db_time_now - 5.minutes)
+    end
+
+    it "should leave the queue in a consistent state and not run the job if locking fails" do
+      SimpleJob.runs.should == 0     
+      @job.stub!(:lock_exclusively!).with(any_args).once.and_return(false)
+      Delayed::Job.should_receive(:find_available).once.and_return(address@hidden)
+      Delayed::Job.work_off(1)
+      SimpleJob.runs.should == 0
+    end
+  
+  end
+  
+  context "while running alongside other workers that locked jobs, it" do
+    before(:each) do
+      Delayed::Job.worker_name = 'worker1'
+      Delayed::Job.create(:payload_object => SimpleJob.new, :locked_by => 'worker1', :locked_at => (Delayed::Job.db_time_now - 1.minutes))
+      Delayed::Job.create(:payload_object => SimpleJob.new, :locked_by => 'worker2', :locked_at => (Delayed::Job.db_time_now - 1.minutes))
+      Delayed::Job.create(:payload_object => SimpleJob.new)
+      Delayed::Job.create(:payload_object => SimpleJob.new, :locked_by => 'worker1', :locked_at => (Delayed::Job.db_time_now - 1.minutes))
+    end
+
+    it "should ingore locked jobs from other workers" do
+      Delayed::Job.worker_name = 'worker3'
+      SimpleJob.runs.should == 0
+      Delayed::Job.work_off
+      SimpleJob.runs.should == 1 # runs the one open job
+    end
+
+    it "should find our own jobs regardless of locks" do
+      Delayed::Job.worker_name = 'worker1'
+      SimpleJob.runs.should == 0
+      Delayed::Job.work_off
+      SimpleJob.runs.should == 3 # runs open job plus worker1 jobs that were already locked
+    end
+  end
+
+  context "while running with locked and expired jobs, it" do
+    before(:each) do
+      Delayed::Job.worker_name = 'worker1'
+      exp_time = Delayed::Job.db_time_now - (1.minutes + Delayed::Job::MAX_RUN_TIME)
+      Delayed::Job.create(:payload_object => SimpleJob.new, :locked_by => 'worker1', :locked_at => exp_time)
+      Delayed::Job.create(:payload_object => SimpleJob.new, :locked_by => 'worker2', :locked_at => (Delayed::Job.db_time_now - 1.minutes))
+      Delayed::Job.create(:payload_object => SimpleJob.new)
+      Delayed::Job.create(:payload_object => SimpleJob.new, :locked_by => 'worker1', :locked_at => (Delayed::Job.db_time_now - 1.minutes))
+    end
+
+    it "should only find unlocked and expired jobs" do
+      Delayed::Job.worker_name = 'worker3'
+      SimpleJob.runs.should == 0
+      Delayed::Job.work_off
+      SimpleJob.runs.should == 2 # runs the one open job and one expired job
+    end
+
+    it "should ignore locks when finding our own jobs" do
+      Delayed::Job.worker_name = 'worker1'
+      SimpleJob.runs.should == 0
+      Delayed::Job.work_off
+      SimpleJob.runs.should == 3 # runs open job plus worker1 jobs
+      # This is useful in the case of a crash/restart on worker1, but make sure multiple workers on the same host have unique names!
+    end
+
+  end
+  
+end

Added: branches/gianni-meandre/vendor/plugins/delayed_job/spec/story_spec.rb (0 => 2524)


--- branches/gianni-meandre/vendor/plugins/delayed_job/spec/story_spec.rb	                        (rev 0)
+++ branches/gianni-meandre/vendor/plugins/delayed_job/spec/story_spec.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,17 @@
+require File.dirname(__FILE__) + '/database'
+
+describe "A story" do
+
+  before(:all) do
+    @story = Story.create :text => "Once upon a time..."
+  end
+
+  it "should be shared" do
+    @story.tell.should == 'Once upon a time...'
+  end
+
+  it "should not return its result if it storytelling is delayed" do
+    @story.send_later(:tell).should_not == 'Once upon a time...'
+  end
+
+end
\ No newline at end of file

Added: branches/gianni-meandre/vendor/plugins/delayed_job/tasks/jobs.rake (0 => 2524)


--- branches/gianni-meandre/vendor/plugins/delayed_job/tasks/jobs.rake	                        (rev 0)
+++ branches/gianni-meandre/vendor/plugins/delayed_job/tasks/jobs.rake	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1 @@
+require File.join(File.dirname(__FILE__), 'tasks')

Added: branches/gianni-meandre/vendor/plugins/delayed_job/tasks/tasks.rb (0 => 2524)


--- branches/gianni-meandre/vendor/plugins/delayed_job/tasks/tasks.rb	                        (rev 0)
+++ branches/gianni-meandre/vendor/plugins/delayed_job/tasks/tasks.rb	2010-09-30 11:42:20 UTC (rev 2524)
@@ -0,0 +1,15 @@
+# Re-definitions are appended to existing tasks
+task :environment
+task :merb_env
+
+namespace :jobs do
+  desc "Clear the delayed_job queue."
+  task :clear => [:merb_env, :environment] do
+    Delayed::Job.delete_all
+  end
+
+  desc "Start a delayed_job worker."
+  task :work => [:merb_env, :environment] do
+    Delayed::Worker.new(:min_priority => ENV['MIN_PRIORITY'], :max_priority => ENV['MAX_PRIORITY']).start
+  end
+end

reply via email to

[Prev in Thread] Current Thread [Next in Thread]