add Job and JobStep resources
authorTom Clegg <tom@clinicalfuture.com>
Sun, 3 Feb 2013 11:30:33 +0000 (03:30 -0800)
committerTom Clegg <tom@clinicalfuture.com>
Sun, 3 Feb 2013 11:30:33 +0000 (03:30 -0800)
22 files changed:
app/assets/javascripts/job_steps.js.coffee [new file with mode: 0644]
app/assets/javascripts/jobs.js.coffee [new file with mode: 0644]
app/assets/stylesheets/job_steps.css.scss [new file with mode: 0644]
app/assets/stylesheets/jobs.css.scss [new file with mode: 0644]
app/controllers/orvos/v1/job_steps_controller.rb [new file with mode: 0644]
app/controllers/orvos/v1/jobs_controller.rb [new file with mode: 0644]
app/helpers/job_steps_helper.rb [new file with mode: 0644]
app/helpers/jobs_helper.rb [new file with mode: 0644]
app/models/job.rb [new file with mode: 0644]
app/models/job_step.rb [new file with mode: 0644]
config/routes.rb
db/migrate/20130203104818_create_jobs.rb [new file with mode: 0644]
db/migrate/20130203104824_create_job_steps.rb [new file with mode: 0644]
db/schema.rb
test/fixtures/job_steps.yml [new file with mode: 0644]
test/fixtures/jobs.yml [new file with mode: 0644]
test/functional/job_steps_controller_test.rb [new file with mode: 0644]
test/functional/jobs_controller_test.rb [new file with mode: 0644]
test/unit/helpers/job_steps_helper_test.rb [new file with mode: 0644]
test/unit/helpers/jobs_helper_test.rb [new file with mode: 0644]
test/unit/job_step_test.rb [new file with mode: 0644]
test/unit/job_test.rb [new file with mode: 0644]

diff --git a/app/assets/javascripts/job_steps.js.coffee b/app/assets/javascripts/job_steps.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/javascripts/jobs.js.coffee b/app/assets/javascripts/jobs.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/job_steps.css.scss b/app/assets/stylesheets/job_steps.css.scss
new file mode 100644 (file)
index 0000000..9c2639b
--- /dev/null
@@ -0,0 +1,3 @@
+// Place all the styles related to the JobSteps controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/assets/stylesheets/jobs.css.scss b/app/assets/stylesheets/jobs.css.scss
new file mode 100644 (file)
index 0000000..e485745
--- /dev/null
@@ -0,0 +1,3 @@
+// Place all the styles related to the Jobs controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/controllers/orvos/v1/job_steps_controller.rb b/app/controllers/orvos/v1/job_steps_controller.rb
new file mode 100644 (file)
index 0000000..6d177f3
--- /dev/null
@@ -0,0 +1,2 @@
+class Orvos::V1::JobStepsController < ApplicationController
+end
diff --git a/app/controllers/orvos/v1/jobs_controller.rb b/app/controllers/orvos/v1/jobs_controller.rb
new file mode 100644 (file)
index 0000000..33425eb
--- /dev/null
@@ -0,0 +1,2 @@
+class Orvos::V1::JobsController < ApplicationController
+end
diff --git a/app/helpers/job_steps_helper.rb b/app/helpers/job_steps_helper.rb
new file mode 100644 (file)
index 0000000..47ff614
--- /dev/null
@@ -0,0 +1,2 @@
+module JobStepsHelper
+end
diff --git a/app/helpers/jobs_helper.rb b/app/helpers/jobs_helper.rb
new file mode 100644 (file)
index 0000000..44c7bf6
--- /dev/null
@@ -0,0 +1,2 @@
+module JobsHelper
+end
diff --git a/app/models/job.rb b/app/models/job.rb
new file mode 100644 (file)
index 0000000..a4b0d1c
--- /dev/null
@@ -0,0 +1,36 @@
+class Job < OrvosModel
+  include AssignUuid
+  include KindAndEtag
+  include CommonApiTemplate
+  serialize :command_parameters, Hash
+  before_create :ensure_unique_submit_id
+
+  class SubmitIdReused < StandardError
+  end
+
+  api_accessible :superuser, :extend => :common do |t|
+    t.add :submit_id
+    t.add :priority
+    t.add :command
+    t.add :command_parameters
+    t.add :command_version
+    t.add :cancelled_at
+    t.add :cancelled_by_client
+    t.add :cancelled_by_user
+    t.add :started_at
+    t.add :finished_at
+    t.add :success
+    t.add :running
+  end
+
+  protected
+
+  def ensure_unique_submit_id
+    if !submit_id.nil?
+      if Job.where('submit_id=?',self.submit_id).first
+        raise SubmitIdReused.new
+      end
+    end
+    true
+  end
+end
diff --git a/app/models/job_step.rb b/app/models/job_step.rb
new file mode 100644 (file)
index 0000000..4fb714b
--- /dev/null
@@ -0,0 +1,8 @@
+class JobStep < OrvosModel
+  include AssignUuid
+  include KindAndEtag
+  include CommonApiTemplate
+
+  api_accessible :superuser, :extend => :common do |t|
+  end
+end
index a25f86373fdd850c5073ab654aa13e5a62b2d7a2..b41af15f530d897b7804ad53a3a6c65edb033639 100644 (file)
@@ -1,4 +1,6 @@
 Server::Application.routes.draw do
+  resources :job_steps
+  resources :jobs
   resources :api_client_authorizations
   resources :api_clients
   resources :logs
@@ -78,11 +80,12 @@ Server::Application.routes.draw do
       resources :nodes
       resources :pipelines
       resources :pipeline_invocations
-      resources :pipelineInvocations
       resources :specimens
       resources :projects
       resources :logs
       resources :users
+      resources :jobs
+      resources :job_steps
     end
   end
 
diff --git a/db/migrate/20130203104818_create_jobs.rb b/db/migrate/20130203104818_create_jobs.rb
new file mode 100644 (file)
index 0000000..f99bf88
--- /dev/null
@@ -0,0 +1,31 @@
+class CreateJobs < ActiveRecord::Migration
+  def change
+    create_table :jobs do |t|
+      t.string :uuid
+      t.string :owner
+      t.string :modified_by_client
+      t.string :modified_by_user
+      t.datetime :modified_at
+      t.string :submit_id
+      t.string :command
+      t.string :command_version
+      t.text :command_parameters
+      t.string :cancelled_by_client
+      t.string :cancelled_by_user
+      t.datetime :cancelled_at
+      t.datetime :started_at
+      t.datetime :finished_at
+      t.boolean :running
+      t.boolean :success
+      t.string :output
+
+      t.timestamps
+    end
+    add_index :jobs, :uuid, :unique => true
+    add_index :jobs, :submit_id, :unique => true
+    add_index :jobs, :command
+    add_index :jobs, :finished_at
+    add_index :jobs, :started_at
+    add_index :jobs, :output
+  end
+end
diff --git a/db/migrate/20130203104824_create_job_steps.rb b/db/migrate/20130203104824_create_job_steps.rb
new file mode 100644 (file)
index 0000000..0636881
--- /dev/null
@@ -0,0 +1,23 @@
+class CreateJobSteps < ActiveRecord::Migration
+  def change
+    create_table :job_steps do |t|
+      t.string :uuid
+      t.string :owner
+      t.string :modified_by_client
+      t.string :modified_by_user
+      t.datetime :modified_at
+      t.string :job_uuid
+      t.integer :sequence
+      t.text :parameters
+      t.text :output
+      t.float :progress
+      t.boolean :success
+
+      t.timestamps
+    end
+    add_index :job_steps, :uuid, :unique => true
+    add_index :job_steps, :job_uuid
+    add_index :job_steps, :sequence
+    add_index :job_steps, :success
+  end
+end
index f2deccbb2a3c39050047022e7cfdaa371968482f..d5cd05d3f664b8e95fb63f47905e7aa4bacd29d6 100644 (file)
@@ -11,7 +11,7 @@
 #
 # It's strongly recommended to check this file into your version control system.
 
-ActiveRecord::Schema.define(:version => 20130130205749) do
+ActiveRecord::Schema.define(:version => 20130203104824) do
 
   create_table "api_client_authorizations", :force => true do |t|
     t.string   "api_token",               :null => false
@@ -64,6 +64,56 @@ ActiveRecord::Schema.define(:version => 20130130205749) do
 
   add_index "collections", ["uuid"], :name => "index_collections_on_uuid", :unique => true
 
+  create_table "job_steps", :force => true do |t|
+    t.string   "uuid"
+    t.string   "owner"
+    t.string   "modified_by_client"
+    t.string   "modified_by_user"
+    t.datetime "modified_at"
+    t.string   "job_uuid"
+    t.integer  "sequence"
+    t.text     "parameters"
+    t.text     "output"
+    t.float    "progress"
+    t.boolean  "success"
+    t.datetime "created_at"
+    t.datetime "updated_at"
+  end
+
+  add_index "job_steps", ["job_uuid"], :name => "index_job_steps_on_job_uuid"
+  add_index "job_steps", ["sequence"], :name => "index_job_steps_on_sequence"
+  add_index "job_steps", ["success"], :name => "index_job_steps_on_success"
+  add_index "job_steps", ["uuid"], :name => "index_job_steps_on_uuid", :unique => true
+
+  create_table "jobs", :force => true do |t|
+    t.string   "uuid"
+    t.string   "owner"
+    t.string   "modified_by_client"
+    t.string   "modified_by_user"
+    t.datetime "modified_at"
+    t.string   "submit_id"
+    t.string   "command"
+    t.string   "command_version"
+    t.text     "command_parameters"
+    t.string   "cancelled_by_client"
+    t.string   "cancelled_by_user"
+    t.datetime "cancelled_at"
+    t.datetime "started_at"
+    t.datetime "finished_at"
+    t.boolean  "running"
+    t.boolean  "success"
+    t.string   "output"
+    t.datetime "created_at"
+    t.datetime "updated_at"
+  end
+
+  add_index "jobs", ["command"], :name => "index_jobs_on_command"
+  add_index "jobs", ["finished_at"], :name => "index_jobs_on_finished_at"
+  add_index "jobs", ["output"], :name => "index_jobs_on_output"
+  add_index "jobs", ["started_at"], :name => "index_jobs_on_started_at"
+  add_index "jobs", ["submit_id"], :name => "index_jobs_on_submit_id", :unique => true
+  add_index "jobs", ["uuid"], :name => "index_jobs_on_uuid", :unique => true
+
   create_table "links", :force => true do |t|
     t.string   "uuid"
     t.string   "owner"
diff --git a/test/fixtures/job_steps.yml b/test/fixtures/job_steps.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/fixtures/jobs.yml b/test/fixtures/jobs.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/job_steps_controller_test.rb b/test/functional/job_steps_controller_test.rb
new file mode 100644 (file)
index 0000000..5a9198b
--- /dev/null
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class JobStepsControllerTest < ActionController::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end
diff --git a/test/functional/jobs_controller_test.rb b/test/functional/jobs_controller_test.rb
new file mode 100644 (file)
index 0000000..ac43b3d
--- /dev/null
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class JobsControllerTest < ActionController::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end
diff --git a/test/unit/helpers/job_steps_helper_test.rb b/test/unit/helpers/job_steps_helper_test.rb
new file mode 100644 (file)
index 0000000..8ba4f82
--- /dev/null
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class JobStepsHelperTest < ActionView::TestCase
+end
diff --git a/test/unit/helpers/jobs_helper_test.rb b/test/unit/helpers/jobs_helper_test.rb
new file mode 100644 (file)
index 0000000..7c4a3fd
--- /dev/null
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class JobsHelperTest < ActionView::TestCase
+end
diff --git a/test/unit/job_step_test.rb b/test/unit/job_step_test.rb
new file mode 100644 (file)
index 0000000..c87035a
--- /dev/null
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class JobStepTest < ActiveSupport::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end
diff --git a/test/unit/job_test.rb b/test/unit/job_test.rb
new file mode 100644 (file)
index 0000000..5079316
--- /dev/null
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class JobTest < ActiveSupport::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end