Module: Geoblacklight::SolrDocument

Extended by:
Blacklight::Solr::Document
Includes:
Arcgis, Carto, Citation, 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/arcgis.rb,
app/models/concerns/geoblacklight/solr_document/finder.rb,
app/models/concerns/geoblacklight/solr_document/citation.rb,
app/models/concerns/geoblacklight/solr_document/inspection.rb

Overview

Extends Blacklight::Solr::Document for GeoBlacklight specific functionality

Defined Under Namespace

Modules: Arcgis, Carto, Citation, Finder, Inspection

Instance Method Summary collapse

Methods included from Citation

#geoblacklight_citation

Methods included from Arcgis

#arcgis_urls

Methods included from Inspection

#inspectable?

Methods included from Carto

#carto_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 (private)



138
139
140
141
142
143
144
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 138

def method_missing(method, *args, &block)
  if /.*_url$/.match?(method.to_s)
    checked_endpoint(method.to_s.gsub("_url", ""))
  else
    super
  end
end

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 18

def available?
  public? || same_institution?
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



113
114
115
116
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 113

def checked_endpoint(type)
  type = references.send(type)
  type.endpoint if type.present?
end

#data_dictionary_downloadObject



74
75
76
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 74

def data_dictionary_download
  references.data_dictionary.to_hash if references.data_dictionary.present?
end

#direct_downloadObject



45
46
47
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 45

def direct_download
  references.download.to_hash if references.download.present?
end

#display_noteObject



49
50
51
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 49

def display_note
  fetch(Settings.FIELDS.DISPLAY_NOTE, "")
end

#downloadable?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 37

def downloadable?
  (direct_download || download_types.present? || iiif_download) && available?
end

#external_urlObject



78
79
80
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 78

def external_url
  references.url&.endpoint
end

#file_formatObject



104
105
106
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 104

def file_format
  fetch(Settings.FIELDS.FORMAT)
end

#geom_fieldObject



90
91
92
93
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 90

def geom_field
  warn_about_blank_default(Settings.FIELDS.GEOMETRY, "geom_field")
  fetch(Settings.FIELDS.GEOMETRY, "")
end

#geometryObject



95
96
97
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 95

def geometry
  @geometry ||= Geoblacklight::Geometry.new(Geoblacklight.deprecation.silence { geom_field })
end

#hgl_downloadObject

Deprecated.


54
55
56
57
58
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 54

def hgl_download
  Geoblacklight.deprecation.silence do
    references.hgl.to_hash if references.hgl.present?
  end
end

#iiif_downloadObject



70
71
72
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 70

def iiif_download
  references.iiif.to_hash if references.iiif.present?
end

#item_viewerObject



82
83
84
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 82

def item_viewer
  ItemViewer.new(references)
end

#itemtypeObject



86
87
88
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 86

def itemtype
  "http://schema.org/Dataset"
end

#oembedObject



62
63
64
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 62

def oembed
  references.oembed.endpoint if references.oembed.present?
end

#public?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 22

def public?
  rights_field_data.present? && rights_field_data.casecmp("public").zero?
end

#referencesObject



41
42
43
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 41

def references
  References.new(self)
end

#restricted?Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
32
33
34
35
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 26

def restricted?
  if key?(Settings.FIELDS.ACCESS_RIGHTS) && self[Settings.FIELDS.ACCESS_RIGHTS].blank?
    Geoblacklight.deprecation.warn(
      "Geoblacklight::SolrDocument#restricted? returns true for a document whose " \
      "#{Settings.FIELDS.ACCESS_RIGHTS} is present but blank; GeoBlacklight 5 returns false for the " \
      "same document, because it tests the value for nil rather than for blankness"
    )
  end
  rights_field_data.blank? || rights_field_data.casecmp("restricted").zero?
end

#same_institution?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 66

def same_institution?
  fetch(Settings.FIELDS.PROVIDER, "").casecmp(Settings.INSTITUTION.downcase).zero?
end

#wxs_identifierObject



99
100
101
102
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 99

def wxs_identifier
  warn_about_blank_default(Settings.FIELDS.WXS_IDENTIFIER, "wxs_identifier")
  fetch(Settings.FIELDS.WXS_IDENTIFIER, "")
end