myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [3540] branches/component-querying: Validate RDF


From: noreply
Subject: [myexperiment-hackers] [3540] branches/component-querying: Validate RDF generation succeeded before saving workflow
Date: Thu, 9 May 2013 15:01:41 +0000 (UTC)

Revision
3540
Author
fbacall
Date
2013-05-09 15:01:41 +0000 (Thu, 09 May 2013)

Log Message

Validate RDF generation succeeded before saving workflow

Modified Paths

Diff

Modified: branches/component-querying/app/controllers/workflows_controller.rb (3539 => 3540)


--- branches/component-querying/app/controllers/workflows_controller.rb	2013-05-09 11:28:46 UTC (rev 3539)
+++ branches/component-querying/app/controllers/workflows_controller.rb	2013-05-09 15:01:41 UTC (rev 3540)
@@ -471,7 +471,7 @@
     if @workflow.valid?
       # Save content blob first now and set it on the workflow.
       # TODO: wrap this in a transaction!
-      @workflow.content_blob = ContentBlob.create(:data ="" file.read)
+      @workflow.content_blob = ContentBlob.new(:data ="" file.read)
       @workflow.preview = nil
       @workflow[:revision_comments] = params[:new_workflow][:rev_comments]
 

Modified: branches/component-querying/lib/acts_as_rdf_serializable.rb (3539 => 3540)


--- branches/component-querying/lib/acts_as_rdf_serializable.rb	2013-05-09 11:28:46 UTC (rev 3539)
+++ branches/component-querying/lib/acts_as_rdf_serializable.rb	2013-05-09 15:01:41 UTC (rev 3540)
@@ -23,6 +23,8 @@
           self.rdf_generator = block
           self.rdf_format = format
 
+          validate :generate_rdf
+
           after_save :store_rdf
           after_destroy :destroy_rdf
 
@@ -46,10 +48,20 @@
           "<#{polymorphic_url(self, :host => "#{base_uri.host}:#{base_uri.port}")}>"
         end
 
+        def generate_rdf
+          begin
+            @rdf = self.to_rdf
+          rescue
+            errors.add_to_base("RDF failed to generate")
+            false
+          else
+            true
+          end
+        end
+
         def store_rdf
           unless TripleStore.instance.nil?
-            rdf = self.to_rdf
-            TripleStore.instance.insert(rdf, resource_uri, self.class.rdf_format) unless rdf.nil?
+            TripleStore.instance.insert(@rdf, resource_uri, self.class.rdf_format) unless @rdf.nil?
           end
         end
 

reply via email to

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