Class: Dor::WorkflowDefinitionDs
- Inherits:
-
ActiveFedora::OmDatastream
- Object
- ActiveFedora::OmDatastream
- Dor::WorkflowDefinitionDs
- Includes:
- SolrDocHelper
- Defined in:
- lib/dor/datastreams/workflow_definition_ds.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_process(attributes) ⇒ Object
-
#initial_workflow ⇒ String
Creates the xml used by Dor::WorkflowService#create_workflow.
- #name ⇒ Object
-
#prefix ⇒ Object
maintain AF < 8 indexing behavior.
- #processes ⇒ Object
- #repo ⇒ Object
- #to_solr(solr_doc = {}, *args) ⇒ Object
Methods included from SolrDocHelper
Class Method Details
.xml_template ⇒ Object
31 32 33 |
# File 'lib/dor/datastreams/workflow_definition_ds.rb', line 31 def self.xml_template Nokogiri::XML('<workflow-def/>') end |
Instance Method Details
#add_process(attributes) ⇒ Object
35 36 37 38 |
# File 'lib/dor/datastreams/workflow_definition_ds.rb', line 35 def add_process(attributes) ng_xml_will_change! add_child_node(ng_xml.at_xpath('/workflow-def'), :process, self, attributes) end |
#initial_workflow ⇒ String
Creates the xml used by Dor::WorkflowService#create_workflow
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/dor/datastreams/workflow_definition_ds.rb', line 56 def initial_workflow doc = Nokogiri::XML('<workflow/>') root = doc.root root['id'] = name processes.each { |proc| doc.create_element 'process' do |node| node['name'] = proc.name if proc.status node['status'] = proc.status node['attempts'] = '1' else node['status'] = 'waiting' end node['lifecycle'] = proc.lifecycle if proc.lifecycle root.add_child node end } Nokogiri::XML(doc.to_xml) { |x| x.noblanks }.to_xml { |config| config.no_declaration } end |
#name ⇒ Object
46 47 48 |
# File 'lib/dor/datastreams/workflow_definition_ds.rb', line 46 def name ng_xml.at_xpath('/workflow-def/@id').to_s end |
#prefix ⇒ Object
maintain AF < 8 indexing behavior
86 87 88 |
# File 'lib/dor/datastreams/workflow_definition_ds.rb', line 86 def prefix '' end |
#processes ⇒ Object
40 41 42 43 44 |
# File 'lib/dor/datastreams/workflow_definition_ds.rb', line 40 def processes ng_xml.xpath('/workflow-def/process').collect do |node| Workflow::Process.new(repo, name, node) end.sort { |a, b| (a.sequence || 0) <=> (b.sequence || 0) } end |
#repo ⇒ Object
50 51 52 |
# File 'lib/dor/datastreams/workflow_definition_ds.rb', line 50 def repo ng_xml.at_xpath('/workflow-def/@repository').to_s end |
#to_solr(solr_doc = {}, *args) ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/dor/datastreams/workflow_definition_ds.rb', line 76 def to_solr(solr_doc = {}, *args) solr_doc = super(solr_doc, *args) add_solr_value(solr_doc, 'workflow_name', name, :symbol, [:symbol]) processes.each do |p| add_solr_value(solr_doc, 'process', "#{p.name}|#{p.label}", :symbol, [:displayable]) end solr_doc end |