Module: CurationConcerns::SolrDocumentBehavior

Extended by:
ActiveSupport::Concern
Includes:
CurationConcerns::SolrBehavior::Characterization, Hydra::Works::MimeTypes
Defined in:
app/models/concerns/curation_concerns/solr_document_behavior.rb

Defined Under Namespace

Classes: ModelWrapper

Instance Method Summary collapse

Methods included from CurationConcerns::SolrBehavior::Characterization

#byte_order, #capture_device, #color_map, #color_space, #compression, #duration, #file_size, #file_title, #filename, #format_label, #gps_timestamp, #height, #image_producer, #last_modified, #latitude, #longitude, #orientation, #original_checksum, #page_count, #profile_name, #profile_version, #sample_rate, #scanning_software, #well_formed, #width

Instance Method Details

#collection?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 55

def collection?
  hydra_model == ::Collection
end

#contributorObject



119
120
121
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 119

def contributor
  fetch(Solrizer.solr_name('contributor'), [])
end

#creatorObject



114
115
116
117
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 114

def creator
  descriptor = hydra_model.index_config[:creator].behaviors.first
  fetch(Solrizer.solr_name('creator', descriptor), [])
end

#date_createdObject

Date created is indexed as a string. This allows users to enter values like: ‘Circa 1840-1844’



81
82
83
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 81

def date_created
  first(Solrizer.solr_name("date_created"))
end

#date_modifiedObject



85
86
87
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 85

def date_modified
  date_field('date_modified')
end

#date_uploadedObject



89
90
91
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 89

def date_uploaded
  date_field('date_uploaded')
end

#depositor(default = '') ⇒ Object



93
94
95
96
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 93

def depositor(default = '')
  val = first(Solrizer.solr_name('depositor'))
  val.present? ? val : default
end

#descriptionObject



102
103
104
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 102

def description
  Array.wrap(self[Solrizer.solr_name('description')])
end

#embargo_release_dateObject



139
140
141
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 139

def embargo_release_date
  self[Hydra.config.permissions.embargo.release_date]
end

#file_formatObject



110
111
112
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 110

def file_format
  first(Solrizer.solr_name('file_format'))
end

#human_readable_typeObject



68
69
70
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 68

def human_readable_type
  first(Solrizer.solr_name('human_readable_type', :stored_searchable))
end

#hydra_modelObject

Method to return the ActiveFedora model



64
65
66
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 64

def hydra_model
  first(Solrizer.solr_name('has_model', :symbol)).constantize
end

#keywordObject



135
136
137
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 135

def keyword
  fetch(Solrizer.solr_name('keyword'), [])
end

#labelObject



106
107
108
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 106

def label
  first(Solrizer.solr_name('label'))
end

#languageObject



131
132
133
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 131

def language
  fetch(Solrizer.solr_name('language'), [])
end

#lease_expiration_dateObject



143
144
145
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 143

def lease_expiration_date
  self[Hydra.config.permissions.lease.expiration_date]
end

#member_of_collection_idsObject



177
178
179
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 177

def member_of_collection_ids
  fetch(Solrizer.solr_name('member_of_collection_ids', :symbol), [])
end

#mime_typeObject



151
152
153
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 151

def mime_type
  self[Solrizer.solr_name('mime_type', :stored_sortable)]
end

#publisherObject



127
128
129
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 127

def publisher
  fetch(Solrizer.solr_name('publisher'), [])
end

#read_groupsObject



155
156
157
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 155

def read_groups
  fetch(Hydra.config.permissions.read.group, [])
end

#representative_idObject



72
73
74
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 72

def representative_id
  first(Solrizer.solr_name('hasRelatedMediaFragment', :symbol))
end

#rightsObject



147
148
149
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 147

def rights
  fetch(Solrizer.solr_name('rights'), [])
end

#sourceObject



159
160
161
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 159

def source
  fetch(Solrizer.solr_name('source'), [])
end

#subjectObject



123
124
125
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 123

def subject
  fetch(Solrizer.solr_name('subject'), [])
end

#suppressed?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 59

def suppressed?
  first(Solrizer.solr_name('suppressed', stored_boolean_field))
end

#thumbnail_idObject



76
77
78
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 76

def thumbnail_id
  first(Solrizer.solr_name('hasRelatedImage', :symbol))
end

#titleObject



98
99
100
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 98

def title
  Array.wrap(self[Solrizer.solr_name('title')])
end

#title_or_labelObject



7
8
9
10
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 7

def title_or_label
  return label if title.blank?
  title.join(', ')
end

#to_modelObject

Offer the source (ActiveFedora-based) model to Rails for some of the Rails methods (e.g. link_to).

Examples:

link_to '...', SolrDocument(:id => 'bXXXXXX5').new => <a href="/dams_object/bXXXXXX5">...</a>


51
52
53
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 51

def to_model
  @model ||= ModelWrapper.new(hydra_model, id)
end

#to_paramObject



12
13
14
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 12

def to_param
  id
end

#to_sObject



16
17
18
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 16

def to_s
  title_or_label
end

#visibilityObject



163
164
165
166
167
168
169
170
171
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 163

def visibility
  @visibility ||= if read_groups.include? Hydra::AccessControls::AccessRight::PERMISSION_TEXT_VALUE_PUBLIC
                    Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
                  elsif read_groups.include? Hydra::AccessControls::AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED
                    Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
                  else
                    Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
                  end
end

#workflow_stateObject



173
174
175
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 173

def workflow_state
  first(Solrizer.solr_name('workflow_state_name', :symbol))
end