myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [3200] branches/snapshots: added pack versions to


From: noreply
Subject: [myexperiment-hackers] [3200] branches/snapshots: added pack versions to REST API
Date: Mon, 26 Nov 2012 13:55:31 +0000 (UTC)

Revision
3200
Author
dgc
Date
2012-11-26 13:55:31 +0000 (Mon, 26 Nov 2012)

Log Message

added pack versions to REST API

Modified Paths

Diff

Modified: branches/snapshots/config/routes.rb (3199 => 3200)


--- branches/snapshots/config/routes.rb	2012-11-26 12:36:45 UTC (rev 3199)
+++ branches/snapshots/config/routes.rb	2012-11-26 13:55:31 UTC (rev 3200)
@@ -99,6 +99,7 @@
                  :download => :get,
                  :quick_add => :post,
                  :resolve_link => :post,
+                 :snapshot => :post,
                  :items => :get } do |pack|
     pack.resources :comments, :collection => { :timeline => :get }
     pack.resources :relationships, :collection => { :edit_relationships => :get }

Modified: branches/snapshots/lib/rest.rb (3199 => 3200)


--- branches/snapshots/lib/rest.rb	2012-11-26 12:36:45 UTC (rev 3199)
+++ branches/snapshots/lib/rest.rb	2012-11-26 13:55:31 UTC (rev 3200)
@@ -190,7 +190,11 @@
           list_element[key] = value
         end
 
-        collection = eval("ob.#{model_data['Accessor'][i]}")
+        if query['version'] and model_data['Versioned'][i] == 'yes'
+          collection = eval(sprintf("ob.find_version(%d).%s", query['version'], model_data['Accessor'][i]))
+        else
+          collection = eval("ob.#{model_data['Accessor'][i]}")
+        end
 
         collection = [collection] if model_data['Encoding'][i] == 'item as list'
 
@@ -383,6 +387,7 @@
   if query['version']
     return rest_response(400, :reason => "Object does not support versioning") unless ob.respond_to?('versions')
     return rest_response(404, :reason => "Specified version does not exist") if query['version'].to_i < 1
+    return rest_response(404, :reason => "Specified version does not exist") if query['version'].to_i > ob.versions.last.version
   end
 
   # Work out which elements to include in the response.
@@ -683,6 +688,7 @@
     when 'Ontology';               return ontology_url(ob)
     when 'Predicate';              return predicate_url(ob)
     when 'Relationship';           return nil
+    when 'PackVersion';            return pack_version_url(ob, ob.version)
 
     when 'Creditation';     return nil
     when 'Attribution';     return nil
@@ -733,6 +739,7 @@
     when 'Attribution';     return nil
 
     when 'WorkflowVersion'; return "#{base}/workflow.xml?id=#{ob.workflow.id}&version=#{ob.version}"
+    when 'PackVersion';     return "#{base}/pack.xml?id=#{ob.pack.id}&version=#{ob.version}"
   end
 
   raise "Class not processed in rest_access_uri: #{ob.class.to_s}"

reply via email to

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