add pipeline resource. refs #1357
authorTom Clegg <tom@clinicalfuture.com>
Wed, 9 Jan 2013 21:03:52 +0000 (13:03 -0800)
committerTom Clegg <tom@clinicalfuture.com>
Wed, 9 Jan 2013 23:17:23 +0000 (15:17 -0800)
13 files changed:
app/assets/javascripts/pipelines.js.coffee [new file with mode: 0644]
app/assets/stylesheets/pipelines.css.scss [new file with mode: 0644]
app/controllers/application_controller.rb
app/controllers/orvos/v1/pipelines_controller.rb [new file with mode: 0644]
app/helpers/pipelines_helper.rb [new file with mode: 0644]
app/models/pipeline.rb [new file with mode: 0644]
config/routes.rb
db/migrate/20130109175700_create_pipelines.rb [new file with mode: 0644]
db/schema.rb
test/fixtures/pipelines.yml [new file with mode: 0644]
test/functional/pipelines_controller_test.rb [new file with mode: 0644]
test/unit/helpers/pipelines_helper_test.rb [new file with mode: 0644]
test/unit/pipeline_test.rb [new file with mode: 0644]

diff --git a/app/assets/javascripts/pipelines.js.coffee b/app/assets/javascripts/pipelines.js.coffee
new file mode 100644 (file)
index 0000000..7615679
--- /dev/null
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
diff --git a/app/assets/stylesheets/pipelines.css.scss b/app/assets/stylesheets/pipelines.css.scss
new file mode 100644 (file)
index 0000000..fa5d69a
--- /dev/null
@@ -0,0 +1,3 @@
+// Place all the styles related to the Pipelines controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
index 612a8896bdd2a926a20131af2e47ef17e1064e8e..aa6d3b8260e3a8a7f0df49252040d34c9ad47093 100644 (file)
@@ -12,12 +12,26 @@ class ApplicationController < ActionController::Base
     render json: @object
   end
 
+  def create
+    @attrs = params[resource_name]
+    if @attrs.class == String
+      @attrs = uncamelcase_hash_keys(JSON.parse @attrs)
+    end
+    @object = model_class.new @attrs
+    @object.save
+    show
+  end
+
   protected
 
   def model_class
     controller_name.classify.constantize
   end
 
+  def resource_name             # params[] key used by client
+    controller_name.classify.camelcase(:lower)
+  end
+
   def find_object_by_uuid
     logger.info params.inspect
     @object = model_class.where('uuid=?', params[:uuid]).first
@@ -47,7 +61,7 @@ class ApplicationController < ActionController::Base
 
   def render_list
     @object_list = {
-      :kind  => "orvos##{model_class.to_s.camelize(:down)}List",
+      :kind  => "orvos##{resource_name}List",
       :etag => "",
       :self_link => "",
       :next_page_token => "",
diff --git a/app/controllers/orvos/v1/pipelines_controller.rb b/app/controllers/orvos/v1/pipelines_controller.rb
new file mode 100644 (file)
index 0000000..b57d47d
--- /dev/null
@@ -0,0 +1,2 @@
+class Orvos::V1::PipelinesController < ApplicationController
+end
diff --git a/app/helpers/pipelines_helper.rb b/app/helpers/pipelines_helper.rb
new file mode 100644 (file)
index 0000000..6837cde
--- /dev/null
@@ -0,0 +1,2 @@
+module PipelinesHelper
+end
diff --git a/app/models/pipeline.rb b/app/models/pipeline.rb
new file mode 100644 (file)
index 0000000..623bed8
--- /dev/null
@@ -0,0 +1,4 @@
+class Pipeline < ActiveRecord::Base
+  include AssignUuid
+  serialize :components, Hash
+end
index 9318be5a67af98b1061c8c515f1d347e03a57720..8de53ef650ebb2cb36693c79f79d8ea994d7794b 100644 (file)
@@ -1,4 +1,5 @@
 Server::Application.routes.draw do
+  resources :pipelines
   resources :nodes
   resources :collections
   resources :metadata
@@ -65,6 +66,7 @@ Server::Application.routes.draw do
       resources :collections
       resources :metadata
       resources :nodes
+      resources :pipelines
       match '/nodes/:uuid/ping' => 'nodes#ping', :as => :ping_node
       match '/metadata/:target_kind/:target_uuid' => 'metadata#index'
     end
diff --git a/db/migrate/20130109175700_create_pipelines.rb b/db/migrate/20130109175700_create_pipelines.rb
new file mode 100644 (file)
index 0000000..fe05886
--- /dev/null
@@ -0,0 +1,21 @@
+class CreatePipelines < ActiveRecord::Migration
+  def up
+    create_table :pipelines do |t|
+      t.string :uuid
+      t.string :created_by_client
+      t.string :created_by_user
+      t.datetime :created_at
+      t.string :modified_by_client
+      t.string :modified_by_user
+      t.datetime :modified_at
+      t.string :name
+      t.text :components
+
+      t.timestamps
+    end
+    add_index :pipelines, :uuid, :unique => true
+  end
+  def down
+    drop_table :pipelines
+  end
+end
index 5db586226479d3851de1ff5666363ff162b69d0c..644a5a7591a9f34c175b106a0590acf7cd39895d 100644 (file)
@@ -11,7 +11,7 @@
 #
 # It's strongly recommended to check this file into your version control system.
 
-ActiveRecord::Schema.define(:version => 20130107212832) do
+ActiveRecord::Schema.define(:version => 20130109175700) do
 
   create_table "collections", :force => true do |t|
     t.string   "locator"
@@ -72,4 +72,19 @@ ActiveRecord::Schema.define(:version => 20130107212832) do
   add_index "nodes", ["slot_number"], :name => "index_nodes_on_slot_number", :unique => true
   add_index "nodes", ["uuid"], :name => "index_nodes_on_uuid", :unique => true
 
+  create_table "pipelines", :force => true do |t|
+    t.string   "uuid"
+    t.string   "created_by_client"
+    t.string   "created_by_user"
+    t.datetime "created_at"
+    t.string   "modified_by_client"
+    t.string   "modified_by_user"
+    t.datetime "modified_at"
+    t.string   "name"
+    t.text     "components"
+    t.datetime "updated_at"
+  end
+
+  add_index "pipelines", ["uuid"], :name => "index_pipelines_on_uuid", :unique => true
+
 end
diff --git a/test/fixtures/pipelines.yml b/test/fixtures/pipelines.yml
new file mode 100644 (file)
index 0000000..c63aac0
--- /dev/null
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+# This model initially had no columns defined.  If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+#  column: value
diff --git a/test/functional/pipelines_controller_test.rb b/test/functional/pipelines_controller_test.rb
new file mode 100644 (file)
index 0000000..468bf6a
--- /dev/null
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class PipelinesControllerTest < ActionController::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end
diff --git a/test/unit/helpers/pipelines_helper_test.rb b/test/unit/helpers/pipelines_helper_test.rb
new file mode 100644 (file)
index 0000000..2c4030a
--- /dev/null
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class PipelinesHelperTest < ActionView::TestCase
+end
diff --git a/test/unit/pipeline_test.rb b/test/unit/pipeline_test.rb
new file mode 100644 (file)
index 0000000..ab21010
--- /dev/null
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class PipelineTest < ActiveSupport::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end