myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [3215] branches/components: Extracting semantic a


From: noreply
Subject: [myexperiment-hackers] [3215] branches/components: Extracting semantic annotations from Taverna 2 workflows
Date: Wed, 28 Nov 2012 08:46:59 +0000 (UTC)

Revision
3215
Author
fbacall
Date
2012-11-28 08:46:58 +0000 (Wed, 28 Nov 2012)

Log Message

Extracting semantic annotations from Taverna 2 workflows

Modified Paths

Diff

Modified: branches/components/Gemfile (3214 => 3215)


--- branches/components/Gemfile	2012-11-27 14:07:35 UTC (rev 3214)
+++ branches/components/Gemfile	2012-11-28 08:46:58 UTC (rev 3215)
@@ -19,4 +19,7 @@
 gem "taverna-scufl", "~> 0.7.2"
 gem "taverna-t2flow", "~> 0.3.0"
 gem "workflow-to-galaxy", "~> 0.3.4"
+gem "addressable"
+gem "rdf"
+gem "rdf-n3"
 

Modified: branches/components/app/models/workflow.rb (3214 => 3215)


--- branches/components/app/models/workflow.rb	2012-11-27 14:07:35 UTC (rev 3214)
+++ branches/components/app/models/workflow.rb	2012-11-28 08:46:58 UTC (rev 3215)
@@ -26,6 +26,8 @@
   belongs_to :license
 
   has_many :workflow_processors, :dependent => :destroy
+  has_many :workflow_ports, :dependent => :destroy
+  has_many :semantic_annotations, :as => :subject, :dependent => :destroy
 
   before_validation :check_unique_name
   before_validation :apply_extracted_metadata
@@ -325,7 +327,7 @@
     if processor_class
       delete_metadata
       begin
-        processor_class.new(content_blob.data).extract_metadata(id)
+        processor_class.new(content_blob.data).extract_metadata(self)
       rescue
       end
     end

Modified: branches/components/app/models/workflow_port.rb (3214 => 3215)


--- branches/components/app/models/workflow_port.rb	2012-11-27 14:07:35 UTC (rev 3214)
+++ branches/components/app/models/workflow_port.rb	2012-11-28 08:46:58 UTC (rev 3215)
@@ -1,7 +1,5 @@
 class WorkflowPort < ActiveRecord::Base
-
   validates_inclusion_of :port_type, :in => ["input", "output"]
   belongs_to :workflow
-  has_many :semantic_annotations, :as => :subject
-
+  has_many :semantic_annotations, :as => :subject, :dependent => :destroy
 end

Modified: branches/components/app/models/workflow_processor.rb (3214 => 3215)


--- branches/components/app/models/workflow_processor.rb	2012-11-27 14:07:35 UTC (rev 3214)
+++ branches/components/app/models/workflow_processor.rb	2012-11-28 08:46:58 UTC (rev 3215)
@@ -5,5 +5,6 @@
 
 class WorkflowProcessor < ActiveRecord::Base
   belongs_to :workflow
+  has_many :semantic_annotations, :as => :subject, :dependent => :destroy
 end
 

Modified: branches/components/lib/workflow_processors/interface.rb (3214 => 3215)


--- branches/components/lib/workflow_processors/interface.rb	2012-11-27 14:07:35 UTC (rev 3214)
+++ branches/components/lib/workflow_processors/interface.rb	2012-11-28 08:46:58 UTC (rev 3215)
@@ -117,7 +117,7 @@
       XML::Node.new("components")
     end
 
-    def extract_metadata(workflow_id)
+    def extract_metadata(workflow)
     end
 
     # End Instance Methods

Modified: branches/components/lib/workflow_processors/taverna2.rb (3214 => 3215)


--- branches/components/lib/workflow_processors/taverna2.rb	2012-11-27 14:07:35 UTC (rev 3214)
+++ branches/components/lib/workflow_processors/taverna2.rb	2012-11-28 08:46:58 UTC (rev 3215)
@@ -9,6 +9,8 @@
   require 't2flow/parser'
   require 't2flow/dot'
   require 'libxml'
+  require 'rdf'
+  require 'rdf/n3'
   
   require 'file_upload'
 
@@ -373,16 +375,45 @@
       aux(@t2flow_model, @t2flow_model, 'components')
     end
     
-    def extract_metadata(workflow_id)
+    def extract_metadata(workflow)
 
       @t2flow_model.all_processors.each do |processor|
-        WorkflowProcessor.create(:workflow_id => workflow_id,
+        workflow_processor = WorkflowProcessor.create(:workflow => workflow,
             :name           => processor.name,
             :wsdl           => processor.wsdl,
             :wsdl_operation => processor.wsdl)
+        create_semantic_annotations(workflow_processor, processor.semantic_annotation)
       end
+
+      @t2flow_model.sources.each do |source|
+        port = WorkflowPort.create(:workflow => workflow,
+                            :port_type => "input",
+                            :name => source.name)
+        create_semantic_annotations(port, source.semantic_annotation)
+      end
+
+      @t2flow_model.sinks.each do |sink|
+        port = WorkflowPort.create(:workflow => workflow,
+                            :port_type => "output",
+                            :name => sink.name)
+        create_semantic_annotations(port, sink.semantic_annotation)
+      end
+
+      create_semantic_annotations(workflow, @t2flow_model.main.annotations.semantic_annotation)
+
     end
 
+    def create_semantic_annotations(subject, semantic_annotations)
+      g = RDF::Graph.new
+      g << RDF::Reader.for(:n3).new(semantic_annotations)
+
+      g.each_statement do |statement|
+        predicate = statement.predicate.to_s
+        object = statement.object.to_s
+        SemanticAnnotation.create(:subject => subject, :predicate => predicate, :object => object)
+      end
+    end
+
     # End Instance Methods
   end
 end

Modified: branches/components/lib/workflow_processors/taverna_scufl.rb (3214 => 3215)


--- branches/components/lib/workflow_processors/taverna_scufl.rb	2012-11-27 14:07:35 UTC (rev 3214)
+++ branches/components/lib/workflow_processors/taverna_scufl.rb	2012-11-28 08:46:58 UTC (rev 3215)
@@ -289,10 +289,10 @@
       aux(@scufl_model, 'components')
     end
 
-    def extract_metadata(workflow_id)
+    def extract_metadata(workflow)
 
       @scufl_model.all_processors.each do |processor|
-        WorkflowProcessor.create(:workflow_id => workflow_id,
+        WorkflowProcessor.create(:workflow => workflow,
             :name           => processor.name,
             :wsdl           => processor.wsdl,
             :wsdl_operation => processor.wsdl_operation)

reply via email to

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