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

#admin_set?Boolean

Returns:

  • (Boolean)


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

def admin_set?
  hydra_model == ::AdminSet
end

#collection?Boolean

Returns:

  • (Boolean)


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

def collection?
  hydra_model == ::Collection
end

#collection_type_gidObject



105
106
107
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 105

def collection_type_gid
  first('collection_type_gid_ssim')
end

#creatorObject



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

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



77
78
79
80
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 77

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

#hydra_modelObject

Method to return the ActiveFedora model



73
74
75
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 73

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

#itemtypeObject

Add a schema.org itemtype



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

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

#title_or_labelObject



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

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>


60
61
62
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 60

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

#to_paramObject



21
22
23
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 21

def to_param
  id
end

#to_sObject



25
26
27
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 25

def to_s
  title_or_label
end

#visibilityObject



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

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