Class: Dor::WorkflowDs
- Inherits:
-
ActiveFedora::OmDatastream
- Object
- ActiveFedora::OmDatastream
- Dor::WorkflowDs
- Defined in:
- lib/dor/datastreams/workflow_ds.rb
Overview
TODO: class docs
Instance Method Summary collapse
-
#content(refresh = false) ⇒ Object
service.
-
#current_priority ⇒ Integer
Finds the first workflow that is expedited, then returns the value of its priority.
- #get_workflow(wf, repo = 'dor') ⇒ Object (also: #[])
- #graph(dir = nil) ⇒ Object
- #ng_xml ⇒ Object
- #to_solr(solr_doc = {}, *args) ⇒ Object
- #workflows ⇒ Object
Instance Method Details
#content(refresh = false) ⇒ Object
service. This flag will invalidate the cached content and refetch it from the workflow service directly
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/dor/datastreams/workflow_ds.rb', line 36 def content(refresh = false) @content = nil if refresh @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
67 68 69 70 71 |
# File 'lib/dor/datastreams/workflow_ds.rb', line 67 def current_priority cp = workflows.detect &:expedited? return 0 if cp.nil? cp.priority.to_i end |
#get_workflow(wf, repo = 'dor') ⇒ Object Also known as: []
20 21 22 23 24 25 |
# File 'lib/dor/datastreams/workflow_ds.rb', line 20 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
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/dor/datastreams/workflow_ds.rb', line 53 def graph(dir = nil) result = GraphViz.digraph(pid) sg = result.add_graph('rank') { |g| g[:rank => 'same'] } workflows.reject(&:nil?).each do |wf| g = wf.graph(result) sg.add_node(g.root.id) unless g.nil? end result['rankdir'] = dir || 'TB' result end |
#ng_xml ⇒ Object
29 30 31 |
# File 'lib/dor/datastreams/workflow_ds.rb', line 29 def ng_xml @ng_xml ||= Nokogiri::XML::Document.parse(content) end |
#to_solr(solr_doc = {}, *args) ⇒ Object
73 74 75 76 77 |
# File 'lib/dor/datastreams/workflow_ds.rb', line 73 def to_solr(solr_doc = {}, *args) # super solr_doc, *args workflows.each { |wf| wf.to_solr(solr_doc, *args) } solr_doc end |