class Dor::EmbargoMetadataDS
Public Class Methods
xml_template()
click to toggle source
Default EmbargoMetadataDS
xml
# File lib/dor/datastreams/embargo_metadata_ds.rb, line 23 def self.xml_template builder = Nokogiri::XML::Builder.new do |xml| xml.embargoMetadata do xml.status xml.releaseDate xml.releaseAccess xml.twentyPctVisibilityStatus xml.twentyPctVisibilityReleaseDate end end builder.doc end
Public Instance Methods
ensure_non_versionable()
click to toggle source
# File lib/dor/datastreams/embargo_metadata_ds.rb, line 44 def ensure_non_versionable self.versionable = 'false' end
prefix()
click to toggle source
maintain AF < 8 indexing behavior
# File lib/dor/datastreams/embargo_metadata_ds.rb, line 98 def prefix '' end
release_access_node()
click to toggle source
@return [Nokogiri::XML::Element] The releaseAccess node
# File lib/dor/datastreams/embargo_metadata_ds.rb, line 83 def release_access_node find_by_terms(:release_access).first end
release_access_node=(new_doc)
click to toggle source
Sets the embargaAccess node @param [Nokogiri::XML::Document] new_doc Document that will replace the existing releaseAccess node
# File lib/dor/datastreams/embargo_metadata_ds.rb, line 89 def release_access_node=(new_doc) raise 'Trying to replace releaseAccess with a non-releaseAccess document' if new_doc.root.name != 'releaseAccess' term_value_delete(select: '//embargoMetadata/releaseAccess') ng_xml_will_change! ng_xml.root.add_child(new_doc.root.clone) end
status()
click to toggle source
# File lib/dor/datastreams/embargo_metadata_ds.rb, line 57 def status term_values(:status).first end
status=(new_status)
click to toggle source
Convenience methods to get and set embargo properties Hides complexity/verbosity of OM TermOperators for simple, non-repeating values
# File lib/dor/datastreams/embargo_metadata_ds.rb, line 53 def status=(new_status) update_values([:status] => new_status) end
to_solr(solr_doc = {}, *args)
click to toggle source
Calls superclass method
# File lib/dor/datastreams/embargo_metadata_ds.rb, line 36 def to_solr(solr_doc = {}, *args) solr_doc = super rd20 = twenty_pct_release_date ::Solrizer.insert_field(solr_doc, 'embargo_release', release_date.first.utc.strftime('%FT%TZ'), :dateable) unless release_date.first.blank? ::Solrizer.insert_field(solr_doc, 'twenty_pct_visibility_release', rd20.utc.strftime('%FT%TZ'), :dateable) unless rd20.blank? solr_doc end
twenty_pct_release_date()
click to toggle source
Current twentyPctVisibilityReleaseDate value @return [Time]
# File lib/dor/datastreams/embargo_metadata_ds.rb, line 77 def twenty_pct_release_date rd = term_values(:twenty_pct_release_date).first rd.nil? || rd.empty? ? nil : Time.parse(rd) end
twenty_pct_release_date=(rd = Time.now.utc)
click to toggle source
Sets the 20% visibility release date. Converts the date to beginning-of-day, UTC to help with Solr indexing @param [Time] rd A Time object represeting the release date. By default, it is set to now
# File lib/dor/datastreams/embargo_metadata_ds.rb, line 71 def twenty_pct_release_date=(rd = Time.now.utc) update_values([:twenty_pct_release_date] => rd.beginning_of_day.utc.xmlschema) end
twenty_pct_status()
click to toggle source
# File lib/dor/datastreams/embargo_metadata_ds.rb, line 65 def twenty_pct_status term_values(:twenty_pct_status).first end
twenty_pct_status=(new_status)
click to toggle source
# File lib/dor/datastreams/embargo_metadata_ds.rb, line 61 def twenty_pct_status=(new_status) update_values([:twenty_pct_status] => new_status) end