Class: Dor::WorkflowObject

Inherits:
Abstract
  • Object
show all
Defined in:
lib/dor/models/workflow_object.rb

Constant Summary collapse

@@xml_cache =
{}
@@repo_cache =
{}

Constants included from Processable

Processable::STATUS_CODE_DISP_TXT, Processable::STEPS

Constants included from Describable

Describable::MODS_TO_DC_XSLT, Describable::XMLNS_DC, Describable::XMLNS_OAI_DC

Constants included from Identifiable

Identifiable::CATKEY_TYPE_ID, Identifiable::PREVIOUS_CATKEY_TYPE_ID

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Preservable

#build_provenanceMetadata_datastream, #build_technicalMetadata_datastream, #create_workflow_provenance, #sdr_ingest_transfer

Methods included from Processable

#build_datastream, #cleanup, #create_workflow, #empty_datastream?, #find_metadata_file, #initialize_workflow, #milestones, #set_workflows_datastream_location, #simplified_status_code_disp_txt, #status, #status_info, #to_solr

Methods included from SolrDocHelper

#add_solr_value

Methods included from Versionable

#allows_modification?, #close_version, #current_version, #new_version_open?, #open_new_version

Methods included from Describable

#add_metadata_format_to_solr_doc, #add_mods_to_solr_doc, #build_descMetadata_datastream, #fetch_descMetadata_datastream, #full_title, #generate_dublin_core, #generate_public_desc_md, get_collection_title, #set_desc_metadata_using_label, #stanford_mods, #to_solr

Methods included from Rightsable

#build_rightsMetadata_datastream, #world_doc

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, #unshelve_and_unpublish

Methods included from Eventable

#add_event

Methods included from Identifiable

#adapt_to_cmodel, #add_other_Id, #add_tag, #catkey, #catkey=, #content_type_tag, #druid_regex, #get_related_obj_display_title, #identity_metadata_source, #initialize, #normalize_tag, #normalize_tag_arr, #pid_regex, #previous_catkeys, #remove_druid_prefix, #remove_other_Id, #remove_tag, #source_id, #source_id=, #split_tag_to_arr, #tags, #to_solr, #update_other_Id, #update_tag, #validate_and_normalize_tag, #validate_tag_format

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

Parameters:

  • name (String)

    the name of the workflow

Returns:

  • (Object)

    a Dor::xxxx object, e.g. a Dor::Item object



53
54
55
56
57
58
59
# File 'lib/dor/models/workflow_object.rb', line 53

def self.find_and_cache_workflow_xml_and_repo(name)
  wobj = find_by_name(name)
  raise "Failed to find workflow via find_by_name('#{name}')" if wobj.nil?
  @@repo_cache[name] = wobj.definition.repo
  @@xml_cache[name]  = wobj.generate_initial_workflow
  wobj
end

.find_by_name(name) ⇒ Object



11
12
13
# File 'lib/dor/models/workflow_object.rb', line 11

def self.find_by_name(name)
  Dor::WorkflowObject.where(Solrizer.solr_name('workflow_name', :symbol) => name).first
end

.initial_repo(name) ⇒ String

Returns the repository attribute from the workflow definition It will cache the result for subsequent requests

Parameters:

  • name (String)

    the name of the workflow

Returns:

  • (String)

    the initial workflow xml



30
31
32
33
34
# File 'lib/dor/models/workflow_object.rb', line 30

def self.initial_repo(name)
  return @@repo_cache[name] if @@repo_cache.include?(name)
  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

Parameters:

  • name (String)

    the name of the workflow

Returns:

  • (String)

    the initial workflow xml



20
21
22
23
24
# File 'lib/dor/models/workflow_object.rb', line 20

def self.initial_workflow(name)
  return @@xml_cache[name] if @@xml_cache.include?(name)
  find_and_cache_workflow_xml_and_repo name
  @@xml_cache[name]
end

Instance Method Details

#definitionObject



36
37
38
# File 'lib/dor/models/workflow_object.rb', line 36

def definition
  datastreams['workflowDefinition']
end

#generate_initial_workflowObject Also known as: generate_intial_workflow



44
45
46
# File 'lib/dor/models/workflow_object.rb', line 44

def generate_initial_workflow
  datastreams['workflowDefinition'].initial_workflow
end

#graph(*args) ⇒ Object



40
41
42
# File 'lib/dor/models/workflow_object.rb', line 40

def graph(*args)
  definition.graph *args
end