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)



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

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


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

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

#data_dictionary_downloadObject



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

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

#direct_downloadObject



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

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

#display_noteObject



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

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

#downloadable?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 30

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

#external_urlObject



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

def external_url
  references.url&.endpoint
end

#file_formatObject



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

def file_format
  fetch(Settings.FIELDS.FORMAT)
end

#geom_fieldObject



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

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

#geometryObject



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

def geometry
  @geometry ||= Geoblacklight::Geometry.new(geom_field)
end

#hgl_downloadObject



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

def hgl_download
  references.hgl.to_hash if references.hgl.present?
end

#iiif_downloadObject



58
59
60
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 58

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

#item_viewerObject



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

def item_viewer
  ItemViewer.new(references)
end

#itemtypeObject



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

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

#oembedObject



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

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



34
35
36
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 34

def references
  References.new(self)
end

#restricted?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 26

def restricted?
  rights_field_data.blank? || rights_field_data.casecmp("restricted").zero?
end

#same_institution?Boolean

Returns:

  • (Boolean)


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

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

#wxs_identifierObject



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

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