Module: Hyrax::SolrDocumentBehavior

Extended by:
ActiveSupport::Concern
Includes:
Hydra::Works::MimeTypes, Permissions::Readable, Hyrax::SolrDocument::Characterization, Hyrax::SolrDocument::Export, Hyrax::SolrDocument::Metadata
Defined in:
app/models/concerns/hyrax/solr_document_behavior.rb

Defined Under Namespace

Classes: ModelWrapper

Instance Method Summary collapse

Methods included from Hyrax::SolrDocument::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

Methods included from Hyrax::SolrDocument::Export

#end_note_format, #endnote_filename, #export_as_endnote, #persistent_url

Methods included from Permissions::Readable

#private?, #public?, #registered?

Instance Method Details

#collection?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 66

def collection?
  hydra_model == ::Collection
end

#creatorObject



80
81
82
83
84
85
86
87
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 80

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

#depositor(default = '') ⇒ Object



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

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

#hydra_modelObject

Method to return the ActiveFedora model



71
72
73
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 71

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

#itemtypeObject

Add a schema.org itemtype



13
14
15
16
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 13

def itemtype
  types = resource_type || []
  ResourceTypesService.microdata_type(types.first)
end

#title_or_labelObject



18
19
20
21
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 18

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>


62
63
64
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 62

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

#to_paramObject



23
24
25
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 23

def to_param
  id
end

#to_sObject



27
28
29
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 27

def to_s
  title_or_label
end

#visibilityObject



89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 89

def visibility
  @visibility ||= if embargo_release_date.present?
                    Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_EMBARGO
                  elsif lease_expiration_date.present?
                    Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_LEASE
                  elsif public?
                    Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
                  elsif registered?
                    Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
                  else
                    Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
                  end
end