Module: Ddr::Models::SolrDocument
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/ddr/models/solr_document.rb
Instance Method Summary collapse
- #active_fedora_model ⇒ Object
- #admin_policy_pid ⇒ Object
- #admin_policy_uri ⇒ Object
- #association(name) ⇒ Object
- #content_checksum ⇒ Object
- #content_ds ⇒ Object
- #content_mime_type ⇒ Object (also: #content_type)
- #content_size ⇒ Object
- #content_size_human ⇒ Object
- #controller_name ⇒ Object
- #datastreams ⇒ Object
- #effective_license ⇒ Object
- #has_admin_policy? ⇒ Boolean
- #has_children? ⇒ Boolean
- #has_content? ⇒ Boolean
- #has_datastream?(dsID) ⇒ Boolean
- #has_default_rights? ⇒ Boolean
- #has_target? ⇒ Boolean
- #has_thumbnail? ⇒ Boolean
- #identifier ⇒ Object
- #inherited_license ⇒ Object
- #internal_uri ⇒ Object
- #label ⇒ Object
- #last_fixity_check_on ⇒ Object
- #last_fixity_check_outcome ⇒ Object
- #last_virus_check_on ⇒ Object
- #last_virus_check_outcome ⇒ Object
- #license ⇒ Object
- #object_create_date ⇒ Object
- #object_modified_date ⇒ Object
- #object_profile ⇒ Object
- #object_state ⇒ Object
- #permanent_id ⇒ Object
- #principal_has_role?(principal, role) ⇒ Boolean
- #safe_id ⇒ Object
- #source ⇒ Object
- #targets ⇒ Object
- #targets_count ⇒ Object
- #title ⇒ Object (also: #title_display)
- #to_partial_path ⇒ Object
Instance Method Details
#active_fedora_model ⇒ Object
20 21 22 |
# File 'lib/ddr/models/solr_document.rb', line 20 def active_fedora_model get(Ddr::IndexFields::ACTIVE_FEDORA_MODEL) end |
#admin_policy_pid ⇒ Object
76 77 78 79 |
# File 'lib/ddr/models/solr_document.rb', line 76 def admin_policy_pid uri = admin_policy_uri uri &&= ActiveFedora::Base.pid_from_uri(uri) end |
#admin_policy_uri ⇒ Object
72 73 74 |
# File 'lib/ddr/models/solr_document.rb', line 72 def admin_policy_uri get(Ddr::IndexFields::IS_GOVERNED_BY) end |
#association(name) ⇒ Object
153 154 155 |
# File 'lib/ddr/models/solr_document.rb', line 153 def association(name) get_pid(ActiveFedora::SolrService.solr_name(name, :symbol)) end |
#content_checksum ⇒ Object
133 134 135 |
# File 'lib/ddr/models/solr_document.rb', line 133 def content_checksum content_ds["dsChecksum"] rescue nil end |
#content_ds ⇒ Object
115 116 117 |
# File 'lib/ddr/models/solr_document.rb', line 115 def content_ds datastreams[Ddr::Datastreams::CONTENT] end |
#content_mime_type ⇒ Object Also known as: content_type
119 120 121 |
# File 'lib/ddr/models/solr_document.rb', line 119 def content_mime_type content_ds["dsMIME"] rescue nil end |
#content_size ⇒ Object
125 126 127 |
# File 'lib/ddr/models/solr_document.rb', line 125 def content_size get(Ddr::IndexFields::CONTENT_SIZE) end |
#content_size_human ⇒ Object
129 130 131 |
# File 'lib/ddr/models/solr_document.rb', line 129 def content_size_human get(Ddr::IndexFields::CONTENT_SIZE_HUMAN) end |
#controller_name ⇒ Object
157 158 159 |
# File 'lib/ddr/models/solr_document.rb', line 157 def controller_name active_fedora_model.tableize end |
#datastreams ⇒ Object
60 61 62 |
# File 'lib/ddr/models/solr_document.rb', line 60 def datastreams object_profile["datastreams"] end |
#effective_license ⇒ Object
180 181 182 |
# File 'lib/ddr/models/solr_document.rb', line 180 def effective_license @effective_license ||= license || inherited_license || {} end |
#has_admin_policy? ⇒ Boolean
68 69 70 |
# File 'lib/ddr/models/solr_document.rb', line 68 def has_admin_policy? admin_policy_uri.present? end |
#has_children? ⇒ Boolean
81 82 83 |
# File 'lib/ddr/models/solr_document.rb', line 81 def has_children? ActiveFedora::SolrService.class_from_solr_document(self).reflect_on_association(:children).present? end |
#has_content? ⇒ Boolean
111 112 113 |
# File 'lib/ddr/models/solr_document.rb', line 111 def has_content? has_datastream?(Ddr::Datastreams::CONTENT) end |
#has_datastream?(dsID) ⇒ Boolean
64 65 66 |
# File 'lib/ddr/models/solr_document.rb', line 64 def has_datastream?(dsID) datastreams[dsID].present? end |
#has_default_rights? ⇒ Boolean
149 150 151 |
# File 'lib/ddr/models/solr_document.rb', line 149 def has_default_rights? has_datastream?(Ddr::Datastreams::DEFAULT_RIGHTS) end |
#has_target? ⇒ Boolean
145 146 147 |
# File 'lib/ddr/models/solr_document.rb', line 145 def has_target? targets_count > 0 end |
#has_thumbnail? ⇒ Boolean
107 108 109 |
# File 'lib/ddr/models/solr_document.rb', line 107 def has_thumbnail? has_datastream?(Ddr::Datastreams::THUMBNAIL) end |
#identifier ⇒ Object
98 99 100 101 |
# File 'lib/ddr/models/solr_document.rb', line 98 def identifier # We want the multivalued version here get(ActiveFedora::SolrService.solr_name(:identifier, :stored_searchable, type: :text)) end |
#inherited_license ⇒ Object
161 162 163 164 165 166 167 168 169 170 |
# File 'lib/ddr/models/solr_document.rb', line 161 def inherited_license if admin_policy_pid query = ActiveFedora::SolrService.construct_query_for_pids([admin_policy_pid]) results = ActiveFedora::SolrService.query(query) doc = results.map { |result| ::SolrDocument.new(result) }.first { title: doc.get(Ddr::IndexFields::DEFAULT_LICENSE_TITLE), description: doc.get(Ddr::IndexFields::DEFAULT_LICENSE_DESCRIPTION), url: doc.get(Ddr::IndexFields::DEFAULT_LICENSE_URL) } end end |
#internal_uri ⇒ Object
24 25 26 |
# File 'lib/ddr/models/solr_document.rb', line 24 def internal_uri get(Ddr::IndexFields::INTERNAL_URI) end |
#label ⇒ Object
85 86 87 |
# File 'lib/ddr/models/solr_document.rb', line 85 def label object_profile["objLabel"] end |
#last_fixity_check_on ⇒ Object
44 45 46 |
# File 'lib/ddr/models/solr_document.rb', line 44 def last_fixity_check_on get_date(Ddr::IndexFields::LAST_FIXITY_CHECK_ON) end |
#last_fixity_check_outcome ⇒ Object
48 49 50 |
# File 'lib/ddr/models/solr_document.rb', line 48 def last_fixity_check_outcome get(Ddr::IndexFields::LAST_FIXITY_CHECK_OUTCOME) end |
#last_virus_check_on ⇒ Object
52 53 54 |
# File 'lib/ddr/models/solr_document.rb', line 52 def last_virus_check_on get_date(Ddr::IndexFields::LAST_VIRUS_CHECK_ON) end |
#last_virus_check_outcome ⇒ Object
56 57 58 |
# File 'lib/ddr/models/solr_document.rb', line 56 def last_virus_check_outcome get(Ddr::IndexFields::LAST_VIRUS_CHECK_OUTCOME) end |
#license ⇒ Object
172 173 174 175 176 177 178 |
# File 'lib/ddr/models/solr_document.rb', line 172 def license if get(Ddr::IndexFields::LICENSE_TITLE) || get(Ddr::IndexFields::LICENSE_DESCRIPTION) || get(Ddr::IndexFields::LICENSE_URL) { title: get(Ddr::IndexFields::LICENSE_TITLE), description: get(Ddr::IndexFields::LICENSE_DESCRIPTION), url: get(Ddr::IndexFields::LICENSE_URL) } end end |
#object_create_date ⇒ Object
36 37 38 |
# File 'lib/ddr/models/solr_document.rb', line 36 def object_create_date parse_date(object_profile["objCreateDate"]) end |
#object_modified_date ⇒ Object
40 41 42 |
# File 'lib/ddr/models/solr_document.rb', line 40 def object_modified_date parse_date(object_profile["objLastModDate"]) end |
#object_profile ⇒ Object
28 29 30 |
# File 'lib/ddr/models/solr_document.rb', line 28 def object_profile @object_profile ||= get_json(Ddr::IndexFields::OBJECT_PROFILE) end |
#object_state ⇒ Object
32 33 34 |
# File 'lib/ddr/models/solr_document.rb', line 32 def object_state object_profile["objState"] end |
#permanent_id ⇒ Object
184 185 186 |
# File 'lib/ddr/models/solr_document.rb', line 184 def permanent_id get(Ddr::IndexFields::PERMANENT_ID) end |
#principal_has_role?(principal, role) ⇒ Boolean
94 95 96 |
# File 'lib/ddr/models/solr_document.rb', line 94 def principal_has_role?(principal, role) (Array(self["admin_metadata__#{role}_ssim"]) & Array(principal)).any? end |
#safe_id ⇒ Object
16 17 18 |
# File 'lib/ddr/models/solr_document.rb', line 16 def safe_id id.sub(/:/, "-") end |
#source ⇒ Object
103 104 105 |
# File 'lib/ddr/models/solr_document.rb', line 103 def source get(ActiveFedora::SolrService.solr_name(:source, :stored_searchable, type: :text)) end |
#targets ⇒ Object
137 138 139 |
# File 'lib/ddr/models/solr_document.rb', line 137 def targets @targets ||= ActiveFedora::SolrService.query(targets_query) end |
#targets_count ⇒ Object
141 142 143 |
# File 'lib/ddr/models/solr_document.rb', line 141 def targets_count @targets_count ||= ActiveFedora::SolrService.count(targets_query) end |
#title ⇒ Object Also known as: title_display
89 90 91 |
# File 'lib/ddr/models/solr_document.rb', line 89 def title get(Ddr::IndexFields::TITLE) end |
#to_partial_path ⇒ Object
12 13 14 |
# File 'lib/ddr/models/solr_document.rb', line 12 def to_partial_path 'document' end |