myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [3757] branches/packs/app: added RO backing to wo


From: noreply
Subject: [myexperiment-hackers] [3757] branches/packs/app: added RO backing to workflows
Date: Mon, 21 Oct 2013 13:33:07 +0000 (UTC)

Revision
3757
Author
dgc
Date
2013-10-21 13:33:07 +0000 (Mon, 21 Oct 2013)

Log Message

added RO backing to workflows

Modified Paths

Diff

Modified: branches/packs/app/controllers/workflows_controller.rb (3756 => 3757)


--- branches/packs/app/controllers/workflows_controller.rb	2013-10-21 13:04:39 UTC (rev 3756)
+++ branches/packs/app/controllers/workflows_controller.rb	2013-10-21 13:33:07 UTC (rev 3757)
@@ -3,6 +3,8 @@
 # Copyright (c) 2007 University of Manchester and the University of Southampton.
 # See license.txt for details.
 
+require 'wf4ever/transformation-client'
+
 class WorkflowsController < ApplicationController
 
   include ApplicationHelper
@@ -369,6 +371,8 @@
           raise unless Rails.env == "production"
         end
 
+        transform_wf(@workflow.research_object, @workflow.find_resource_by_path(@workflow.filename).uri)
+
         policy_err_msg = update_policy(@workflow, params, current_user)
 
         # Credits and Attributions:
@@ -1104,5 +1108,13 @@
     return ok
   end
 
+  def transform_wf(research_object, resource_uri)
+    format = "application/vnd.taverna.t2flow+xml"
+    token = Conf.wf_ro_service_bearer_token
+    uri = Wf4Ever::TransformationClient.create_job(Conf.wf_ro_service_uri, resource_uri.to_s, format, research_object.uri, token)
+puts "      [Conf.wf_ro_service_uri, resource_uri, format, @pack.research_object.uri, token] = #{      [Conf.wf_ro_service_uri, resource_uri, format, research_object.uri, token].inspect}"
+    puts "################## Transforming at " + uri
+
+    uri
+  end
 end
-

Modified: branches/packs/app/models/workflow.rb (3756 => 3757)


--- branches/packs/app/models/workflow.rb	2013-10-21 13:04:39 UTC (rev 3756)
+++ branches/packs/app/models/workflow.rb	2013-10-21 13:33:07 UTC (rev 3757)
@@ -17,8 +17,12 @@
 require 'scufl/model'
 require 'scufl/parser'
 
+require 'has_research_object'
+
 class Workflow < ActiveRecord::Base
   
+  include ResearchObjectsHelper
+
   has_many :citations, 
            :order => "created_at DESC",
            :dependent => :destroy
@@ -107,6 +111,10 @@
   validates_presence_of :content_blob
   validates_presence_of :content_type
 
+  has_research_object
+  
+  after_create :create_research_object
+
   def tag_list_comma
     list = ''
     tags.each do |t|
@@ -425,4 +433,22 @@
     WsdlDeprecation.find_all_by_wsdl(workflow_processors.map {|wp| wp.wsdl}).group_by {|wd| wd.deprecation_event}
   end
 
+  def create_research_object
+
+    user_path = "/users/#{contributor_id}"
+
+    slug = "Workflow#{self.id}"
+    slug = SecureRandom.uuid if ResearchObject.find_by_slug_and_version(slug, nil)
+
+    ro = ResearchObject.create(:slug => slug, :user => self.contributor)
+    
+    update_attribute(:research_object, ro)
+
+    workflow_resource = ro.create_aggregated_resource(
+        :user_uri     => user_path,
+        :path         => filename,  # FIXME - where should these be URL encoded?
+        :data         ="" content_blob.data,
+        :context      => self,
+        :content_type => content_type.mime_type)
+  end
 end

reply via email to

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