Class: Valkyrie::Persistence::Fedora::Persister::OrmConverter::GraphToAttributes::TimeValue

Inherits:
ValueMapper
  • Object
show all
Defined in:
lib/valkyrie/persistence/fedora/persister/orm_converter.rb

Overview

Class for mapping RDF datetime literals into Valkyrie Resource attribute values Class for mapping Property objects for Time values Technically Valkyrie does not support time, but when other persisters support time

this code will make Fedora compliant with the established patterns.

https://github.com/samvera-labs/valkyrie/wiki/Supported-Data-Types

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 statement is an RDF literal typed for Time values

Parameters:

Returns:

  • (Boolean)


390
391
392
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 390

def self.handles?(value)
  value.statement.object.is_a?(RDF::Literal) && value.statement.object.language.blank? && value.statement.object.datatype == PermissiveSchema.valkyrie_time
end

Instance Method Details

#resultApplicator

Casts the value of the RDF literal into an Applicator for DateTime values

Returns:



396
397
398
399
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 396

def result
  value.statement.object = Time.parse(value.statement.object.to_s).utc
  calling_mapper.for(Property.new(statement: value.statement, scope: value.scope, adapter: value.adapter)).result
end