|
|
## Gemfile
|
|
|
|
|
|
1. Edit `Gemfile` as such
|
|
|
|
|
|
```diff
|
|
|
- gem 'osc-machete', '~> 0.6.3'
|
|
|
+ gem 'osc-machete', '~> 1.0'
|
|
|
+ gem 'osc_machete_rails', '~> 1.0'
|
|
|
- gem 'awesim_rails', '~> 0.8'
|
|
|
+ gem 'awesim_rails', '~> 1.0'
|
|
|
```
|
|
|
|
|
|
2. Run
|
|
|
|
|
|
```shell
|
|
|
$ bundle install --local
|
|
|
```
|
|
|
|
|
|
## Development Environment
|
|
|
|
|
|
1. Edit `config/environments/development.rb` as such
|
|
|
|
|
|
```diff
|
|
|
- config.eager_load = false
|
|
|
+ config.eager_load = true
|
|
|
```
|
|
|
|
|
|
## Models
|
|
|
|
|
|
### Workflow Model
|
|
|
|
|
|
No changes necessary.
|
|
|
|
|
|
### Job Model
|
|
|
|
|
|
1. Edit `app/models/job.rb` as such
|
|
|
|
|
|
```diff
|
|
|
class Job < ActiveRecord::Base
|
|
|
- include OSC::Machete::SimpleJob::Statusable
|
|
|
+ include OscMacheteRails::Statusable
|
|
|
...
|
|
|
|
|
|
- before_destroy { |j| j.job.delete(rmdir: true) }
|
|
|
|
|
|
...
|
|
|
end
|
|
|
```
|
|
|
|
|
|
## Controllers
|
|
|
|
|
|
1. Edit any `app/controllers/*_controller.rb` as such
|
|
|
|
|
|
```diff
|
|
|
def destroy
|
|
|
- @container.destroy
|
|
|
respond_to do |format|
|
|
|
- format.html { redirect_to containers_url }
|
|
|
- format.json { head :no_content }
|
|
|
+ if @container.destroy
|
|
|
+ format.html { redirect_to containers_url, notice: 'Container was successfully destroyed.' }
|
|
|
+ format.json { head :no_content }
|
|
|
+ else
|
|
|
+ format.html { redirect_to containers_url, alert: "Container failed to be destroyed: #{@container.errors.to_a}" }
|
|
|
+ format.json { render json: @container.errors, status: :internal_server_error }
|
|
|
+ end
|
|
|
end
|
|
|
end
|
|
|
```
|
|
|
|
|
|
```diff
|
|
|
def submit
|
|
|
- if @container.submitted?
|
|
|
- respond_to do |format|
|
|
|
- format.html { redirect_to containers_url, alert: 'Container simulation has already been submitted!' }
|
|
|
+ respond_to do |format|
|
|
|
+ if @container.submitted?
|
|
|
+ format.html { redirect_to containers_url, alert: 'Container has already been submitted.' }
|
|
|
format.json { head :no_content }
|
|
|
- end
|
|
|
- else
|
|
|
- #TODO: add error handling
|
|
|
- @container.submit
|
|
|
-
|
|
|
- respond_to do |format|
|
|
|
- format.html { redirect_to containers_url, notice: 'Container simulation submitted.' }
|
|
|
+ elsif @container.submit
|
|
|
+ format.html { redirect_to containers_url, notice: 'Container was successfully submitted.' }
|
|
|
format.json { head :no_content }
|
|
|
+ else
|
|
|
+ format.html { redirect_to containers_url, alert: "Container failed to be submitted: #{@container.errors.to_a}" }
|
|
|
+ format.json { render json: @container.errors, status: :internal_server_error }
|
|
|
end
|
|
|
end
|
|
|
end
|
|
|
```
|
|
|
|
|
|
2. Replace any occurrence of `container` above with your respective workflow model name.
|
|
|
|
|
|
## Helpers
|
|
|
|
|
|
1. Edit any `app/helpers/*_helper.rb` as such
|
|
|
|
|
|
```diff
|
|
|
- def job_status_label(job)
|
|
|
- ...
|
|
|
- end
|
|
|
```
|
|
|
|
|
|
Basically, remove the method `job_status_label` from all of your helpers as it is now provided for you.
|
|
|
|
|
|
## Gotchas
|
|
|
|
|
|
* `simulation.status` and `job.status` now return an `OSC::Machete::Status` value
|
|
|
|
|
|
```ruby
|
|
|
job.status #=> OSC::Machete::Status.queued
|
|
|
```
|
|
|
|
|
|
although this still maintains backwards compatibility, one should be careful about comparisons with single letter characters
|
|
|
|
|
|
```ruby
|
|
|
def queued?
|
|
|
status == "Q"
|
|
|
end
|
|
|
``` |
|
|
\ No newline at end of file |