Class: Valkyrie::Persistence::Solr::ModelConverter::SharedStringPropertyValue

Inherits:
ValueMapper
  • Object
show all
Defined in:
lib/valkyrie/persistence/solr/model_converter.rb

Overview

Handles casting language-tagged strings when there are both language-tagged and non-language-tagged strings in Solr. Assumes English for non-language-tagged strings.

Instance Attribute Summary

Attributes inherited from ValueMapper

#calling_mapper, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ValueMapper

for, #initialize, register

Constructor Details

This class inherits a constructor from Valkyrie::ValueMapper

Class Method Details

.handles?(value) ⇒ Boolean

Determines whether or not a Property value is a String whether or not the Property has an RDF literal specifying the language tag

Parameters:

  • value (Object)

Returns:

  • (Boolean)

395
396
397
# File 'lib/valkyrie/persistence/solr/model_converter.rb', line 395

def self.handles?(value)
  value.is_a?(Property) && value.value.is_a?(String) && value.scope.find { |x| x.is_a?(::RDF::Literal) }.present?
end

Instance Method Details

#resultCompositeSolrRow

Constructs a CompositeSolrRow object with the language-tagged literal value

Returns:


401
402
403
404
405
406
407
408
409
# File 'lib/valkyrie/persistence/solr/model_converter.rb', line 401

def result
  CompositeSolrRow.new(
    [
      calling_mapper.for(Property.new(value.key, value.value)).result,
      calling_mapper.for(Property.new("#{value.key}_lang", "eng")).result,
      calling_mapper.for(Property.new("#{value.key}_type", "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString")).result
    ]
  )
end