Module: Geoblacklight::SolrDocument

Extended by:
Blacklight::Solr::Document
Defined in:
lib/geoblacklight/solr_document.rb

Overview

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

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)


75
76
77
78
79
80
81
# File 'lib/geoblacklight/solr_document.rb', line 75

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

Returns:

  • (Boolean)

10
11
12
# File 'lib/geoblacklight/solr_document.rb', line 10

def available?
  public? || same_institution?
end

#bounding_box_as_wsenObject


54
55
56
57
58
59
60
61
62
# File 'lib/geoblacklight/solr_document.rb', line 54

def bounding_box_as_wsen
  s = get(Settings.GEOMETRY_FIELD.to_sym)
  if s =~ /^\s*ENVELOPE\(\s*([-\.\d]+)\s*,\s*([-\.\d]+)\s*,\s*([-\.\d]+)\s*,\s*([-\.\d]+)\s*\)\s*$/
    w, s, e, n = $1, $4, $2, $3
    return "#{w} #{s} #{e} #{n}"
  else
    return s # as-is, not a WKT
  end
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

68
69
70
71
# File 'lib/geoblacklight/solr_document.rb', line 68

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

#direct_downloadObject


34
35
36
# File 'lib/geoblacklight/solr_document.rb', line 34

def direct_download
  return references.download.to_hash unless references.download.blank?
end

#download_typesObject


26
27
28
# File 'lib/geoblacklight/solr_document.rb', line 26

def download_types
  references.download_types
end

#downloadable?Boolean

Returns:

  • (Boolean)

22
23
24
# File 'lib/geoblacklight/solr_document.rb', line 22

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

#hgl_downloadObject


38
39
40
# File 'lib/geoblacklight/solr_document.rb', line 38

def hgl_download
  return references.hgl.to_hash unless references.hgl.blank?
end

#item_viewerObject


46
47
48
# File 'lib/geoblacklight/solr_document.rb', line 46

def item_viewer
  ItemViewer.new(references)
end

#itemtypeObject


50
51
52
# File 'lib/geoblacklight/solr_document.rb', line 50

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

#public?Boolean

Returns:

  • (Boolean)

14
15
16
# File 'lib/geoblacklight/solr_document.rb', line 14

def public?
  get(:dc_rights_s).downcase == 'public'
end

#referencesObject


30
31
32
# File 'lib/geoblacklight/solr_document.rb', line 30

def references
  References.new(self)
end

#restricted?Boolean

Returns:

  • (Boolean)

18
19
20
# File 'lib/geoblacklight/solr_document.rb', line 18

def restricted?
  get(:dc_rights_s).downcase == 'restricted'
end

#same_institution?Boolean

Returns:

  • (Boolean)

42
43
44
# File 'lib/geoblacklight/solr_document.rb', line 42

def same_institution?
  get(:dct_provenance_s).downcase == Settings.INSTITUTION.downcase
end