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

#alpha_channels, #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)

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

def admin_set?
  hydra_model == ::AdminSet
end

#collection?Boolean

Returns:

  • (Boolean)

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

def collection?
  hydra_model == ::Collection
end

#collection_type_gidObject


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

def collection_type_gid
  first('collection_type_gid_ssim')
end

#creatorObject


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

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


87
88
89
90
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 87

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

#file_set?Boolean

Returns:

  • (Boolean)

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

def file_set?
  hydra_model == ::FileSet
end

#hydra_modelObject

Method to return the ActiveFedora model


83
84
85
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 83

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


101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 101

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