Class: Dor::WorkflowObject
- Inherits:
-
ActiveFedora::Base
- Object
- ActiveFedora::Base
- Dor::WorkflowObject
- Includes:
- Governable, Identifiable, SolrDocHelper
- Defined in:
- lib/dor/models/workflow_object.rb
Constant Summary collapse
- @@xml_cache =
{}
- @@repo_cache =
{}
Class Method Summary collapse
-
.find_and_cache_workflow_xml_and_repo(name) ⇒ Object
Searches DOR for the workflow definition object.
- .find_by_name(name, opts = {}) ⇒ Object
-
.initial_repo(name) ⇒ String
Returns the repository attribute from the workflow definition It will cache the result for subsequent requests.
-
.initial_workflow(name) ⇒ String
Searches for the workflow definition object in DOR, then returns an object’s initial workflow as defined in the worfklowDefinition datastream It will cache the result for subsequent requests.
Instance Method Summary collapse
- #definition ⇒ Object
- #generate_initial_workflow ⇒ Object (also: #generate_intial_workflow)
- #graph(*args) ⇒ Object
- #to_solr(solr_doc = Hash.new, *args) ⇒ Object
Methods included from Governable
#add_collection, #can_manage_content?, #can_manage_desc_metadata?, #can_manage_embargo?, #can_manage_item?, #can_manage_rights?, #can_manage_system_metadata?, #can_view_content?, #can_view_metadata?, #default_workflow_lane, #groups_which_manage_content, #groups_which_manage_desc_metadata, #groups_which_manage_embargo, #groups_which_manage_item, #groups_which_manage_rights, #groups_which_manage_system_metadata, #groups_which_view_content, #groups_which_view_metadata, #initiate_apo_workflow, #intersect, #reapplyAdminPolicyObjectDefaults, #remove_collection, #reset_to_apo_default, #rights, #set_read_rights
Methods included from SolrDocHelper
Methods included from Identifiable
#add_other_Id, #add_tag, #content_type_tag, #initialize, #method_missing, #normalize_tag, #normalize_tag_arr, #remove_displayTypes, #remove_other_Id, #remove_tag, #set_source_id, #split_tag_to_arr, #tags, #update_other_Id, #update_tag, #validate_and_normalize_tag, #validate_tag_format
Methods included from Upgradable
add_upgrade_callback, included, run_upgrade_callbacks, #upgrade!
Methods included from Eventable
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Dor::Identifiable
Class Method Details
.find_and_cache_workflow_xml_and_repo(name) ⇒ Object
Searches DOR for the workflow definition object. It then caches the workflow repository and xml
66 67 68 69 70 71 |
# File 'lib/dor/models/workflow_object.rb', line 66 def self.find_and_cache_workflow_xml_and_repo name wobj = self.find_by_name(name) wf_xml = wobj.generate_initial_workflow @@repo_cache[name] = wobj.definition.repo @@xml_cache[name] = wf_xml end |
.find_by_name(name, opts = {}) ⇒ Object
14 15 16 |
# File 'lib/dor/models/workflow_object.rb', line 14 def self.find_by_name(name, opts={}) Dor.find_all(%{objectType_t:"#{self.object_type}" workflow_name_s:"#{name}"}, opts).first end |
.initial_repo(name) ⇒ String
Returns the repository attribute from the workflow definition It will cache the result for subsequent requests
34 35 36 37 38 39 |
# File 'lib/dor/models/workflow_object.rb', line 34 def self.initial_repo(name) return @@repo_cache[name] if(@@repo_cache.include?(name)) self.find_and_cache_workflow_xml_and_repo name @@repo_cache[name] end |
.initial_workflow(name) ⇒ String
Searches for the workflow definition object in DOR, then returns an object’s initial workflow as defined in the worfklowDefinition datastream It will cache the result for subsequent requests
23 24 25 26 27 28 |
# File 'lib/dor/models/workflow_object.rb', line 23 def self.initial_workflow(name) return @@xml_cache[name] if(@@xml_cache.include?(name)) self.find_and_cache_workflow_xml_and_repo name @@xml_cache[name] end |
Instance Method Details
#definition ⇒ Object
41 42 43 |
# File 'lib/dor/models/workflow_object.rb', line 41 def definition datastreams['workflowDefinition'] end |
#generate_initial_workflow ⇒ Object Also known as: generate_intial_workflow
58 59 60 |
# File 'lib/dor/models/workflow_object.rb', line 58 def generate_initial_workflow datastreams['workflowDefinition'].initial_workflow end |
#graph(*args) ⇒ Object
45 46 47 |
# File 'lib/dor/models/workflow_object.rb', line 45 def graph *args self.definition.graph *args end |
#to_solr(solr_doc = Hash.new, *args) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/dor/models/workflow_object.rb', line 49 def to_solr solr_doc=Hash.new, *args super solr_doc, *args client = Dor::WorkflowService.workflow_resource xml = client["workflow_archive?repository=#{definition.repo}&workflow=#{definition.name}&count-only=true"].get count = Nokogiri::XML(xml).at_xpath('/objects/@count').value add_solr_value(solr_doc,"#{definition.name}_archived",count,:integer,[:displayable]) solr_doc end |