Class: Dor::WorkflowDs
- Inherits:
-
ActiveFedora::OmDatastream
- Object
- ActiveFedora::OmDatastream
- Dor::WorkflowDs
- Includes:
- SolrDocHelper
- Defined in:
- lib/dor/datastreams/workflow_ds.rb
Overview
TODO: class docs
Instance Method Summary collapse
- #content ⇒ Object
-
#current_priority ⇒ Integer
Finds the first workflow that is expedited, then returns the value of its priority.
- #ensure_xml_loaded ⇒ Object
- #get_workflow(wf, repo = 'dor') ⇒ Object (also: #[])
- #graph(dir = nil) ⇒ Object
-
#initialize(*args) ⇒ WorkflowDs
constructor
A new instance of WorkflowDs.
- #ng_xml ⇒ Object
- #to_solr(solr_doc = {}, *args) ⇒ Object
- #workflows ⇒ Object
Methods included from SolrDocHelper
Constructor Details
#initialize(*args) ⇒ WorkflowDs
Returns a new instance of WorkflowDs.
21 22 23 24 |
# File 'lib/dor/datastreams/workflow_ds.rb', line 21 def initialize(*args) self.field_mapper = UtcDateFieldMapper.new super end |
Instance Method Details
#content ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/dor/datastreams/workflow_ds.rb', line 44 def content @content ||= Dor::WorkflowService.get_workflow_xml 'dor', pid, nil rescue RestClient::ResourceNotFound xml = Nokogiri::XML(%(<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<workflows objectId="#{pid}"/>)) digital_object.datastreams.keys.each do |dsid| next unless dsid =~ /WF$/ ds_content = Nokogiri::XML(Dor::WorkflowService.get_workflow_xml 'dor', pid, dsid) xml.root.add_child(ds_content.root) end @content ||= xml.to_xml end |
#current_priority ⇒ Integer
Finds the first workflow that is expedited, then returns the value of its priority
76 77 78 79 80 |
# File 'lib/dor/datastreams/workflow_ds.rb', line 76 def current_priority cp = workflows.detect &:expedited? return 0 if cp.nil? cp.priority.to_i end |
#ensure_xml_loaded ⇒ Object
35 36 37 38 |
# File 'lib/dor/datastreams/workflow_ds.rb', line 35 def ensure_xml_loaded ng_xml self.xml_loaded = true end |
#get_workflow(wf, repo = 'dor') ⇒ Object Also known as: []
26 27 28 29 30 31 |
# File 'lib/dor/datastreams/workflow_ds.rb', line 26 def get_workflow(wf, repo = 'dor') xml = Dor::WorkflowService.get_workflow_xml(repo, pid, wf) xml = Nokogiri::XML(xml) return nil if xml.xpath('workflow').length == 0 Workflow::Document.new(xml.to_s) end |
#graph(dir = nil) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/dor/datastreams/workflow_ds.rb', line 60 def graph(dir = nil) result = GraphViz.digraph(pid) sg = result.add_graph('rank') { |g| g[:rank => 'same'] } workflows.each do |wf| unless wf.nil? g = wf.graph(result) sg.add_node(g.root.id) unless g.nil? end end result['rankdir'] = dir || 'TB' result end |
#ng_xml ⇒ Object
40 41 42 |
# File 'lib/dor/datastreams/workflow_ds.rb', line 40 def ng_xml @ng_xml ||= Nokogiri::XML::Document.parse(content) end |
#to_solr(solr_doc = {}, *args) ⇒ Object
82 83 84 85 86 |
# File 'lib/dor/datastreams/workflow_ds.rb', line 82 def to_solr(solr_doc = {}, *args) # super solr_doc, *args workflows.each { |wf| wf.to_solr(solr_doc, *args) } solr_doc end |