myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [3759] branches/packs/app/controllers: added robu


From: noreply
Subject: [myexperiment-hackers] [3759] branches/packs/app/controllers: added robundle handling to files
Date: Mon, 21 Oct 2013 15:31:21 +0000 (UTC)

Revision
3759
Author
dgc
Date
2013-10-21 15:31:21 +0000 (Mon, 21 Oct 2013)

Log Message

added robundle handling to files

Modified Paths

Diff

Modified: branches/packs/app/controllers/blobs_controller.rb (3758 => 3759)


--- branches/packs/app/controllers/blobs_controller.rb	2013-10-21 13:44:59 UTC (rev 3758)
+++ branches/packs/app/controllers/blobs_controller.rb	2013-10-21 15:31:21 UTC (rev 3759)
@@ -3,6 +3,8 @@
 # Copyright (c) 2007 University of Manchester and the University of Southampton.
 # See license.txt for details.
 
+require 'zip/zip'
+
 class BlobsController < ApplicationController
 
   include ApplicationHelper
@@ -181,6 +183,8 @@
 
           update_credits(@blob, params)
           update_attributions(@blob, params)
+
+          post_process_file(@blob, @blob.research_object.uri + @blob.local_name)
         
           if policy_err_msg.blank?
             update_layout(@blob, params[:layout]) unless params[:policy_type] == "group"
@@ -488,4 +492,42 @@
       render_401("You are not authorised to manage this file.") unless @blob.owner?(current_user)
     end
   end
+
+  def annotate_resources(research_object, resource_uris, body_graph, content_type = 'application/rdf+xml')
+    research_object.create_annotation(
+        :body_graph   => body_graph,
+        :content_type => content_type,
+        :resources    => resource_uris,
+        :creator_uri  => "/users/#{current_user.id}")
+  end
+
+  def post_process_file(file, resource_uri)
+
+    # Process robundle
+
+    if file.content_blob.data[0..3] == "PK\x03\x04"
+
+      bundle_content = file.content_blob.data
+
+      begin
+        zip_file = Tempfile.new('workflow_run.zip.')
+        zip_file.binmode
+        zip_file.write(bundle_content)
+        zip_file.close
+        
+        Zip::ZipFile.open(zip_file.path) { |zip|
+
+          wfdesc = zip.get_entry(".ro/annotations/workflow.wfdesc.ttl").get_input_stream.read
+          wfprov = zip.get_entry("workflowrun.prov.ttl").get_input_stream.read
+
+          annotate_resources(file.research_object, [resource_uri], wfdesc, 'text/turtle')
+          annotate_resources(file.research_object, [resource_uri], wfprov, 'text/turtle')
+        }
+
+      rescue
+        raise unless Rails.env == "production"
+      end
+    end
+  end
+
 end

Modified: branches/packs/app/controllers/packs_controller.rb (3758 => 3759)


--- branches/packs/app/controllers/packs_controller.rb	2013-10-21 13:44:59 UTC (rev 3758)
+++ branches/packs/app/controllers/packs_controller.rb	2013-10-21 15:31:21 UTC (rev 3759)
@@ -608,61 +608,16 @@
     annotate_resources([resource_uri], body)
   end
 
-  def transform_wf(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, @pack.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, @pack.research_object.uri, token].inspect}"
-      puts "################## Transforming at " + uri
-
-      uri
-  end
-  
-  def post_process_workflow_run(entry, resource_uri)
-
-    # FIXME this should work with externals too
-    return unless entry.kind_of?(PackContributableEntry)
-
-    bundle_content = entry.contributable.content_blob.data
-
-    begin
-      zip_file = Tempfile.new('workflow_run.zip.')
-      zip_file.binmode
-      zip_file.write(bundle_content)
-      zip_file.close
-      
-      Zip::ZipFile.open(zip_file.path) { |zip|
-
-        wfdesc = zip.get_entry(".ro/annotations/workflow.wfdesc.ttl").get_input_stream.read
-        wfprov = zip.get_entry("workflowrun.prov.ttl").get_input_stream.read
-
-        annotate_resources([resource_uri], wfdesc, 'text/turtle')
-        annotate_resources([resource_uri], wfprov, 'text/turtle')
-      }
-
-    rescue
-      raise unless Rails.env == "production"
-    end
-  end
-
   def post_process_created_resource(pack, entry, resource_uri, params)
 
     ro = pack.research_object
 
     config = Conf.ro_resource_types.select { |x| x["uri"] == params[:type] }.first
 
-    if params[:type] == WORKFLOW_DEFINITION
-      job_uri = transform_wf(resource_uri)
-    end
-
     if params[:type] != RO_RESOURCE
       annotate_resource_type(resource_uri, params[:type])
     end
 
-    if WORKFLOW_RUN.include?(params[:type])
-      post_process_workflow_run(entry, resource_uri)
-    end
-
     # Folder selection is performed on the following with decreasing order of
     # priority.
     #

reply via email to

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