Class: Dor::WorkflowDs
- Inherits:
-
ActiveFedora::OmDatastream
- Object
- ActiveFedora::OmDatastream
- Dor::WorkflowDs
- Defined in:
- lib/dor/datastreams/workflow_ds.rb
Overview
TODO: class docs
Class Method Summary collapse
-
.default_attributes ⇒ Object
Called by rubydora.
Instance Method Summary collapse
-
#build_location ⇒ Object
Called before saving, but after a pid has been assigned.
-
#content(refresh = false) ⇒ Object
service.
-
#current_priority ⇒ Integer
Finds the first workflow that is expedited, then returns the value of its priority.
- #ng_xml ⇒ Object
-
#prefix ⇒ Object
maintain AF < 8 indexing behavior.
- #to_solr(solr_doc = {}, *_args) ⇒ Object
- #workflows ⇒ Object
Class Method Details
.default_attributes ⇒ Object
Called by rubydora. This lets us customize the mime-type
30 31 32 |
# File 'lib/dor/datastreams/workflow_ds.rb', line 30 def self.default_attributes super.merge(mimeType: 'application/xml') end |
Instance Method Details
#build_location ⇒ Object
Called before saving, but after a pid has been assigned
23 24 25 26 27 |
# File 'lib/dor/datastreams/workflow_ds.rb', line 23 def build_location return unless new? self.dsLocation = File.join(Dor::Config.workflow.url, "dor/objects/#{pid}/workflows") end |
#content(refresh = false) ⇒ Object
service. This flag will invalidate the cached content and refetch it from the workflow service directly
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/dor/datastreams/workflow_ds.rb', line 41 def content(refresh = false) @content = nil if refresh @content ||= Dor::Config.workflow.client.all_workflows_xml pid rescue Dor::WorkflowException => e # TODO: I don't understand when this would be useful as this block ends up calling the workflow service too. # Why not just raise an exception here? Dor.logger.warn "Unable to connect to the workflow service #{e}. Falling back to placeholder XML" 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::Config.workflow.client.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
65 66 67 68 69 70 |
# File 'lib/dor/datastreams/workflow_ds.rb', line 65 def current_priority cp = workflows.detect(&:expedited?) return 0 if cp.nil? cp.priority.to_i end |
#ng_xml ⇒ Object
34 35 36 |
# File 'lib/dor/datastreams/workflow_ds.rb', line 34 def ng_xml @ng_xml ||= Nokogiri::XML::Document.parse(content) end |
#prefix ⇒ Object
maintain AF < 8 indexing behavior
78 79 80 |
# File 'lib/dor/datastreams/workflow_ds.rb', line 78 def prefix '' end |
#to_solr(solr_doc = {}, *_args) ⇒ Object
72 73 74 75 |
# File 'lib/dor/datastreams/workflow_ds.rb', line 72 def to_solr(solr_doc = {}, *_args) # noop - indexing is done by the WorkflowsIndexer solr_doc end |