myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [3641] branches/packs/app: refactored load_graph


From: noreply
Subject: [myexperiment-hackers] [3641] branches/packs/app: refactored load_graph to take an optional base_uri
Date: Fri, 30 Aug 2013 13:12:12 +0000 (UTC)

Revision
3641
Author
dgc
Date
2013-08-30 13:12:12 +0000 (Fri, 30 Aug 2013)

Log Message

refactored load_graph to take an optional base_uri

Modified Paths

Diff

Modified: branches/packs/app/controllers/annotations_controller.rb (3640 => 3641)


--- branches/packs/app/controllers/annotations_controller.rb	2013-08-28 14:48:16 UTC (rev 3640)
+++ branches/packs/app/controllers/annotations_controller.rb	2013-08-30 13:12:12 UTC (rev 3641)
@@ -20,7 +20,7 @@
 
     @annotation = @pack.research_object.resources.find(:first, :conditions => { :uuid => params[:id] })
 
-    @graph = load_graph(@annotation.ao_body.content_blob.data, @annotation.ao_body.content_type)
+    @graph = load_graph(@annotation.ao_body.content_blob.data, :content_type => @annotation.ao_body.content_type)
 
     @annotation_template, @parameters = @pack.research_object.find_template_from_graph(@graph, Conf.ro_templates)
   end

Modified: branches/packs/app/helpers/research_objects_helper.rb (3640 => 3641)


--- branches/packs/app/helpers/research_objects_helper.rb	2013-08-28 14:48:16 UTC (rev 3640)
+++ branches/packs/app/helpers/research_objects_helper.rb	2013-08-30 13:12:12 UTC (rev 3641)
@@ -176,7 +176,10 @@
     end
   end
 
-  def load_graph(content, content_type = "application/rdf+xml")
+  def load_graph(content, opts = {})
+  
+    content_type = opts[:content_type] || "application/rdf+xml"
+    base_uri     = opts[:base_uri]
 
     case content_type
     when "application/rdf+xml"
@@ -186,7 +189,7 @@
     end
 
     graph = RDF::Graph.new
-    graph << RDF::Reader.for(format).new(content) if content
+    graph << RDF::Reader.for(format).new(content, :base_uri => base_uri) if content
     graph
   end
 

Modified: branches/packs/app/models/research_object.rb (3640 => 3641)


--- branches/packs/app/models/research_object.rb	2013-08-28 14:48:16 UTC (rev 3640)
+++ branches/packs/app/models/research_object.rb	2013-08-30 13:12:12 UTC (rev 3641)
@@ -6,6 +6,7 @@
 require 'rdf'
 require 'rdf/raptor'
 require 'yaml'
+require 'zip/zip'
 
 class ResearchObject < ActiveRecord::Base
 
@@ -497,7 +498,7 @@
 
     resources.all(:conditions => { :is_annotation => true }).each do |annotation|
       ao_body = annotation.ao_body
-      result << load_graph(ao_body.content_blob.data, ao_body.content_type)
+      result << load_graph(ao_body.content_blob.data, :content_type => ao_body.content_type)
     end
 
     result
@@ -615,7 +616,7 @@
      
     annotations.uniq.map do |annotation|
 
-      graph = load_graph(annotation.ao_body.content_blob.data, annotation.ao_body.content_type)
+      graph = load_graph(annotation.ao_body.content_blob.data, :content_type => annotation.ao_body.content_type)
 
       template, parameters = find_template_from_graph(graph, Conf.ro_templates)
 
@@ -627,7 +628,7 @@
       }
     end
   end
-
+w:
 private
 
   def create_manifest #:nodoc:

Modified: branches/packs/app/models/resource.rb (3640 => 3641)


--- branches/packs/app/models/resource.rb	2013-08-28 14:48:16 UTC (rev 3640)
+++ branches/packs/app/models/resource.rb	2013-08-30 13:12:12 UTC (rev 3641)
@@ -223,7 +223,7 @@
 
     annotations.each do |annotation|
       ao_body = annotation.ao_body
-      result << load_graph(ao_body.content_blob.data, ao_body.content_type)
+      result << load_graph(ao_body.content_blob.data, :content_type => ao_body.content_type)
     end
 
     result
@@ -232,7 +232,7 @@
   def annotations_with_templates
     annotations.map do |annotation|
 
-      graph = load_graph(annotation.ao_body.content_blob.data, annotation.ao_body.content_type)
+      graph = load_graph(annotation.ao_body.content_blob.data, :content_type => annotation.ao_body.content_type)
 
       template, parameters = research_object.find_template_from_graph(graph, Conf.ro_templates)
 

reply via email to

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