Class: Dor::EmbargoMetadataDS
- Inherits:
-
ActiveFedora::OmDatastream
- Object
- ActiveFedora::OmDatastream
- Dor::EmbargoMetadataDS
- Defined in:
- lib/dor/datastreams/embargo_metadata_ds.rb
Class Method Summary collapse
-
.xml_template ⇒ Object
Default EmbargoMetadataDS xml.
Instance Method Summary collapse
- #ensure_non_versionable ⇒ Object
-
#prefix ⇒ Object
maintain AF < 8 indexing behavior.
-
#release_access_node ⇒ Nokogiri::XML::Element
The releaseAccess node.
-
#release_access_node=(new_doc) ⇒ Object
Sets the embargaAccess node.
-
#release_date ⇒ Time
Current releaseDate value.
-
#release_date=(rd = Time.now.utc) ⇒ Object
Sets the release date.
- #status ⇒ Object
-
#status=(new_status) ⇒ Object
Convenience methods to get and set embargo properties Hides complexity/verbosity of OM TermOperators for simple, non-repeating values.
- #to_solr(solr_doc = {}, *args) ⇒ Object
-
#twenty_pct_release_date ⇒ Time
Current twentyPctVisibilityReleaseDate value.
-
#twenty_pct_release_date=(rd = Time.now.utc) ⇒ Object
Sets the 20% visibility release date.
- #twenty_pct_status ⇒ Object
- #twenty_pct_status=(new_status) ⇒ Object
Class Method Details
.xml_template ⇒ Object
Default EmbargoMetadataDS xml
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/dor/datastreams/embargo_metadata_ds.rb', line 17 def self.xml_template builder = Nokogiri::XML::Builder.new do |xml| xml. { xml.status xml.releaseDate xml.releaseAccess xml.twentyPctVisibilityStatus xml.twentyPctVisibilityReleaseDate } end builder.doc end |
Instance Method Details
#ensure_non_versionable ⇒ Object
40 41 42 |
# File 'lib/dor/datastreams/embargo_metadata_ds.rb', line 40 def ensure_non_versionable self.versionable = 'false' end |
#prefix ⇒ Object
maintain AF < 8 indexing behavior
109 110 111 |
# File 'lib/dor/datastreams/embargo_metadata_ds.rb', line 109 def prefix '' end |
#release_access_node ⇒ Nokogiri::XML::Element
Returns The releaseAccess node.
92 93 94 |
# File 'lib/dor/datastreams/embargo_metadata_ds.rb', line 92 def release_access_node find_by_terms(:release_access).first end |
#release_access_node=(new_doc) ⇒ Object
Sets the embargaAccess node
98 99 100 101 102 103 104 105 106 |
# File 'lib/dor/datastreams/embargo_metadata_ds.rb', line 98 def release_access_node=(new_doc) if new_doc.root.name != 'releaseAccess' raise 'Trying to replace releaseAccess with a non-releaseAccess document' end term_value_delete(:select => '//embargoMetadata/releaseAccess') ng_xml_will_change! ng_xml.root.add_child(new_doc.root.clone) end |
#release_date ⇒ Time
Current releaseDate value
65 66 67 68 |
# File 'lib/dor/datastreams/embargo_metadata_ds.rb', line 65 def release_date rd = term_values(:release_date).first (rd.nil? || rd.empty?) ? nil : Time.parse(rd) end |
#release_date=(rd = Time.now.utc) ⇒ Object
Sets the release date. Does NOT convert to beginning-of-day.
59 60 61 |
# File 'lib/dor/datastreams/embargo_metadata_ds.rb', line 59 def release_date=(rd = Time.now.utc) update_values([:release_date] => rd.utc.xmlschema) end |
#status ⇒ Object
53 54 55 |
# File 'lib/dor/datastreams/embargo_metadata_ds.rb', line 53 def status term_values(:status).first end |
#status=(new_status) ⇒ Object
Convenience methods to get and set embargo properties Hides complexity/verbosity of OM TermOperators for simple, non-repeating values
49 50 51 |
# File 'lib/dor/datastreams/embargo_metadata_ds.rb', line 49 def status=(new_status) update_values([:status] => new_status) end |
#to_solr(solr_doc = {}, *args) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/dor/datastreams/embargo_metadata_ds.rb', line 30 def to_solr(solr_doc = {}, *args) solr_doc = super #::Solrizer.insert_field(solr_doc, field_name, value, *index_types) rd1 = release_date rd20 = twenty_pct_release_date ::Solrizer.insert_field(solr_doc, 'embargo_release', rd1.utc.strftime('%FT%TZ'), :dateable) unless rd1.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 ⇒ Time
Current twentyPctVisibilityReleaseDate value
86 87 88 89 |
# File 'lib/dor/datastreams/embargo_metadata_ds.rb', line 86 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) ⇒ Object
Sets the 20% visibility release date. Converts the date to beginning-of-day, UTC to help with Solr indexing
80 81 82 |
# File 'lib/dor/datastreams/embargo_metadata_ds.rb', line 80 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 ⇒ Object
74 75 76 |
# File 'lib/dor/datastreams/embargo_metadata_ds.rb', line 74 def twenty_pct_status term_values(:twenty_pct_status).first end |
#twenty_pct_status=(new_status) ⇒ Object
70 71 72 |
# File 'lib/dor/datastreams/embargo_metadata_ds.rb', line 70 def twenty_pct_status=(new_status) update_values([:twenty_pct_status] => new_status) end |