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)


378
379
380
# File 'lib/valkyrie/persistence/solr/model_converter.rb', line 378

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:



384
385
386
387
388
389
390
391
392
# File 'lib/valkyrie/persistence/solr/model_converter.rb', line 384

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