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
226 227 228 229 230 |
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 226 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
246 247 248 |
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 246 def container GraphContainer.new(graph, value.statement.object) end |
#graph ⇒ RDF::Graph
Construct the RDF graph used for the parent graph
270 271 272 |
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 270 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
260 261 262 263 264 265 266 |
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 260 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
252 253 254 |
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 252 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
234 235 236 237 238 239 240 241 242 |
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 234 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 |