Class: GeoCombine::Geoblacklight
- Inherits:
-
Object
- Object
- GeoCombine::Geoblacklight
- Includes:
- Formats, GeometryTypes, Subjects
- Defined in:
- lib/geo_combine/geoblacklight.rb
Constant Summary collapse
- GEOBLACKLIGHT_VERSION =
'v1.1.0'
- SCHEMA_JSON_URL =
"https://raw.githubusercontent.com/geoblacklight/geoblacklight/#{GEOBLACKLIGHT_VERSION}/schema/geoblacklight-schema.json".freeze
- DEPRECATED_KEYS_V1 =
%w[ uuid georss_polygon_s georss_point_s georss_box_s dc_relation_sm solr_issued_i solr_bbox ].freeze
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Instance Method Summary collapse
-
#dct_references_validate! ⇒ Boolean
Validate dct_references_s.
-
#enhance_metadata ⇒ Object
Calls metadata enhancement methods for each key, value pair in the metadata hash.
-
#initialize(metadata, fields = {}) ⇒ Geoblacklight
constructor
Initializes a GeoBlacklight object GeoBlacklight-Schema.
- #spatial_validate! ⇒ Object
-
#to_json(options = {}) ⇒ String
Returns a string of JSON from a GeoBlacklight hash.
-
#valid? ⇒ Boolean
Validates a GeoBlacklight-Schema json document.
Methods included from GeometryTypes
Methods included from Subjects
Methods included from Formats
Constructor Details
#initialize(metadata, fields = {}) ⇒ Geoblacklight
Initializes a GeoBlacklight object GeoBlacklight-Schema
30 31 32 33 |
# File 'lib/geo_combine/geoblacklight.rb', line 30 def initialize(, fields = {}) @metadata = JSON.parse().merge(fields) @schema = nil end |
Instance Attribute Details
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
11 12 13 |
# File 'lib/geo_combine/geoblacklight.rb', line 11 def @metadata end |
Instance Method Details
#dct_references_validate! ⇒ Boolean
Validate dct_references_s
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/geo_combine/geoblacklight.rb', line 70 def dct_references_validate! return true unless .key?('dct_references_s') # TODO: shouldn't we require this field? begin ref = JSON.parse(['dct_references_s']) raise GeoCombine::Exceptions::InvalidDCTReferences, 'dct_references must be parsed to a Hash' unless ref.is_a?(Hash) true rescue JSON::ParserError => e raise e, "Invalid JSON in dct_references_s: #{e.}" end end |
#enhance_metadata ⇒ Object
Calls metadata enhancement methods for each key, value pair in the metadata hash
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/geo_combine/geoblacklight.rb', line 38 def upgrade_to_v1 if ['geoblacklight_version'].blank? .each do |key, value| translate_formats(key, value) enhance_subjects(key, value) format_proper_date(key, value) fields_should_be_array(key, value) translate_geometry_type(key, value) end end |
#spatial_validate! ⇒ Object
81 82 83 |
# File 'lib/geo_combine/geoblacklight.rb', line 81 def spatial_validate! GeoCombine::BoundingBox.from_envelope(['solr_geom']).valid? end |
#to_json(options = {}) ⇒ String
Returns a string of JSON from a GeoBlacklight hash
53 54 55 |
# File 'lib/geo_combine/geoblacklight.rb', line 53 def to_json( = {}) .to_json() end |
#valid? ⇒ Boolean
Validates a GeoBlacklight-Schema json document
60 61 62 63 64 65 |
# File 'lib/geo_combine/geoblacklight.rb', line 60 def valid? @schema ||= JSON.parse(open(SCHEMA_JSON_URL).read) JSON::Validator.validate!(@schema, to_json, fragment: '#/properties/layer') && dct_references_validate! && spatial_validate! end |