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
Overview
Hyrax extensions for Blacklight
‘s generated SolrDocument
.
Constant Summary collapse
- ModelWrapper =
alias for backward compatibility
ActiveFedoraDummyModel
Constants included from Hyrax::SolrDocument::Export
Hyrax::SolrDocument::Export::END_NOTE_MAPPINGS
Instance Method Summary collapse
- #admin_set? ⇒ Boolean
- #collection? ⇒ Boolean
- #collection_type_gid ⇒ Object
- #creator ⇒ Object
- #depositor(default = '') ⇒ Object
- #file_set? ⇒ Boolean
-
#hydra_model(classifier: ActiveFedora.model_mapper) ⇒ Object
Method to return the model.
-
#itemtype ⇒ Object
Add a schema.org itemtype.
- #title_or_label ⇒ Object
-
#to_model ⇒ Object
Offer the source model to Rails for some of the Rails methods (e.g. link_to).
- #to_param ⇒ Object
-
#to_s ⇒ Object
rubocop:disable Rails/Delegate.
- #visibility ⇒ Object
- #work? ⇒ Boolean
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
67 68 69 |
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 67 def admin_set? hydra_model == ::AdminSet end |
#collection? ⇒ Boolean
55 56 57 |
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 55 def collection? hydra_model == Hyrax.config.collection_class end |
#collection_type_gid ⇒ Object
107 108 109 |
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 107 def collection_type_gid first(Hyrax.config.collection_type_index_field) end |
#creator ⇒ Object
88 89 90 91 |
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 88 def creator solr_term = hydra_model == AdminSet ? "creator_ssim" : "creator_tesim" fetch(solr_term, []) end |
#depositor(default = '') ⇒ Object
83 84 85 86 |
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 83 def depositor(default = '') val = first("depositor_tesim") val.presence || default end |
#file_set? ⇒ Boolean
61 62 63 |
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 61 def file_set? hydra_model == ::FileSet end |
#hydra_model(classifier: ActiveFedora.model_mapper) ⇒ Object
Method to return the model
78 79 80 81 |
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 78 def hydra_model(classifier: ActiveFedora.model_mapper) first('has_model_ssim')&.safe_constantize || classifier.classifier(self).best_model end |
#itemtype ⇒ Object
Add a schema.org itemtype
26 27 28 29 |
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 26 def itemtype types = resource_type || [] ResourceTypesService.microdata_type(types.first) end |
#title_or_label ⇒ Object
31 32 33 34 |
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 31 def title_or_label return label if title.blank? title.join(', ') end |
#to_model ⇒ Object
Offer the source model to Rails for some of the Rails methods (e.g. link_to).
49 50 51 |
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 49 def to_model @model ||= ActiveFedoraDummyModel.new(hydra_model, id) end |
#to_param ⇒ Object
36 37 38 |
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 36 def to_param id end |
#to_s ⇒ Object
rubocop:disable Rails/Delegate
40 41 42 |
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 40 def to_s # rubocop:disable Rails/Delegate title_or_label.to_s end |
#visibility ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 93 def visibility @visibility ||= if .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 |
#work? ⇒ Boolean
73 74 75 |
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 73 def work? Hyrax.config.curation_concerns.include? hydra_model end |