From 5c97536303ca96700be0af8f3a097ee31dbc8558 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Sun, 13 Jan 2013 13:37:44 -0800 Subject: [PATCH] add api template for pipelines, collections, metadata --- app/models/collection.rb | 13 +++++++++++++ app/models/metadatum.rb | 14 ++++++++++++-- app/models/pipeline.rb | 7 +++++++ ...214204_add_index_to_collections_and_metadata.rb | 10 ++++++++++ db/schema.rb | 7 ++++++- 5 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20130113214204_add_index_to_collections_and_metadata.rb diff --git a/app/models/collection.rb b/app/models/collection.rb index 84464e1d02..ccb2ccb8f0 100644 --- a/app/models/collection.rb +++ b/app/models/collection.rb @@ -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 diff --git a/app/models/metadatum.rb b/app/models/metadatum.rb index 445c728e27..7736ff9291 100644 --- a/app/models/metadatum.rb +++ b/app/models/metadatum.rb @@ -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 diff --git a/app/models/pipeline.rb b/app/models/pipeline.rb index 623bed8915..c2c025f641 100644 --- a/app/models/pipeline.rb +++ b/app/models/pipeline.rb @@ -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 index 0000000000..78499e4b4a --- /dev/null +++ b/db/migrate/20130113214204_add_index_to_collections_and_metadata.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 28568e0e5a..aa21ec4c6c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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" -- 2.30.2