Class: GeoCombine::Geoblacklight
- Inherits:
-
Object
- Object
- GeoCombine::Geoblacklight
- Includes:
- Formats, GeometryTypes, Subjects
- Defined in:
- lib/geo_combine/geoblacklight.rb
Constant Summary collapse
- GEOBLACKLIGHT_VERSION =
'1.0'- SCHEMA_JSON_URL =
"https://raw.githubusercontent.com/OpenGeoMetadata/opengeometadata.github.io/main/docs/schema/geoblacklight-schema-#{GEOBLACKLIGHT_VERSION}.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
-
#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.
-
#to_json(options = {}) ⇒ String
Returns a string of JSON from a GeoBlacklight hash.
-
#valid? ⇒ Boolean
True if the GeoBlacklight-Schema document is valid.
-
#validate! ⇒ Boolean
Validates a GeoBlacklight-Schema json document.
-
#validate_references! ⇒ Boolean
Validate dct_references_s.
- #validate_spatial! ⇒ Object
Methods included from GeometryTypes
Methods included from Subjects
Methods included from Formats
Constructor Details
#initialize(metadata, fields = {}) ⇒ Geoblacklight
Initializes a GeoBlacklight object GeoBlacklight-Schema
32 33 34 |
# File 'lib/geo_combine/geoblacklight.rb', line 32 def initialize(, fields = {}) @metadata = JSON.parse().merge(fields) end |
Instance Attribute Details
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
13 14 15 |
# File 'lib/geo_combine/geoblacklight.rb', line 13 def @metadata end |
Instance Method Details
#enhance_metadata ⇒ Object
Calls metadata enhancement methods for each key, value pair in the metadata hash
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/geo_combine/geoblacklight.rb', line 39 def upgrade_to_v1 if ['geoblacklight_version'].blank? .each do |key, value| translate_formats(key, value) enhance_subjects(key, value) infer_geometry_type_from_subject(key, value) format_proper_date(key, value) fields_should_be_array(key, value) translate_geometry_type(key, value) end end |
#to_json(options = {}) ⇒ String
Returns a string of JSON from a GeoBlacklight hash
55 56 57 |
# File 'lib/geo_combine/geoblacklight.rb', line 55 def to_json( = {}) .to_json() end |
#valid? ⇒ Boolean
True if the GeoBlacklight-Schema document is valid
61 62 63 64 65 66 |
# File 'lib/geo_combine/geoblacklight.rb', line 61 def valid? validate! true rescue StandardError false end |
#validate! ⇒ Boolean
Validates a GeoBlacklight-Schema json document
71 72 73 74 75 |
# File 'lib/geo_combine/geoblacklight.rb', line 71 def validate! JSON::Validator.validate!(schema, to_json, fragment: '#/definitions/layer') validate_references! validate_spatial! end |
#validate_references! ⇒ Boolean
Validate dct_references_s
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/geo_combine/geoblacklight.rb', line 80 def validate_references! return unless .key?('dct_references_s') # Not required begin ref = JSON.parse(['dct_references_s']) unless ref.is_a?(Hash) raise GeoCombine::Exceptions::InvalidDCTReferences, 'dct_references must be parsed to a Hash' end true rescue JSON::ParserError => e raise e, "Invalid JSON in dct_references_s: #{e.}" end end |
#validate_spatial! ⇒ Object
96 97 98 |
# File 'lib/geo_combine/geoblacklight.rb', line 96 def validate_spatial! raise GeoCombine::Exceptions::InvalidGeometry unless GeoCombine::BoundingBox.from_envelope(['solr_geom']).valid? end |