myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [3360] branches/wf4ever/app/controllers: WFE-821


From: noreply
Subject: [myexperiment-hackers] [3360] branches/wf4ever/app/controllers: WFE-821 add annotation links
Date: Fri, 25 Jan 2013 17:02:57 +0000 (UTC)

Revision
3360
Author
stain
Date
2013-01-25 17:02:56 +0000 (Fri, 25 Jan 2013)

Log Message

WFE-821 add annotation links

Use RDF.rb directly

Modified Paths

Diff

Modified: branches/wf4ever/app/controllers/application_controller.rb (3359 => 3360)


--- branches/wf4ever/app/controllers/application_controller.rb	2013-01-25 17:02:49 UTC (rev 3359)
+++ branches/wf4ever/app/controllers/application_controller.rb	2013-01-25 17:02:56 UTC (rev 3360)
@@ -1060,6 +1060,8 @@
 
   def create_annotation_body(ro_uri, resource_uri, body, namespaces)
     ## FIXME: THIS IS NOT HOW TO MAKE RDF!!
+    
+    
     namespaces["rdf"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 
     doc = LibXML::XML::Document.new
@@ -1084,33 +1086,27 @@
 
     if params[:commit] == 'Add' || params[:commit] == 'Edit'
 
+      ao_graph = ROSRS::RDFGraph.new
       case params[:template]
       when "Title"
-              ## FIXME: THIS IS NOT HOW TO MAKE RDF!!
-        ao_body = create_annotation_body(ro_uri, resource_uri,
-            LibXML::XML::Node.new('dct:title', params[:value]),
-            { "dct" => "http://purl.org/dc/terms/" })
+        ao_graph.graph << [RDF::URI(resource_uri), RDF::DC.title, params[:value]]
       when "Creator"
-        ao_body = create_annotation_body(ro_uri, resource_uri,
-            LibXML::XML::Node.new('dct:creator', params[:value]),
-            { "dct" => "http://purl.org/dc/terms/" })
+        ## FIXME: dcterms:creator and contributor should be given as resources, not literal
+        ao_graph.graph << [RDF::URI(resource_uri), RDF::DC.creator, params[:value]]
       when "Contributor"
-        ao_body = create_annotation_body(ro_uri, resource_uri,
-            LibXML::XML::Node.new('dct:contributor', params[:value]),
-            { "dct" => "http://purl.org/dc/terms/" })
+        ao_graph.graph << [RDF::URI(resource_uri), RDF::DC.contributor, params[:value]]
       when "Description"
-        ao_body = create_annotation_body(ro_uri, resource_uri,
-            LibXML::XML::Node.new('dct:description', params[:value]),
-            { "dct" => "http://purl.org/dc/terms/" })
+        ao_graph.graph << [RDF::URI(resource_uri), RDF::DC.description, params[:value]]
+      else
+        ao_graph = nil
       end
     end
 
     if params[:commit] == 'Add'
-      if ao_body
-        agraph = ROSRS::RDFGraph.new(:data ="" ao_body.to_s, :format => :xml)
-
+      if ao_graph        
         begin
-          code, reason, stub_uri, body_uri = session.create_internal_annotation(ro_uri, resource_uri, agraph)
+          code, reason, stub_uri, body_uri = session.create_internal_annotation(ro_uri, resource_uri, ao_graph)
+          puts body_uri
         rescue ROSRS::Exception => e
           contributable.errors.add(params[:template], 'Error from remote server')
         end

Modified: branches/wf4ever/app/controllers/packs_controller.rb (3359 => 3360)


--- branches/wf4ever/app/controllers/packs_controller.rb	2013-01-25 17:02:49 UTC (rev 3359)
+++ branches/wf4ever/app/controllers/packs_controller.rb	2013-01-25 17:02:56 UTC (rev 3360)
@@ -146,17 +146,14 @@
   end
   
   def annotate_resource_type(session, resource_uri, type_uri)
-      ## FIXME: THIS IS NOT HOW TO MAKE RDF!!
-#      node = LibXML::XML::Node.new('rdf:type', nil, ["rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#" ])
-#      node["rdf:resource"] = type_uri
-#      ao_body = create_annotation_body(ro_uri, resource_uri, node)
-#      agraph = ROSRS::RDFGraph.new(:data ="" ao_body.to_s, :format => :xml)
-#
-#      begin
-#        code, reason, stub_uri, body_uri = session.create_internal_annotation(ro_uri, resource_uri, agraph)
-#      rescue ROSRS::Exception => e
-#        contributable.errors.add(params[:template], 'Error from remote server')
-#      end      
+    ao_graph = ROSRS::RDFGraph.new
+    ao_graph.graph << [RDF::URI(resource_uri), RDF.type, RDF::URI(type_uri)]
+    
+    begin
+        code, reason, stub_uri, body_uri = session.create_internal_annotation(@pack.ro_uri, resource_uri, ao_graph)
+    rescue ROSRS::Exception => e
+        contributable.errors.add(params[:template], 'Error from remote server')
+    end      
   end
   
   def post_process_created_resource(session, ruri, type)

reply via email to

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