add pipelineInvocation resource. refs #1357
authorTom Clegg <tom@clinicalfuture.com>
Wed, 9 Jan 2013 22:20:00 +0000 (14:20 -0800)
committerTom Clegg <tom@clinicalfuture.com>
Wed, 9 Jan 2013 23:17:34 +0000 (15:17 -0800)
13 files changed:
app/assets/javascripts/pipeline_invocations.js.coffee [new file with mode: 0644]
app/assets/stylesheets/pipeline_invocations.css.scss [new file with mode: 0644]
app/controllers/application_controller.rb
app/controllers/orvos/v1/pipeline_invocations_controller.rb [new file with mode: 0644]
app/helpers/pipeline_invocations_helper.rb [new file with mode: 0644]
app/models/pipeline_invocation.rb [new file with mode: 0644]
config/routes.rb
db/migrate/20130109220548_create_pipeline_invocations.rb [new file with mode: 0644]
db/schema.rb
test/fixtures/pipeline_invocations.yml [new file with mode: 0644]
test/functional/pipeline_invocations_controller_test.rb [new file with mode: 0644]
test/unit/helpers/pipeline_invocations_helper_test.rb [new file with mode: 0644]
test/unit/pipeline_invocation_test.rb [new file with mode: 0644]

diff --git a/app/assets/javascripts/pipeline_invocations.js.coffee b/app/assets/javascripts/pipeline_invocations.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/pipeline_invocations.css.scss b/app/assets/stylesheets/pipeline_invocations.css.scss
new file mode 100644 (file)
index 0000000..cc3b7af
--- /dev/null
@@ -0,0 +1,3 @@
+// Place all the styles related to the PipelineInvocations controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
index aa6d3b8260e3a8a7f0df49252040d34c9ad47093..8216accfe59b0d14acc345c206290c5b3c99abdb 100644 (file)
@@ -14,6 +14,9 @@ class ApplicationController < ActionController::Base
 
   def create
     @attrs = params[resource_name]
+    if @attrs.nil?
+      raise "no #{resource_name} provided with request #{params.inspect}"
+    end
     if @attrs.class == String
       @attrs = uncamelcase_hash_keys(JSON.parse @attrs)
     end
@@ -38,7 +41,7 @@ class ApplicationController < ActionController::Base
   end
 
   def uncamelcase_params_hash_keys
-    uncamelcase_hash_keys(params)
+    self.params = uncamelcase_hash_keys(params)
   end
 
   def uncamelcase_hash_keys(h)
diff --git a/app/controllers/orvos/v1/pipeline_invocations_controller.rb b/app/controllers/orvos/v1/pipeline_invocations_controller.rb
new file mode 100644 (file)
index 0000000..4219c60
--- /dev/null
@@ -0,0 +1,2 @@
+class Orvos::V1::PipelineInvocationsController < ApplicationController
+end
diff --git a/app/helpers/pipeline_invocations_helper.rb b/app/helpers/pipeline_invocations_helper.rb
new file mode 100644 (file)
index 0000000..2d8ead4
--- /dev/null
@@ -0,0 +1,2 @@
+module PipelineInvocationsHelper
+end
diff --git a/app/models/pipeline_invocation.rb b/app/models/pipeline_invocation.rb
new file mode 100644 (file)
index 0000000..b9f5159
--- /dev/null
@@ -0,0 +1,14 @@
+class PipelineInvocation < ActiveRecord::Base
+  include AssignUuid
+  serialize :components, Hash
+  belongs_to :pipeline, :foreign_key => :pipeline_uuid, :primary_key => :uuid
+
+  after_validation :bootstrap_components
+
+  protected
+  def bootstrap_components
+    if pipeline and (!components or components.empty?)
+      self.components = pipeline.components
+    end
+  end
+end
index 8de53ef650ebb2cb36693c79f79d8ea994d7794b..ab63db3eae453c47efacf2e81fd82568229b2d13 100644 (file)
@@ -1,9 +1,4 @@
 Server::Application.routes.draw do
-  resources :pipelines
-  resources :nodes
-  resources :collections
-  resources :metadata
-
   # The priority is based upon order of creation:
   # first created -> highest priority.
 
@@ -67,6 +62,7 @@ Server::Application.routes.draw do
       resources :metadata
       resources :nodes
       resources :pipelines
+      resources :pipeline_invocations
       match '/nodes/:uuid/ping' => 'nodes#ping', :as => :ping_node
       match '/metadata/:target_kind/:target_uuid' => 'metadata#index'
     end
diff --git a/db/migrate/20130109220548_create_pipeline_invocations.rb b/db/migrate/20130109220548_create_pipeline_invocations.rb
new file mode 100644 (file)
index 0000000..147fdad
--- /dev/null
@@ -0,0 +1,24 @@
+class CreatePipelineInvocations < ActiveRecord::Migration
+  def up
+    create_table :pipeline_invocations 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 :pipeline_uuid
+      t.string :name
+      t.text :components
+      t.boolean :success, :null => true
+      t.boolean :active, :default => false
+
+      t.timestamps
+    end
+    add_index :pipeline_invocations, :uuid, :unique => true
+  end
+  def down
+    drop_table :pipeline_invocations
+  end
+end
index 644a5a7591a9f34c175b106a0590acf7cd39895d..28568e0e5aea9ca8f4f56f77034c53fb4e9f58c5 100644 (file)
@@ -1,4 +1,3 @@
-# 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.
@@ -11,7 +10,7 @@
 #
 # It's strongly recommended to check this file into your version control system.
 
-ActiveRecord::Schema.define(:version => 20130109175700) do
+ActiveRecord::Schema.define(:version => 20130109220548) do
 
   create_table "collections", :force => true do |t|
     t.string   "locator"
@@ -72,6 +71,24 @@ ActiveRecord::Schema.define(:version => 20130109175700) 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 "pipeline_invocations", :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   "pipeline_uuid"
+    t.string   "name"
+    t.text     "components"
+    t.boolean  "success"
+    t.boolean  "active",             :default => false
+    t.datetime "updated_at"
+  end
+
+  add_index "pipeline_invocations", ["uuid"], :name => "index_pipeline_invocations_on_uuid", :unique => true
+
   create_table "pipelines", :force => true do |t|
     t.string   "uuid"
     t.string   "created_by_client"
diff --git a/test/fixtures/pipeline_invocations.yml b/test/fixtures/pipeline_invocations.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/pipeline_invocations_controller_test.rb b/test/functional/pipeline_invocations_controller_test.rb
new file mode 100644 (file)
index 0000000..3d22b75
--- /dev/null
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class PipelineInvocationsControllerTest < ActionController::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end
diff --git a/test/unit/helpers/pipeline_invocations_helper_test.rb b/test/unit/helpers/pipeline_invocations_helper_test.rb
new file mode 100644 (file)
index 0000000..bf0fca9
--- /dev/null
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class PipelineInvocationsHelperTest < ActionView::TestCase
+end
diff --git a/test/unit/pipeline_invocation_test.rb b/test/unit/pipeline_invocation_test.rb
new file mode 100644 (file)
index 0000000..df4bed2
--- /dev/null
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class PipelineInvocationTest < ActiveSupport::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end