myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [2601] trunk: added basic OWL support


From: noreply
Subject: [myexperiment-hackers] [2601] trunk: added basic OWL support
Date: Fri, 3 Jun 2011 12:56:27 -0400 (EDT)

Revision
2601
Author
dgc
Date
2011-06-03 12:56:27 -0400 (Fri, 03 Jun 2011)

Log Message

added basic OWL support

Modified Paths

Added Paths

Diff

Modified: trunk/Rakefile (2600 => 2601)


--- trunk/Rakefile	2011-06-03 15:06:16 UTC (rev 2600)
+++ trunk/Rakefile	2011-06-03 16:56:27 UTC (rev 2601)
@@ -56,12 +56,34 @@
   Maintenance::Backup.restore
 end
 
-desc 'Load a controlled vocabulary file'
-task "myexp:vocab:load" do
+desc 'Load a SKOS concept schema'
+task "myexp:skos:load" do
   require File.dirname(__FILE__) + '/config/environment'
-  LoadVocabulary::load_vocabulary
+
+  file_name = ENV['FILE']
+
+  if file_name.nil?
+    puts "Missing file name."
+    return
+  end
+
+  LoadVocabulary::load_skos(YAML::load_file(file_name))
 end
 
+desc 'Load an OWL ontology'
+task "myexp:ontology:load" do
+  require File.dirname(__FILE__) + '/config/environment'
+
+  file_name = ENV['FILE']
+
+  if file_name.nil?
+    puts "Missing file name."
+    return
+  end
+
+  LoadVocabulary::load_ontology(YAML::load_file(file_name))
+end
+
 desc 'Refresh workflow metadata'
 task "myexp:refresh:workflows" do
   require File.dirname(__FILE__) + '/config/environment'

Added: trunk/app/models/ontology.rb (0 => 2601)


--- trunk/app/models/ontology.rb	                        (rev 0)
+++ trunk/app/models/ontology.rb	2011-06-03 16:56:27 UTC (rev 2601)
@@ -0,0 +1,15 @@
+# myExperiment: app/models/ontology.rb
+#
+# Copyright (c) 2011 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+class Ontology < ActiveRecord::Base
+
+  acts_as_structured_data
+
+  format_attribute(:description)
+
+  validates_presence_of(:uri, :title, :prefix)
+
+end
+

Added: trunk/app/models/predicate.rb (0 => 2601)


--- trunk/app/models/predicate.rb	                        (rev 0)
+++ trunk/app/models/predicate.rb	2011-06-03 16:56:27 UTC (rev 2601)
@@ -0,0 +1,15 @@
+# myExperiment: app/models/predicate.rb
+#
+# Copyright (c) 2011 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+class Predicate < ActiveRecord::Base
+
+  acts_as_structured_data
+
+  format_attribute(:description)
+
+  validates_presence_of(:title)
+
+end
+

Added: trunk/config/schema.d/owl.xml (0 => 2601)


--- trunk/config/schema.d/owl.xml	                        (rev 0)
+++ trunk/config/schema.d/owl.xml	2011-06-03 16:56:27 UTC (rev 2601)
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<schema>
+
+  <table name="ontologies">
+
+    <column type="integer"  name="user_id"/>
+    <column type="string"   name="uri"/>
+    <column type="string"   name="title"/>
+    <column type="string"   name="prefix"/>
+    <column type="text"     name="description"/>
+    <column type="text"     name="description_html"/>
+    <column type="datetime" name="created_at"/>
+    <column type="datetime" name="updated_at"/>
+
+    <has-many target="predicates" foreign_key="ontology_id"/>
+
+  </table>
+
+  <table name="predicates">
+
+    <column type="integer"  name="ontology_id"/>
+    <column type="string"   name="title"/>
+    <column type="string"   name="phrase"/>
+    <column type="text"     name="description"/>
+    <column type="text"     name="description_html"/>
+    <column type="text"     name="equivalent_to"/>
+    <column type="datetime" name="created_at"/>
+    <column type="datetime" name="updated_at"/>
+
+    <belongs-to target="ontology"/>
+
+  </table>
+
+</schema>
+

Modified: trunk/lib/load_vocabulary.rb (2600 => 2601)


--- trunk/lib/load_vocabulary.rb	2011-06-03 15:06:16 UTC (rev 2600)
+++ trunk/lib/load_vocabulary.rb	2011-06-03 16:56:27 UTC (rev 2601)
@@ -5,17 +5,8 @@
 
 module LoadVocabulary
 
-  def self.load_vocabulary
+  def self.load_skos(data)
 
-    file_name = ENV['FILE']
-
-    if file_name.nil?
-      puts "Missing file name."
-      return
-    end
-
-    data = ""
-
     exising_vocabulary = Vocabulary.find_by_uri(data["uri"])
     exising_vocabulary.destroy if exising_vocabulary
 
@@ -64,5 +55,28 @@
     end
   end
 
+  def self.load_ontology(data)
+
+    existing_ontology = Ontology.find_by_uri(data["uri"])
+    existing_ontology.destroy if existing_ontology
+
+    
+        :uri         => data["uri"],
+        :title       => data["title"],
+        :prefix      => data["prefix"],
+        :description => data["description"])
+
+    data["predicates"].each do |predicate|
+      
+      p = Predicate.create(
+          :title         => predicate["title"],
+          :phrase        => predicate["phrase"],
+          :description   => predicate["description"],
+          :equivalent_to => predicate["equivalent_to"])
+
+      ontology.predicates << p
+
+    end
+  end
 end
 

reply via email to

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