Class: Dor::EmbargoMetadataDS

Inherits:
ActiveFedora::OmDatastream
  • Object
show all
Includes:
SolrDocHelper
Defined in:
lib/dor/datastreams/embargo_metadata_ds.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SolrDocHelper

#add_solr_value

Class Method Details

.xml_templateObject

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
  return builder.doc
end

Instance Method Details

#ensure_non_versionableObject


38
39
40
# File 'lib/dor/datastreams/embargo_metadata_ds.rb', line 38

def ensure_non_versionable
  self.versionable = "false"
end

#release_access_nodeNokogiri::XML::Element


91
92
93
# File 'lib/dor/datastreams/embargo_metadata_ds.rb', line 91

def release_access_node
  find_by_terms(:release_access).first
end

#release_access_node=(new_doc) ⇒ Object

Sets the embargaAccess node


102
103
104
105
106
107
108
109
# File 'lib/dor/datastreams/embargo_metadata_ds.rb', line 102

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.root.add_child(new_doc.root.clone)
end

#release_dateTime

Current releaseDate value


64
65
66
# File 'lib/dor/datastreams/embargo_metadata_ds.rb', line 64

def release_date
  Time.parse(term_values(:release_date).first)
end

#release_date=(rd = Time.now) ⇒ Object

Sets the release date. Converts the date to beginning-of-day, UTC to help with Solr indexing


57
58
59
60
# File 'lib/dor/datastreams/embargo_metadata_ds.rb', line 57

def release_date=(rd=Time.now)
update_values([:release_date] => rd.beginning_of_day.utc.xmlschema)
  self.content=self.ng_xml.to_s
end

#statusObject


51
52
53
# File 'lib/dor/datastreams/embargo_metadata_ds.rb', line 51

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


47
48
49
# File 'lib/dor/datastreams/embargo_metadata_ds.rb', line 47

def status=(new_status)
  update_values([:status] => new_status)
end

#to_solr(solr_doc = {}, *args) ⇒ Object


30
31
32
33
34
35
36
# File 'lib/dor/datastreams/embargo_metadata_ds.rb', line 30

def to_solr solr_doc = {}, *args
  super
  add_solr_value(solr_doc, 'embargo_release_date', self.release_date.utc.strftime('%FT%TZ') , :date, [:searchable]) rescue nil
  add_solr_value(solr_doc, 'twenty_pct_visibility_release_date', self.twenty_pct_release_date.utc.strftime('%FT%TZ') , :date, [:searchable]) rescue nil

  solr_doc
end

#twenty_pct_release_dateTime

Current twentyPctVisibilityReleaseDate value


86
87
88
# File 'lib/dor/datastreams/embargo_metadata_ds.rb', line 86

def twenty_pct_release_date
  Time.parse(term_values(:twenty_pct_release_date).first)
end

#twenty_pct_release_date=(rd = Time.now) ⇒ Object

Sets the 20% visibility release date. Converts the date to beginning-of-day, UTC to help with Solr indexing


79
80
81
82
# File 'lib/dor/datastreams/embargo_metadata_ds.rb', line 79

def twenty_pct_release_date=(rd=Time.now)
  update_values([:twenty_pct_release_date] => rd.beginning_of_day.utc.xmlschema)
  content_will_change!
end

#twenty_pct_statusObject


73
74
75
# File 'lib/dor/datastreams/embargo_metadata_ds.rb', line 73

def twenty_pct_status
  term_values(:twenty_pct_status).first
end

#twenty_pct_status=(new_status) ⇒ Object


68
69
70
71
# File 'lib/dor/datastreams/embargo_metadata_ds.rb', line 68

def twenty_pct_status=(new_status)
  update_values([:twenty_pct_status] => new_status)
  content_will_change!
end