Module: Geoblacklight::SolrDocument
- Extended by:
- Blacklight::Solr::Document
- Includes:
- Carto, Finder, Inspection
- Defined in:
- app/models/concerns/geoblacklight/solr_document.rb,
app/models/concerns/geoblacklight/solr_document/carto.rb,
app/models/concerns/geoblacklight/solr_document/finder.rb,
app/models/concerns/geoblacklight/solr_document/inspection.rb
Overview
Extends Blacklight::Solr::Document for GeoBlacklight specific functionalit
Defined Under Namespace
Modules: Carto, Finder, Inspection
Instance Method Summary
collapse
Methods included from Inspection
#inspectable?
Methods included from Carto
#carto_reference, #cartodb_reference
Methods included from Finder
#blacklight_solr
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
96
97
98
99
100
101
102
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 96
def method_missing(method, *args, &block)
if /.*_url$/ =~ method.to_s
checked_endpoint(method.to_s.gsub('_url', ''))
else
super
end
end
|
Instance Method Details
#available? ⇒ Boolean
14
15
16
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 14
def available?
public? || same_institution?
end
|
#bounding_box_as_wsen ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 62
def bounding_box_as_wsen
geom_field = fetch(Settings.FIELDS.GEOMETRY, '')
exp = /^\s*ENVELOPE\(
\s*([-\.\d]+)\s*,
\s*([-\.\d]+)\s*,
\s*([-\.\d]+)\s*,
\s*([-\.\d]+)\s*
\)\s*$/x bbox_match = exp.match(geom_field)
return geom_field unless bbox_match w, e, n, s = bbox_match.captures
"#{w} #{s} #{e} #{n}"
end
|
#checked_endpoint(type) ⇒ Object
Provides a convenience method to access a SolrDocument’s References endpoint url without having to check and see if it is available :type => a string which if its a Geoblacklight::Constants::URI key
will return a coresponding Geoblacklight::Reference
89
90
91
92
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 89
def checked_endpoint(type)
type = references.send(type)
type.endpoint if type.present?
end
|
#data_dictionary_download ⇒ Object
50
51
52
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 50
def data_dictionary_download
references.data_dictionary.to_hash unless references.data_dictionary.blank?
end
|
#direct_download ⇒ Object
34
35
36
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 34
def direct_download
references.download.to_hash unless references.download.blank?
end
|
#downloadable? ⇒ Boolean
26
27
28
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 26
def downloadable?
(direct_download || download_types.present? || iiif_download) && available?
end
|
80
81
82
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 80
def file_format
fetch(Settings.FIELDS.FILE_FORMAT)
end
|
#hgl_download ⇒ Object
38
39
40
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 38
def hgl_download
references.hgl.to_hash unless references.hgl.blank?
end
|
#iiif_download ⇒ Object
46
47
48
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 46
def iiif_download
references.iiif.to_hash unless references.iiif.blank?
end
|
#item_viewer ⇒ Object
54
55
56
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 54
def item_viewer
ItemViewer.new(references)
end
|
#itemtype ⇒ Object
58
59
60
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 58
def itemtype
'http://schema.org/Dataset'
end
|
#public? ⇒ Boolean
18
19
20
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 18
def public?
fetch(Settings.FIELDS.RIGHTS).casecmp('public').zero?
end
|
#references ⇒ Object
30
31
32
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 30
def references
References.new(self)
end
|
#restricted? ⇒ Boolean
22
23
24
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 22
def restricted?
fetch(Settings.FIELDS.RIGHTS).casecmp('restricted').zero?
end
|
#same_institution? ⇒ Boolean
42
43
44
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 42
def same_institution?
fetch(Settings.FIELDS.PROVENANCE).casecmp(Settings.INSTITUTION.downcase).zero?
end
|
#wxs_identifier ⇒ Object
76
77
78
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 76
def wxs_identifier
fetch(Settings.FIELDS.WXS_IDENTIFIER, '')
end
|