rules_engine 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/VERSION +1 -0
- data/init.rb +1 -0
- data/lib/rules_engine/cache.rb +26 -0
- data/lib/rules_engine/discovery.rb +51 -0
- data/lib/rules_engine/job_runner.rb +115 -0
- data/lib/rules_engine/rule.rb +60 -0
- data/lib/rules_engine/rule_outcome.rb +13 -0
- data/lib/rules_engine.rb +6 -0
- data/rails_generators/USAGE +68 -0
- data/rails_generators/blacklist_word.yml +6 -0
- data/rails_generators/blacklist_word_manifest.rb +26 -0
- data/rails_generators/generator.yml +58 -0
- data/rails_generators/generator_manifest.rb +282 -0
- data/rails_generators/rules_engine_generator.rb +35 -0
- data/rails_generators/simple.yml +6 -0
- data/rails_generators/simple_manifest.rb +21 -0
- data/rails_generators/template_manifest.rb +13 -0
- data/rails_generators/templates/app/controllers/re_jobs_controller.rb +18 -0
- data/rails_generators/templates/app/controllers/re_pipeline_jobs_controller.rb +17 -0
- data/rails_generators/templates/app/controllers/re_pipelines_controller.rb +143 -0
- data/rails_generators/templates/app/controllers/re_rules_controller.rb +140 -0
- data/rails_generators/templates/app/helpers/re_pipeline_helper.rb +29 -0
- data/rails_generators/templates/app/models/re_job.rb +123 -0
- data/rails_generators/templates/app/models/re_job_audit.rb +21 -0
- data/rails_generators/templates/app/models/re_pipeline.rb +69 -0
- data/rails_generators/templates/app/models/re_pipeline_activated.rb +26 -0
- data/rails_generators/templates/app/models/re_pipeline_activated_observer.rb +11 -0
- data/rails_generators/templates/app/models/re_pipeline_base.rb +68 -0
- data/rails_generators/templates/app/models/re_rule.rb +78 -0
- data/rails_generators/templates/app/models/re_rule_outcome.rb +40 -0
- data/rails_generators/templates/app/rules/blacklist_word.rb +89 -0
- data/rails_generators/templates/app/rules/simple.rb +44 -0
- data/rails_generators/templates/app/rules/template.rb +51 -0
- data/rails_generators/templates/app/views/layouts/_blockUI.html.erb +3 -0
- data/rails_generators/templates/app/views/re_jobs/_empty.html.erb +11 -0
- data/rails_generators/templates/app/views/re_jobs/_index.html.erb +66 -0
- data/rails_generators/templates/app/views/re_jobs/_show.html.erb +43 -0
- data/rails_generators/templates/app/views/re_jobs/index.html.erb +21 -0
- data/rails_generators/templates/app/views/re_jobs/index.js.erb +9 -0
- data/rails_generators/templates/app/views/re_jobs/show.html.erb +12 -0
- data/rails_generators/templates/app/views/re_jobs/show.js.erb +1 -0
- data/rails_generators/templates/app/views/re_pipeline_jobs/_empty.html.erb +11 -0
- data/rails_generators/templates/app/views/re_pipeline_jobs/_index.html.erb +41 -0
- data/rails_generators/templates/app/views/re_pipeline_jobs/index.html.erb +21 -0
- data/rails_generators/templates/app/views/re_pipeline_jobs/index.js.erb +10 -0
- data/rails_generators/templates/app/views/re_pipelines/_change.html.erb +46 -0
- data/rails_generators/templates/app/views/re_pipelines/_change_actions.html.erb +34 -0
- data/rails_generators/templates/app/views/re_pipelines/_confirm.html.erb +40 -0
- data/rails_generators/templates/app/views/re_pipelines/_edit.html.erb +21 -0
- data/rails_generators/templates/app/views/re_pipelines/_empty.html.erb +13 -0
- data/rails_generators/templates/app/views/re_pipelines/_index.html.erb +58 -0
- data/rails_generators/templates/app/views/re_pipelines/_new.html.erb +18 -0
- data/rails_generators/templates/app/views/re_pipelines/_show.html.erb +32 -0
- data/rails_generators/templates/app/views/re_pipelines/_show_actions.html.erb +3 -0
- data/rails_generators/templates/app/views/re_pipelines/change.html.erb +37 -0
- data/rails_generators/templates/app/views/re_pipelines/create.js.erb +8 -0
- data/rails_generators/templates/app/views/re_pipelines/edit.html.erb +11 -0
- data/rails_generators/templates/app/views/re_pipelines/edit.js.erb +5 -0
- data/rails_generators/templates/app/views/re_pipelines/index.html.erb +14 -0
- data/rails_generators/templates/app/views/re_pipelines/new.html.erb +9 -0
- data/rails_generators/templates/app/views/re_pipelines/new.js.erb +5 -0
- data/rails_generators/templates/app/views/re_pipelines/show.html.erb +41 -0
- data/rails_generators/templates/app/views/re_pipelines/update.js.erb +13 -0
- data/rails_generators/templates/app/views/re_rule_definitions/blacklist_word/_edit.html.erb +7 -0
- data/rails_generators/templates/app/views/re_rule_definitions/blacklist_word/_help.html.erb +2 -0
- data/rails_generators/templates/app/views/re_rule_definitions/blacklist_word/_new.html.erb +7 -0
- data/rails_generators/templates/app/views/re_rule_definitions/blacklist_word/_pipeline.html.erb +18 -0
- data/rails_generators/templates/app/views/re_rule_definitions/blacklist_word/_script.html.erb +26 -0
- data/rails_generators/templates/app/views/re_rule_definitions/blacklist_word/_title.html.erb +6 -0
- data/rails_generators/templates/app/views/re_rule_definitions/blacklist_word/_word.html.erb +12 -0
- data/rails_generators/templates/app/views/re_rule_definitions/blacklist_word/_words.html.erb +16 -0
- data/rails_generators/templates/app/views/re_rule_definitions/simple/_edit.html.erb +6 -0
- data/rails_generators/templates/app/views/re_rule_definitions/simple/_help.html.erb +2 -0
- data/rails_generators/templates/app/views/re_rule_definitions/simple/_new.html.erb +6 -0
- data/rails_generators/templates/app/views/re_rule_definitions/template/_edit.html.erb +6 -0
- data/rails_generators/templates/app/views/re_rule_definitions/template/_help.html.erb +2 -0
- data/rails_generators/templates/app/views/re_rule_definitions/template/_new.html.erb +6 -0
- data/rails_generators/templates/app/views/re_rules/_change.html.erb +57 -0
- data/rails_generators/templates/app/views/re_rules/_edit.html.erb +25 -0
- data/rails_generators/templates/app/views/re_rules/_empty.html.erb +12 -0
- data/rails_generators/templates/app/views/re_rules/_empty.js.erb +7 -0
- data/rails_generators/templates/app/views/re_rules/_error.html.erb +3 -0
- data/rails_generators/templates/app/views/re_rules/_help.html.erb +13 -0
- data/rails_generators/templates/app/views/re_rules/_index.html.erb +38 -0
- data/rails_generators/templates/app/views/re_rules/_menu.html.erb +41 -0
- data/rails_generators/templates/app/views/re_rules/_new.html.erb +26 -0
- data/rails_generators/templates/app/views/re_rules/_show.html.erb +43 -0
- data/rails_generators/templates/app/views/re_rules/destroy.js.erb +13 -0
- data/rails_generators/templates/app/views/re_rules/edit.html.erb +11 -0
- data/rails_generators/templates/app/views/re_rules/edit.js.erb +5 -0
- data/rails_generators/templates/app/views/re_rules/error.html.erb +11 -0
- data/rails_generators/templates/app/views/re_rules/error.js.erb +3 -0
- data/rails_generators/templates/app/views/re_rules/help.html.erb +11 -0
- data/rails_generators/templates/app/views/re_rules/help.js.erb +2 -0
- data/rails_generators/templates/app/views/re_rules/new.html.erb +11 -0
- data/rails_generators/templates/app/views/re_rules/new.js.erb +5 -0
- data/rails_generators/templates/app/views/re_rules/update.js.erb +20 -0
- data/rails_generators/templates/db/migrate/20100308225008_create_re_pipelines.rb +74 -0
- data/rails_generators/templates/lib/tasks/re_runner.rake +12 -0
- data/rails_generators/templates/public/images/re_job/error-14.png +0 -0
- data/rails_generators/templates/public/images/re_job/error-18.png +0 -0
- data/rails_generators/templates/public/images/re_job/error-25.png +0 -0
- data/rails_generators/templates/public/images/re_job/error-48.png +0 -0
- data/rails_generators/templates/public/images/re_job/goto-16.png +0 -0
- data/rails_generators/templates/public/images/re_job/info-14.png +0 -0
- data/rails_generators/templates/public/images/re_job/info-18.png +0 -0
- data/rails_generators/templates/public/images/re_job/info-25.png +0 -0
- data/rails_generators/templates/public/images/re_job/info-48.png +0 -0
- data/rails_generators/templates/public/images/re_job/list-14.png +0 -0
- data/rails_generators/templates/public/images/re_job/list-18.png +0 -0
- data/rails_generators/templates/public/images/re_job/list-25.png +0 -0
- data/rails_generators/templates/public/images/re_job/list-48.png +0 -0
- data/rails_generators/templates/public/images/re_job/loadingAnimation.gif +0 -0
- data/rails_generators/templates/public/images/re_job/next-disabled-14.png +0 -0
- data/rails_generators/templates/public/images/re_job/next-disabled-18.png +0 -0
- data/rails_generators/templates/public/images/re_job/next-disabled-25.png +0 -0
- data/rails_generators/templates/public/images/re_job/next-disabled-48.png +0 -0
- data/rails_generators/templates/public/images/re_job/next-enabled-14.png +0 -0
- data/rails_generators/templates/public/images/re_job/next-enabled-18.png +0 -0
- data/rails_generators/templates/public/images/re_job/next-enabled-25.png +0 -0
- data/rails_generators/templates/public/images/re_job/next-enabled-48.png +0 -0
- data/rails_generators/templates/public/images/re_job/prev-disabled-14.png +0 -0
- data/rails_generators/templates/public/images/re_job/prev-disabled-18.png +0 -0
- data/rails_generators/templates/public/images/re_job/prev-disabled-25.png +0 -0
- data/rails_generators/templates/public/images/re_job/prev-disabled-48.png +0 -0
- data/rails_generators/templates/public/images/re_job/prev-enabled-14.png +0 -0
- data/rails_generators/templates/public/images/re_job/prev-enabled-18.png +0 -0
- data/rails_generators/templates/public/images/re_job/prev-enabled-25.png +0 -0
- data/rails_generators/templates/public/images/re_job/prev-enabled-48.png +0 -0
- data/rails_generators/templates/public/images/re_job/success-14.png +0 -0
- data/rails_generators/templates/public/images/re_job/success-18.png +0 -0
- data/rails_generators/templates/public/images/re_job/success-25.png +0 -0
- data/rails_generators/templates/public/images/re_job/success-48.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/__destroy-14.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/__destroy-18.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/__destroy-25.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/__destroy-48.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/activate-14.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/activate-18.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/activate-25.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/activate-48.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/alert-14.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/alert-18.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/alert-25.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/alert-48.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/change-14.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/change-18.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/change-25.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/change-48.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/changed-14.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/changed-18.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/changed-25.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/changed-48.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/current-14.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/current-18.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/current-25.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/current-48.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/deactivate-14.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/deactivate-18.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/deactivate-25.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/deactivate-48.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/destroy-14.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/destroy-18.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/destroy-25.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/destroy-48.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/draft-14.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/draft-18.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/draft-25.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/draft-48.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/edit-14.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/edit-18.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/edit-25.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/edit-48.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/list-14.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/list-18.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/list-25.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/list-48.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/list-down.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/list-right.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/new-14.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/new-18.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/new-25.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/new-48.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/revert-14.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/revert-18.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/revert-25.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/revert-48.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/show-14.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/show-18.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/show-25.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/show-48.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/verify-14.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/verify-18.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/verify-25.png +0 -0
- data/rails_generators/templates/public/images/re_pipeline/verify-48.png +0 -0
- data/rails_generators/templates/public/images/re_rule/__destroy-14.png +0 -0
- data/rails_generators/templates/public/images/re_rule/__destroy-18.png +0 -0
- data/rails_generators/templates/public/images/re_rule/__destroy-25.png +0 -0
- data/rails_generators/templates/public/images/re_rule/__destroy-48.png +0 -0
- data/rails_generators/templates/public/images/re_rule/destroy-14.png +0 -0
- data/rails_generators/templates/public/images/re_rule/destroy-18.png +0 -0
- data/rails_generators/templates/public/images/re_rule/destroy-25.png +0 -0
- data/rails_generators/templates/public/images/re_rule/destroy-48.png +0 -0
- data/rails_generators/templates/public/images/re_rule/edit-14.png +0 -0
- data/rails_generators/templates/public/images/re_rule/edit-18.png +0 -0
- data/rails_generators/templates/public/images/re_rule/edit-25.png +0 -0
- data/rails_generators/templates/public/images/re_rule/edit-48.png +0 -0
- data/rails_generators/templates/public/images/re_rule/goto-pipeline-14.png +0 -0
- data/rails_generators/templates/public/images/re_rule/goto-pipeline-18.png +0 -0
- data/rails_generators/templates/public/images/re_rule/move-down-14.png +0 -0
- data/rails_generators/templates/public/images/re_rule/move-down-18.png +0 -0
- data/rails_generators/templates/public/images/re_rule/move-down-25.png +0 -0
- data/rails_generators/templates/public/images/re_rule/move-down-48.png +0 -0
- data/rails_generators/templates/public/images/re_rule/move-down-off-14.png +0 -0
- data/rails_generators/templates/public/images/re_rule/move-down-off-18.png +0 -0
- data/rails_generators/templates/public/images/re_rule/move-down-off-25.png +0 -0
- data/rails_generators/templates/public/images/re_rule/move-down-off-48.png +0 -0
- data/rails_generators/templates/public/images/re_rule/move-up-14.png +0 -0
- data/rails_generators/templates/public/images/re_rule/move-up-18.png +0 -0
- data/rails_generators/templates/public/images/re_rule/move-up-25.png +0 -0
- data/rails_generators/templates/public/images/re_rule/move-up-48.png +0 -0
- data/rails_generators/templates/public/images/re_rule/move-up-off-14.png +0 -0
- data/rails_generators/templates/public/images/re_rule/move-up-off-18.png +0 -0
- data/rails_generators/templates/public/images/re_rule/move-up-off-25.png +0 -0
- data/rails_generators/templates/public/images/re_rule/move-up-off-48.png +0 -0
- data/rails_generators/templates/public/images/re_rule/next-change-14.png +0 -0
- data/rails_generators/templates/public/images/re_rule/next-change-18.png +0 -0
- data/rails_generators/templates/public/images/re_rule/next-change-25.png +0 -0
- data/rails_generators/templates/public/images/re_rule/next-change-48.png +0 -0
- data/rails_generators/templates/public/images/re_rule/next-show-14.png +0 -0
- data/rails_generators/templates/public/images/re_rule/next-show-18.png +0 -0
- data/rails_generators/templates/public/images/re_rule/next-show-25.png +0 -0
- data/rails_generators/templates/public/images/re_rule/next-show-48.png +0 -0
- data/rails_generators/templates/public/images/re_rule/stop-failure-14.png +0 -0
- data/rails_generators/templates/public/images/re_rule/stop-failure-18.png +0 -0
- data/rails_generators/templates/public/images/re_rule/stop-failure-25.png +0 -0
- data/rails_generators/templates/public/images/re_rule/stop-failure-48.png +0 -0
- data/rails_generators/templates/public/images/re_rule/stop-success-14.png +0 -0
- data/rails_generators/templates/public/images/re_rule/stop-success-18.png +0 -0
- data/rails_generators/templates/public/images/re_rule/stop-success-25.png +0 -0
- data/rails_generators/templates/public/images/re_rule/stop-success-48.png +0 -0
- data/rails_generators/templates/public/images/re_rule/valid-14.png +0 -0
- data/rails_generators/templates/public/images/re_rule/valid-18.png +0 -0
- data/rails_generators/templates/public/images/re_rule/valid-25.png +0 -0
- data/rails_generators/templates/public/images/re_rule/valid-48.png +0 -0
- data/rails_generators/templates/public/images/re_rule/verify-14.png +0 -0
- data/rails_generators/templates/public/images/re_rule/verify-18.png +0 -0
- data/rails_generators/templates/public/images/re_rule/verify-25.png +0 -0
- data/rails_generators/templates/public/images/re_rule/verify-48.png +0 -0
- data/rails_generators/templates/public/images/re_rule_class/add-14.png +0 -0
- data/rails_generators/templates/public/images/re_rule_class/add-18.png +0 -0
- data/rails_generators/templates/public/images/re_rule_class/add-25.png +0 -0
- data/rails_generators/templates/public/images/re_rule_class/add-48.png +0 -0
- data/rails_generators/templates/public/images/re_rule_class/help-14.png +0 -0
- data/rails_generators/templates/public/images/re_rule_class/help-18.png +0 -0
- data/rails_generators/templates/public/images/re_rule_class/help-25.png +0 -0
- data/rails_generators/templates/public/images/re_rule_class/help-48.png +0 -0
- data/rails_generators/templates/public/images/re_rule_class/list-down.png +0 -0
- data/rails_generators/templates/public/images/re_rule_class/list-right.png +0 -0
- data/rails_generators/templates/public/images/re_rule_class/new-14.png +0 -0
- data/rails_generators/templates/public/images/re_rule_class/new-18.png +0 -0
- data/rails_generators/templates/public/images/re_rule_class/new-25.png +0 -0
- data/rails_generators/templates/public/images/re_rule_class/new-48.png +0 -0
- data/rails_generators/templates/public/javascripts/re_jobs.js +59 -0
- data/rails_generators/templates/public/javascripts/re_pipeline.js +54 -0
- data/rails_generators/templates/public/javascripts/re_pipeline_change.js +205 -0
- data/rails_generators/templates/public/javascripts/re_pipeline_index.js +24 -0
- data/rails_generators/templates/public/javascripts/re_pipeline_jobs.js +61 -0
- data/rails_generators/templates/public/javascripts/re_pipeline_new.js +34 -0
- data/rails_generators/templates/public/stylesheets/re_pipeline/accept.png +0 -0
- data/rails_generators/templates/public/stylesheets/re_pipeline/exclamation.png +0 -0
- data/rails_generators/templates/public/stylesheets/re_pipeline.css +509 -0
- data/rails_generators/templates/spec/controllers/re_pipelines_controller_spec.rb +111 -0
- data/rails_generators/templates/spec/models/re_job_audit_spec.rb +24 -0
- data/rails_generators/templates/spec/models/re_job_spec.rb +18 -0
- data/rails_generators/templates/spec/models/re_pipeline_activated_spec.rb +6 -0
- data/rails_generators/templates/spec/models/re_pipeline_base_spec.rb +157 -0
- data/rails_generators/templates/spec/models/re_pipeline_spec.rb +166 -0
- data/rails_generators/templates/spec/models/re_rule_outcome_spec.rb +97 -0
- data/rails_generators/templates/spec/models/re_rule_spec.rb +171 -0
- data/rails_generators/templates/spec/support/blueprint_re_pipelines.rb +11 -0
- data/spec/rules_engine_spec.rb +7 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +9 -0
- data/tasks/rspec.rake +18 -0
- metadata +363 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
module RePipelineHelper
|
2
|
+
|
3
|
+
def javascript_alert_messages
|
4
|
+
unless flash[:error].blank?
|
5
|
+
flash.delete(:success)
|
6
|
+
flash.delete(:notice)
|
7
|
+
return "$.error_message('" + escape_javascript(flash.delete(:error)) + "');"
|
8
|
+
end
|
9
|
+
unless flash[:success].blank?
|
10
|
+
flash.delete(:notice)
|
11
|
+
return "$.success_message('" + escape_javascript(flash.delete(:success)) + "');"
|
12
|
+
end
|
13
|
+
unless flash[:notice].blank?
|
14
|
+
return "$.notice_message('" + escape_javascript(flash.delete(:notice)) + "');"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def re_pipeline_status re_pipeline
|
19
|
+
case re_pipeline.changed_status
|
20
|
+
when RePipelineBase::CHANGED_STATUS_DRAFT
|
21
|
+
'draft'
|
22
|
+
when RePipelineBase::CHANGED_STATUS_CHANGED
|
23
|
+
'changed'
|
24
|
+
else # RePipelineBase::CHANGED_STATUS_CURRENT
|
25
|
+
'current'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
class ReJob < ActiveRecord::Base
|
2
|
+
|
3
|
+
JOB_STATUS_NONE = 0
|
4
|
+
JOB_STATUS_RUNNING = 1
|
5
|
+
JOB_STATUS_SUCCESS = 2
|
6
|
+
JOB_STATUS_FAILED = 3
|
7
|
+
|
8
|
+
|
9
|
+
has_many :re_job_audits
|
10
|
+
|
11
|
+
validates_presence_of :job_status
|
12
|
+
|
13
|
+
|
14
|
+
def self.find_jobs_by_pipeline re_pipeline_id, options = {}
|
15
|
+
sql_count = <<-END_OF_STRING
|
16
|
+
SELECT COUNT(rej.id) AS total
|
17
|
+
FROM re_jobs rej
|
18
|
+
WHERE rej.id IN (
|
19
|
+
SELECT rejas.re_job_id
|
20
|
+
FROM re_job_audits rejas
|
21
|
+
WHERE rejas.audit_code = #{ReJobAudit::AUDIT_PIPELINE_START}
|
22
|
+
AND rejas.re_pipeline_id = #{re_pipeline_id}
|
23
|
+
)
|
24
|
+
END_OF_STRING
|
25
|
+
|
26
|
+
total_entries = find_by_sql(sql_count).first.total
|
27
|
+
|
28
|
+
paginate re_pipeline_id, options.reverse_merge(:finder => 'find_jobs_by_pipeline_paginate', :offset => 0, :limit => 20, :total_entries => total_entries)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.find_jobs_by_pipeline_paginate re_pipeline_id, options = {:offset=>0, :limit=>100}
|
32
|
+
sql_select = <<-END_OF_STRING
|
33
|
+
SELECT rej.id AS job_id,
|
34
|
+
rej.job_status AS job_status,
|
35
|
+
rej.created_at AS job_date
|
36
|
+
FROM re_jobs rej
|
37
|
+
WHERE rej.id IN (
|
38
|
+
SELECT rejas.re_job_id
|
39
|
+
FROM re_job_audits rejas
|
40
|
+
WHERE rejas.audit_code = #{ReJobAudit::AUDIT_PIPELINE_START}
|
41
|
+
AND rejas.re_pipeline_id = #{re_pipeline_id}
|
42
|
+
)
|
43
|
+
ORDER BY job_date DESC
|
44
|
+
END_OF_STRING
|
45
|
+
|
46
|
+
query = add_limit!(sql_select, :offset => options[:offset], :limit=>options[:limit])
|
47
|
+
|
48
|
+
ActiveRecord::Base.connection.select_all(query).map do | result |
|
49
|
+
|
50
|
+
job_audit = ReJobAudit.find(:all, :conditions => ["re_job_id = ? AND audit_code = ? AND re_pipeline_id = ?", result['job_id'], ReJobAudit::AUDIT_PIPELINE_START, re_pipeline_id], :order => "audit_date ASC", :limit => 1).first
|
51
|
+
result.merge!({
|
52
|
+
'start_date' => job_audit.audit_date,
|
53
|
+
'start_data' => job_audit.audit_data,
|
54
|
+
'start_success' => job_audit.audit_success
|
55
|
+
})
|
56
|
+
|
57
|
+
job_audit = ReJobAudit.find(:all, :conditions => ["re_job_id = ? AND audit_code = ? AND re_pipeline_id = ?", result['job_id'], ReJobAudit::AUDIT_PIPELINE_END, re_pipeline_id], :order => "audit_date ASC", :limit => 1).first
|
58
|
+
if (job_audit)
|
59
|
+
result.merge!({
|
60
|
+
'end_date' => job_audit.audit_date,
|
61
|
+
'end_data' => job_audit.audit_data,
|
62
|
+
'end_success' => job_audit.audit_success
|
63
|
+
})
|
64
|
+
end
|
65
|
+
|
66
|
+
result
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.find_jobs options = {}
|
71
|
+
sql_count = <<-END_OF_STRING
|
72
|
+
SELECT COUNT(rej.id) AS total
|
73
|
+
FROM re_jobs rej
|
74
|
+
WHERE rej.id IN (
|
75
|
+
SELECT rejas.re_job_id
|
76
|
+
FROM re_job_audits rejas
|
77
|
+
WHERE rejas.audit_code = #{ReJobAudit::AUDIT_PIPELINE_START}
|
78
|
+
)
|
79
|
+
END_OF_STRING
|
80
|
+
|
81
|
+
total_entries = find_by_sql(sql_count).first.total
|
82
|
+
|
83
|
+
paginate options.reverse_merge(:finder => 'find_jobs_paginate', :page => 0, :per_page => 20, :total_entries => total_entries)
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.find_jobs_paginate options = {:offset=>0, :limit=>100}
|
87
|
+
sql_select = <<-END_OF_STRING
|
88
|
+
SELECT rej.id AS job_id,
|
89
|
+
rej.job_status AS job_status,
|
90
|
+
rej.created_at AS job_date
|
91
|
+
FROM re_jobs rej
|
92
|
+
WHERE rej.id IN (
|
93
|
+
SELECT rejas.re_job_id
|
94
|
+
FROM re_job_audits rejas
|
95
|
+
WHERE rejas.audit_code = #{ReJobAudit::AUDIT_PIPELINE_START}
|
96
|
+
)
|
97
|
+
ORDER BY job_date DESC
|
98
|
+
END_OF_STRING
|
99
|
+
|
100
|
+
query = add_limit!(sql_select, :offset => options[:offset], :limit=>options[:limit])
|
101
|
+
|
102
|
+
ActiveRecord::Base.connection.select_all(query).map do | result |
|
103
|
+
|
104
|
+
job_audit = ReJobAudit.find(:all, :conditions => ["re_job_id = ? AND audit_code = ?", result['job_id'], ReJobAudit::AUDIT_PIPELINE_START], :order => "audit_date ASC", :limit => 1).first
|
105
|
+
result.merge!({
|
106
|
+
'start_date' => job_audit.audit_date,
|
107
|
+
'start_data' => job_audit.audit_data,
|
108
|
+
'start_success' => job_audit.audit_success
|
109
|
+
})
|
110
|
+
|
111
|
+
job_audit = ReJobAudit.find(:all, :conditions => ["re_job_id = ? AND audit_code = ?", result['job_id'], ReJobAudit::AUDIT_PIPELINE_END], :order => "audit_date DESC", :limit => 1).first
|
112
|
+
if (job_audit)
|
113
|
+
result.merge!({
|
114
|
+
'end_date' => job_audit.audit_date,
|
115
|
+
'end_data' => job_audit.audit_data,
|
116
|
+
'end_success' => job_audit.audit_success
|
117
|
+
})
|
118
|
+
end
|
119
|
+
|
120
|
+
result
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class ReJobAudit < ActiveRecord::Base
|
2
|
+
|
3
|
+
AUDIT_PIPELINE_START = 1
|
4
|
+
AUDIT_PIPELINE_END = 2
|
5
|
+
AUDIT_PIPELINE_INFO = 3
|
6
|
+
AUDIT_RULE_START = 4
|
7
|
+
AUDIT_RULE_END = 5
|
8
|
+
AUDIT_RULE_INFO = 6
|
9
|
+
|
10
|
+
belongs_to :re_job
|
11
|
+
belongs_to :re_pipeline
|
12
|
+
belongs_to :re_rule
|
13
|
+
|
14
|
+
validates_presence_of :audit_date
|
15
|
+
validates_presence_of :audit_code
|
16
|
+
# validates_presence_of :audit_success
|
17
|
+
|
18
|
+
named_scope :by_re_job_id, lambda {|re_job_id| {:conditions => ['re_job_id = ?', re_job_id]} }
|
19
|
+
named_scope :order_date, lambda {|order| {:order => "audit_date #{order}"} }
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
class RePipeline < RePipelineBase
|
2
|
+
|
3
|
+
has_one :activated_re_pipeline, :class_name => "RePipelineActivated",
|
4
|
+
:foreign_key => :parent_re_pipeline_id, :dependent => :destroy
|
5
|
+
|
6
|
+
has_many :re_job_audits
|
7
|
+
|
8
|
+
# before_save :reset_activated_status, :reset_changed_status
|
9
|
+
|
10
|
+
def activate!
|
11
|
+
self.activated_re_pipeline ||= RePipelineActivated.new
|
12
|
+
activated_re_pipeline.copy! self
|
13
|
+
|
14
|
+
self.class.transaction do
|
15
|
+
activated_re_pipeline.save! unless self.new_record?
|
16
|
+
save
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def deactivate!
|
21
|
+
self.activated_re_pipeline.destroy unless activated_re_pipeline.nil?
|
22
|
+
self.activated_re_pipeline = nil
|
23
|
+
self.activated_status = RePipelineBase::ACTIVATED_STATUS_DRAFT
|
24
|
+
save
|
25
|
+
end
|
26
|
+
|
27
|
+
def revert!
|
28
|
+
return if activated_re_pipeline.nil?
|
29
|
+
self.copy!(activated_re_pipeline)
|
30
|
+
save
|
31
|
+
end
|
32
|
+
|
33
|
+
def activated_status
|
34
|
+
if self.activated_re_pipeline.nil?
|
35
|
+
RePipelineBase::ACTIVATED_STATUS_DRAFT
|
36
|
+
else
|
37
|
+
RePipelineBase::ACTIVATED_STATUS_ACTIVE
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def changed_status
|
42
|
+
if self.activated_re_pipeline.nil?
|
43
|
+
RePipelineBase::CHANGED_STATUS_DRAFT
|
44
|
+
elsif !equals?(self.activated_re_pipeline)
|
45
|
+
RePipelineBase::CHANGED_STATUS_CHANGED
|
46
|
+
else
|
47
|
+
RePipelineBase::CHANGED_STATUS_CURRENT
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# private
|
52
|
+
# def reset_activated_status
|
53
|
+
# if self.activated_re_pipeline.nil?
|
54
|
+
# self.activated_status = RePipelineBase::ACTIVATED_STATUS_DRAFT
|
55
|
+
# else
|
56
|
+
# self.activated_status = RePipelineBase::ACTIVATED_STATUS_ACTIVE
|
57
|
+
# end
|
58
|
+
# end
|
59
|
+
#
|
60
|
+
# def reset_changed_status
|
61
|
+
# if self.activated_re_pipeline.nil?
|
62
|
+
# self.changed_status = RePipelineBase::CHANGED_STATUS_DRAFT
|
63
|
+
# elsif !equals?(self.activated_re_pipeline)
|
64
|
+
# self.changed_status = RePipelineBase::CHANGED_STATUS_CHANGED
|
65
|
+
# else
|
66
|
+
# self.changed_status = RePipelineBase::CHANGED_STATUS_CURRENT
|
67
|
+
# end
|
68
|
+
# end
|
69
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class RePipelineActivated < RePipelineBase
|
2
|
+
belongs_to :re_pipeline, :foreign_key => :parent_re_pipeline_id
|
3
|
+
|
4
|
+
def self.find_by_code(code)
|
5
|
+
return find_by_code_without_caching(code) unless RulesEngine::Cache.perform_caching?
|
6
|
+
|
7
|
+
re_pipeline = RulesEngine::Cache.cache_store.read("activated_pipeline_#{code}")
|
8
|
+
if (re_pipeline.nil?)
|
9
|
+
re_pipeline = find_by_code_without_caching(code)
|
10
|
+
|
11
|
+
RulesEngine::Cache.cache_store.write("activated_pipeline_#{code}", re_pipeline)
|
12
|
+
end
|
13
|
+
|
14
|
+
re_pipeline
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.find_by_code_without_caching(code)
|
18
|
+
RePipelineActivated.find(:first, :conditions => ["code = ?", code], :include => :re_rules)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.reset_cache(code)
|
22
|
+
return unless RulesEngine::Cache.perform_caching?
|
23
|
+
RulesEngine::Cache.cache_store.delete("activated_pipeline_#{code}")
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
class RePipelineBase < ActiveRecord::Base
|
2
|
+
set_table_name :re_pipelines
|
3
|
+
|
4
|
+
has_many :re_rules, :foreign_key => :re_pipeline_id, :dependent => :destroy, :order => :position
|
5
|
+
|
6
|
+
ACTIVATED_STATUS_DRAFT = 0
|
7
|
+
ACTIVATED_STATUS_ACTIVE = 1
|
8
|
+
|
9
|
+
CHANGED_STATUS_DRAFT = 0
|
10
|
+
CHANGED_STATUS_CHANGED = 1
|
11
|
+
CHANGED_STATUS_CURRENT = 2
|
12
|
+
|
13
|
+
validates_presence_of :code
|
14
|
+
validates_presence_of :title
|
15
|
+
validates_uniqueness_of :code, :scope => :parent_re_pipeline_id, :case_sensitive => false, :message=>"alread taken."
|
16
|
+
|
17
|
+
named_scope :order_code, :order => 're_pipelines.code ASC'
|
18
|
+
named_scope :order_title, :order => 're_pipelines.title ASC'
|
19
|
+
|
20
|
+
def code=(new_code)
|
21
|
+
self[:code] = new_code.downcase if new_code && new_record?
|
22
|
+
end
|
23
|
+
|
24
|
+
def copy! re_pipeline
|
25
|
+
activated_attrs = re_pipeline.attributes
|
26
|
+
ignore_attributes.each{|key| activated_attrs.delete(key)}
|
27
|
+
|
28
|
+
activated_attrs.each do |key, value|
|
29
|
+
self[key] = value
|
30
|
+
end
|
31
|
+
|
32
|
+
self.re_rules = re_pipeline.re_rules.map { |rule| ReRule.new.copy!(rule) }
|
33
|
+
|
34
|
+
self
|
35
|
+
end
|
36
|
+
|
37
|
+
def equals? re_pipeline
|
38
|
+
activated_attrs = re_pipeline.attributes
|
39
|
+
ignore_attributes.each{|key| activated_attrs.delete(key)}
|
40
|
+
|
41
|
+
activated_attrs.each do |key, value|
|
42
|
+
return false unless self[key] == value
|
43
|
+
end
|
44
|
+
|
45
|
+
return false if (self.re_rules.length != re_pipeline.re_rules.length)
|
46
|
+
self.re_rules.each_with_index do |re_rule, index|
|
47
|
+
return false unless re_rule.equals?(re_pipeline.re_rules[index])
|
48
|
+
end
|
49
|
+
|
50
|
+
true
|
51
|
+
end
|
52
|
+
|
53
|
+
def verify
|
54
|
+
return 'rules required' if re_rules.empty?
|
55
|
+
|
56
|
+
re_rules.each do |rule|
|
57
|
+
result = rule.verify
|
58
|
+
return result unless result.blank?
|
59
|
+
end
|
60
|
+
|
61
|
+
nil
|
62
|
+
end
|
63
|
+
|
64
|
+
protected
|
65
|
+
def ignore_attributes
|
66
|
+
[self.class.primary_key, self.class.inheritance_column, "type", "parent_re_pipeline_id", "activated_status", "changed_status", "created_at", "updated_at"]
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
class ReRule < ActiveRecord::Base
|
2
|
+
belongs_to :re_pipeline
|
3
|
+
acts_as_list :scope => :re_pipeline
|
4
|
+
|
5
|
+
has_many :re_rule_outcomes, :dependent => :destroy, :order => "outcome ASC"
|
6
|
+
has_many :re_job_audits
|
7
|
+
|
8
|
+
validates_associated :re_pipeline
|
9
|
+
validates_presence_of :title
|
10
|
+
validates_presence_of :rule_class
|
11
|
+
validates_presence_of :summary
|
12
|
+
validates_presence_of :data_version
|
13
|
+
validates_presence_of :data
|
14
|
+
|
15
|
+
default_scope :order => 're_rules.position ASC'
|
16
|
+
|
17
|
+
def copy! re_rule
|
18
|
+
activated_attrs = re_rule.attributes
|
19
|
+
ignore_attributes.each{|key| activated_attrs.delete(key)}
|
20
|
+
|
21
|
+
activated_attrs.each do |key, value|
|
22
|
+
self[key] = value
|
23
|
+
end
|
24
|
+
|
25
|
+
self.re_rule_outcomes = re_rule.re_rule_outcomes.map { |rule_outcome| ReRuleOutcome.new.copy!(rule_outcome) }
|
26
|
+
|
27
|
+
self
|
28
|
+
end
|
29
|
+
|
30
|
+
def equals? re_rule
|
31
|
+
activated_attrs = re_rule.attributes
|
32
|
+
ignore_attributes.each{|key| activated_attrs.delete(key)}
|
33
|
+
|
34
|
+
activated_attrs.each do |key, value|
|
35
|
+
return false unless self[key] == value
|
36
|
+
end
|
37
|
+
|
38
|
+
return false unless self.re_rule_outcomes.length == re_rule.re_rule_outcomes.length
|
39
|
+
self.re_rule_outcomes.each_with_index do |rule_outcome, index|
|
40
|
+
return false unless rule_outcome.equals?(re_rule.re_rule_outcomes[index])
|
41
|
+
end
|
42
|
+
|
43
|
+
true
|
44
|
+
end
|
45
|
+
|
46
|
+
def verify
|
47
|
+
return self.error unless self.error.blank?
|
48
|
+
|
49
|
+
self.re_rule_outcomes.each do |rule_outcome|
|
50
|
+
result = rule_outcome.verify
|
51
|
+
return result unless result.blank?
|
52
|
+
end
|
53
|
+
|
54
|
+
nil
|
55
|
+
end
|
56
|
+
|
57
|
+
def re_rule_outcome_next
|
58
|
+
re_rule_outcomes.detect{ |re_rule_outcome| re_rule_outcome.outcome == RulesEngine::RuleOutcome::OUTCOME_NEXT }
|
59
|
+
end
|
60
|
+
|
61
|
+
def re_rule_outcome_success
|
62
|
+
re_rule_outcomes.detect{ |re_rule_outcome| re_rule_outcome.outcome == RulesEngine::RuleOutcome::OUTCOME_STOP_SUCCESS }
|
63
|
+
end
|
64
|
+
|
65
|
+
def re_rule_outcome_failure
|
66
|
+
re_rule_outcomes.detect{ |re_rule_outcome| re_rule_outcome.outcome == RulesEngine::RuleOutcome::OUTCOME_STOP_FAILURE }
|
67
|
+
end
|
68
|
+
|
69
|
+
def re_rule_outcomes_start_pipeline
|
70
|
+
re_rule_outcomes.select{ |re_rule_outcome| re_rule_outcome.outcome == RulesEngine::RuleOutcome::OUTCOME_START_PIPELINE }
|
71
|
+
end
|
72
|
+
|
73
|
+
protected
|
74
|
+
def ignore_attributes
|
75
|
+
[self.class.primary_key, self.class.inheritance_column, "re_pipeline_id", "created_at", "updated_at"]
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
class ReRuleOutcome < ActiveRecord::Base
|
2
|
+
belongs_to :re_rule
|
3
|
+
|
4
|
+
validates_associated :re_rule
|
5
|
+
validates_presence_of :outcome
|
6
|
+
def validate
|
7
|
+
if outcome == RulesEngine::RuleOutcome::OUTCOME_START_PIPELINE && pipeline_code.blank?
|
8
|
+
errors.add(:pipeline_code, "pipeline code required")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def copy! re_rule_outcome
|
13
|
+
self.outcome = re_rule_outcome.outcome
|
14
|
+
self.pipeline_code = re_rule_outcome.pipeline_code
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
def equals? re_rule_outcome
|
19
|
+
if outcome != re_rule_outcome.outcome
|
20
|
+
return false
|
21
|
+
end
|
22
|
+
|
23
|
+
if outcome == RulesEngine::RuleOutcome::OUTCOME_START_PIPELINE
|
24
|
+
return false unless pipeline_code == re_rule_outcome.pipeline_code
|
25
|
+
#TODO check the pipeline equals the pipeline code
|
26
|
+
end
|
27
|
+
|
28
|
+
return true
|
29
|
+
end
|
30
|
+
|
31
|
+
def verify
|
32
|
+
if outcome == RulesEngine::RuleOutcome::OUTCOME_START_PIPELINE
|
33
|
+
return "pipeline code required" if pipeline_code.blank?
|
34
|
+
return "outcome pipeline missing" unless RePipeline.find(:first, :conditions => ["code = ?", pipeline_code])
|
35
|
+
end
|
36
|
+
|
37
|
+
return nil
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
class BlacklistWord < RulesEngine::Rule
|
2
|
+
|
3
|
+
BLACKLIST_WORD_VERSION = 1.0
|
4
|
+
|
5
|
+
self.options =
|
6
|
+
{
|
7
|
+
:group => 'Sample Rules',
|
8
|
+
:name => 'Blacklist Words',
|
9
|
+
:description => 'Perform a specifc action if the following words are found',
|
10
|
+
:help_template => '/re_rule_definitions/blacklist_word/help',
|
11
|
+
:new_template => '/re_rule_definitions/blacklist_word/new',
|
12
|
+
:edit_template => '/re_rule_definitions/blacklist_word/edit'
|
13
|
+
}
|
14
|
+
|
15
|
+
attr_reader :title
|
16
|
+
attr_reader :words
|
17
|
+
attr_reader :pipeline_action
|
18
|
+
attr_reader :pipeline
|
19
|
+
|
20
|
+
def attributes=(params)
|
21
|
+
@words = []
|
22
|
+
@title = params['blacklist_word_title']
|
23
|
+
|
24
|
+
return if params['blacklist_word'].nil?
|
25
|
+
params['blacklist_word'].each do |key, value|
|
26
|
+
@words << value['word'].downcase unless value['word'].blank? || value['_delete'] == '1'
|
27
|
+
end
|
28
|
+
|
29
|
+
@pipeline_action = params['blacklist_word_pipeline_action'] || 'continue'
|
30
|
+
@pipeline = params['blacklist_word_pipeline'] || ''
|
31
|
+
end
|
32
|
+
|
33
|
+
def valid?
|
34
|
+
self.errors << "At least one word must be defined" if @words.nil? || @words.empty?
|
35
|
+
self.errors << "Title required" if @title.blank?
|
36
|
+
self.errors << "Pipeline required" if @pipeline_action == 'start_pipeline' && @pipeline.blank?
|
37
|
+
return self.errors.empty?
|
38
|
+
end
|
39
|
+
|
40
|
+
def load(re_rule)
|
41
|
+
return false unless super
|
42
|
+
|
43
|
+
@title = re_rule.title
|
44
|
+
@words, @pipeline_action, @pipeline = ActiveSupport::JSON.decode(re_rule.data)
|
45
|
+
true
|
46
|
+
end
|
47
|
+
|
48
|
+
def save(re_rule)
|
49
|
+
return false unless super
|
50
|
+
|
51
|
+
re_rule.title = @title
|
52
|
+
re_rule.summary = "Exclude #{@words.size} #{@words.size == 1 ? 'word' : 'words'}"
|
53
|
+
re_rule.data_version = BLACKLIST_WORD_VERSION
|
54
|
+
re_rule.data = [@words, @pipeline_action, @pipeline].to_json
|
55
|
+
re_rule.error = nil
|
56
|
+
|
57
|
+
# save rule outcomes
|
58
|
+
if @pipeline_action == 'next'
|
59
|
+
re_rule.re_rule_outcomes = [ReRuleOutcome.new(:outcome => RulesEngine::RuleOutcome::OUTCOME_NEXT)]
|
60
|
+
elsif @pipeline_action == 'stop_success'
|
61
|
+
re_rule.re_rule_outcomes = [ReRuleOutcome.new(:outcome => RulesEngine::RuleOutcome::OUTCOME_STOP_SUCCESS)]
|
62
|
+
elsif @pipeline_action == 'stop_failure'
|
63
|
+
re_rule.re_rule_outcomes = [ReRuleOutcome.new(:outcome => RulesEngine::RuleOutcome::OUTCOME_STOP_FAILURE)]
|
64
|
+
else # if @pipeline_action == 'start_pipeline'
|
65
|
+
re_rule.re_rule_outcomes = [ReRuleOutcome.new(:outcome => RulesEngine::RuleOutcome::OUTCOME_START_PIPELINE,
|
66
|
+
:pipeline_code => @pipeline)]
|
67
|
+
end
|
68
|
+
|
69
|
+
true
|
70
|
+
end
|
71
|
+
|
72
|
+
def process(job_id, data)
|
73
|
+
rule_outcome = RulesEngine::RuleOutcome.new
|
74
|
+
|
75
|
+
if @pipeline_action == 'next'
|
76
|
+
rule_outcome.outcome = RulesEngine::RuleOutcome::OUTCOME_NEXT
|
77
|
+
elsif @pipeline_action == 'stop_success'
|
78
|
+
rule_outcome.outcome = RulesEngine::RuleOutcome::OUTCOME_STOP_SUCCESS
|
79
|
+
elsif @pipeline_action == 'stop_failure'
|
80
|
+
rule_outcome.outcome = RulesEngine::RuleOutcome::OUTCOME_STOP_FAILURE
|
81
|
+
else # if @pipeline_action == 'start_pipeline'
|
82
|
+
rule_outcome.outcome = RulesEngine::RuleOutcome::OUTCOME_START_PIPELINE
|
83
|
+
rule_outcome.pipeline_code = @pipeline
|
84
|
+
end
|
85
|
+
|
86
|
+
rule_outcome
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
class Simple < RulesEngine::Rule
|
2
|
+
|
3
|
+
SIMPLE_VERSION = 1.0
|
4
|
+
|
5
|
+
self.options =
|
6
|
+
{
|
7
|
+
:group => 'Sample Rules',
|
8
|
+
:name => 'Simple Rule',
|
9
|
+
:description => 'Does nothing',
|
10
|
+
:help_template => '/re_rule_definitions/simple/help',
|
11
|
+
:new_template => '/re_rule_definitions/simple/new',
|
12
|
+
:edit_template => '/re_rule_definitions/simple/edit'
|
13
|
+
}
|
14
|
+
|
15
|
+
attr_reader :title
|
16
|
+
|
17
|
+
def attributes=(params)
|
18
|
+
@title = params['simple_title']
|
19
|
+
end
|
20
|
+
|
21
|
+
def valid?
|
22
|
+
self.errors << "Title required" if @title.blank?
|
23
|
+
return self.errors.empty?
|
24
|
+
end
|
25
|
+
|
26
|
+
def load(re_rule)
|
27
|
+
return false unless super
|
28
|
+
|
29
|
+
@title = re_rule.title
|
30
|
+
true
|
31
|
+
end
|
32
|
+
|
33
|
+
def save(re_rule)
|
34
|
+
return false unless super
|
35
|
+
|
36
|
+
re_rule.title = @title
|
37
|
+
re_rule.summary = "Simple Rule : Does Nothing"
|
38
|
+
re_rule.data_version = SIMPLE_VERSION
|
39
|
+
re_rule.data = ["ignore"].to_json
|
40
|
+
re_rule.error = nil
|
41
|
+
true
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
class <%= rule_class %> < RulesEngine::Rule
|
2
|
+
|
3
|
+
<%=rule_name.upcase %>_VERSION = 1.0
|
4
|
+
|
5
|
+
self.options =
|
6
|
+
{
|
7
|
+
:group => 'Sample Rules',
|
8
|
+
:name => '<%=rule_class %> Rule',
|
9
|
+
:description => 'Does nothing',
|
10
|
+
:help_template => '/re_rule_definitions/<%=rule_name %>/help',
|
11
|
+
:new_template => '/re_rule_definitions/<%=rule_name %>/new',
|
12
|
+
:edit_template => '/re_rule_definitions/<%=rule_name %>/edit'
|
13
|
+
}
|
14
|
+
|
15
|
+
attr_reader :title
|
16
|
+
|
17
|
+
def attributes=(params)
|
18
|
+
@title = params['<%=rule_name %>_title']
|
19
|
+
end
|
20
|
+
|
21
|
+
def valid?
|
22
|
+
self.errors << "Title required" if @title.blank?
|
23
|
+
return self.errors.empty?
|
24
|
+
end
|
25
|
+
|
26
|
+
def load(re_rule)
|
27
|
+
return false unless super
|
28
|
+
|
29
|
+
@title = re_rule.title
|
30
|
+
true
|
31
|
+
end
|
32
|
+
|
33
|
+
def save(re_rule)
|
34
|
+
return false unless super
|
35
|
+
|
36
|
+
re_rule.title = @title
|
37
|
+
re_rule.summary = "<%=rule_class %> Rule : Does Nothing"
|
38
|
+
re_rule.data_version = <%=rule_name.upcase%>_VERSION
|
39
|
+
re_rule.data = ["ignore"].to_json
|
40
|
+
re_rule.error = nil
|
41
|
+
true
|
42
|
+
end
|
43
|
+
|
44
|
+
##################################################################
|
45
|
+
# return an RulesEngine::RuleOutcome object to define what to do next
|
46
|
+
# or nil to continue to the next rule
|
47
|
+
def process(job_id, data)
|
48
|
+
nil
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<% local_hide = local_assigns[:hide] && hide %>
|
2
|
+
|
3
|
+
<div id="job_list_empty" style="<%= local_hide ? 'display:none' : '' %>">
|
4
|
+
<div class="redbox-header"><h4 class="white">No Jobs Created</h4></div>
|
5
|
+
<div class="redbox no-top">
|
6
|
+
<h4 class="left-5">Jobs are added when run.</h4>
|
7
|
+
</div>
|
8
|
+
<div class="clear"></div>
|
9
|
+
</div>
|
10
|
+
<div class="clear"></div>
|
11
|
+
|