Class: Valkyrie::Persistence::Fedora::Persister::OrmConverter::GraphToAttributes::NestedValue
- Inherits:
-
ValueMapper
- Object
- ValueMapper
- Valkyrie::Persistence::Fedora::Persister::OrmConverter::GraphToAttributes::NestedValue
- Defined in:
- lib/valkyrie/persistence/fedora/persister/orm_converter.rb
Overview
Class for mapping RDF child graphs within parent graphs
Defined Under Namespace
Classes: GraphContainer
Instance Attribute Summary
Attributes inherited from ValueMapper
Class Method Summary collapse
-
.handles?(value) ⇒ Boolean
Determines whether or not a Property lies within a parent graph.
Instance Method Summary collapse
-
#container ⇒ GraphContainer
Construct a new GraphContainer object for the parent graph of the child graph in this Property.
-
#graph ⇒ RDF::Graph
Construct the RDF graph used for the parent graph.
-
#new_subject(statement) ⇒ RDF::URI
Retrieve a new RDF subject for a given statement If the subject of the statement and that of the Property statement are the same, generate an empty URI.
-
#resource ⇒ Valkyrie::Resource
Recursively convert the parent graph into a Valkyrie Resource.
-
#result ⇒ Applicator
Construct an Applicator object from the parent graph for the child graph in this Property.
Methods inherited from ValueMapper
Constructor Details
This class inherits a constructor from Valkyrie::ValueMapper
Class Method Details
.handles?(value) ⇒ Boolean
Determines whether or not a Property lies within a parent graph
227 228 229 230 231 |
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 227 def self.handles?(value) value.statement.object.is_a?(RDF::URI) && value.statement.object.to_s.include?("#") && (value.statement.object.to_s.start_with?("#") || value.statement.object.to_s.start_with?(value.adapter.connection_prefix)) end |
Instance Method Details
#container ⇒ GraphContainer
Construct a new GraphContainer object for the parent graph of the child graph in this Property
247 248 249 |
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 247 def container GraphContainer.new(graph, value.statement.object) end |
#graph ⇒ RDF::Graph
Construct the RDF graph used for the parent graph
271 272 273 |
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 271 def graph @graph ||= RDF::Graph.new end |
#new_subject(statement) ⇒ RDF::URI
Retrieve a new RDF subject for a given statement
If the subject of the statement and that of the Property statement are the same, generate an empty URI
261 262 263 264 265 266 267 |
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 261 def new_subject(statement) if statement.subject == value.statement.object RDF::URI("") else statement.subject end end |
#resource ⇒ Valkyrie::Resource
Recursively convert the parent graph into a Valkyrie Resource
253 254 255 |
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 253 def resource OrmConverter.new(object: container, adapter: value.adapter).convert end |
#result ⇒ Applicator
Construct an Applicator object from the parent graph for the child graph in this Property
235 236 237 238 239 240 241 242 243 |
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 235 def result value.scope.each do |statement| next unless statement.subject.to_s.include?("#") subject = new_subject(statement) graph << RDF::Statement.new(subject, statement.predicate, statement.object) end value.statement.object = resource Applicator.new(Property.new(statement: value.statement, scope: value.scope, adapter: value.adapter)) end |