add api template for pipelines, collections, metadata
authorTom Clegg <tom@clinicalfuture.com>
Sun, 13 Jan 2013 21:37:44 +0000 (13:37 -0800)
committerTom Clegg <tom@clinicalfuture.com>
Sun, 13 Jan 2013 21:44:13 +0000 (13:44 -0800)
app/models/collection.rb
app/models/metadatum.rb
app/models/pipeline.rb
db/migrate/20130113214204_add_index_to_collections_and_metadata.rb [new file with mode: 0644]
db/schema.rb

index 84464e1d0248715e1c1c1a8d9456f8b8ce7ff7a5..ccb2ccb8f03404082be4e59d3b15df70116f230f 100644 (file)
@@ -1,2 +1,15 @@
 class Collection < ActiveRecord::Base
+  include AssignUuid
+  include KindAndEtag
+  include CommonApiTemplate
+
+  api_accessible :superuser, :extend => :common do |t|
+    t.add :locator
+    t.add :portable_data_hash
+    t.add :name
+    t.add :redundancy
+    t.add :redundancy_confirmed_by_client
+    t.add :redundancy_confirmed_at
+    t.add :redundancy_confirmed_as
+  end
 end
index 445c728e270124828ed6d5ac8cd01cd2e8055bcf..7736ff9291eb9f2903da251d46a1657425660619 100644 (file)
@@ -1,8 +1,18 @@
 class Metadatum < ActiveRecord::Base
+  include AssignUuid
+  include KindAndEtag
+  include CommonApiTemplate
   serialize :info, Hash
-
   before_validation :populate_native_target
-  include AssignUuid
+
+  api_accessible :superuser, :extend => :common do |t|
+    t.add :target_kind
+    t.add :target_uuid
+    t.add :metadata_class
+    t.add :key
+    t.add :value
+    t.add :info
+  end
 
   def info
     @info ||= Hash.new
index 623bed891574eadb3d78cf7561bb683e111a94d8..c2c025f64157b804cc3bf140dea1914de37be2f0 100644 (file)
@@ -1,4 +1,11 @@
 class Pipeline < ActiveRecord::Base
   include AssignUuid
+  include KindAndEtag
+  include CommonApiTemplate
   serialize :components, Hash
+
+  api_accessible :superuser, :extend => :common do |t|
+    t.add :name
+    t.add :components
+  end
 end
diff --git a/db/migrate/20130113214204_add_index_to_collections_and_metadata.rb b/db/migrate/20130113214204_add_index_to_collections_and_metadata.rb
new file mode 100644 (file)
index 0000000..78499e4
--- /dev/null
@@ -0,0 +1,10 @@
+class AddIndexToCollectionsAndMetadata < ActiveRecord::Migration
+  def up
+    add_index :collections, :uuid, :unique => true
+    add_index :metadata, :uuid, :unique => true
+  end
+  def down
+    remove_index :metadata, :uuid
+    remove_index :collections, :uuid
+  end
+end
index 28568e0e5aea9ca8f4f56f77034c53fb4e9f58c5..aa21ec4c6c7f2a621aad78e8ca29a7b28e5895d4 100644 (file)
@@ -1,3 +1,4 @@
+# encoding: UTF-8
 # This file is auto-generated from the current state of the database. Instead
 # of editing this file, please use the migrations feature of Active Record to
 # incrementally modify your database, and then regenerate this schema definition.
@@ -10,7 +11,7 @@
 #
 # It's strongly recommended to check this file into your version control system.
 
-ActiveRecord::Schema.define(:version => 20130109220548) do
+ActiveRecord::Schema.define(:version => 20130113214204) do
 
   create_table "collections", :force => true do |t|
     t.string   "locator"
@@ -30,6 +31,8 @@ ActiveRecord::Schema.define(:version => 20130109220548) do
     t.string   "uuid"
   end
 
+  add_index "collections", ["uuid"], :name => "index_collections_on_uuid", :unique => true
+
   create_table "metadata", :force => true do |t|
     t.string   "uuid"
     t.string   "created_by_client"
@@ -49,6 +52,8 @@ ActiveRecord::Schema.define(:version => 20130109220548) do
     t.datetime "updated_at"
   end
 
+  add_index "metadata", ["uuid"], :name => "index_metadata_on_uuid", :unique => true
+
   create_table "nodes", :force => true do |t|
     t.string   "uuid"
     t.string   "created_by_client"