Module: Krikri::LDP::RdfSource

Extended by:
ActiveSupport::Concern
Includes:
Resource
Included in:
OriginalRecordMetadata
Defined in:
lib/krikri/ldp/rdf_source.rb

Overview

Adds simple LDP persistence to ActiveTriples::Resource classes

See Also:

Instance Method Summary collapse

Methods included from Resource

#delete!, #etag, #exists?, #http_head, #ldp_connection, #modified_date

Instance Method Details

#get(*args) ⇒ Object

GETs the LDP resource from #rdf_subject and resets this object’s RDF::Graph to match the one returned from the LDP server.



29
30
31
32
33
# File 'lib/krikri/ldp/rdf_source.rb', line 29

def get(*args)
  result = super
  reload_ldp
  result
end

#saveObject

Note:

this forces a (GET/#get) reload of the resource after save since the LDP endpoint may add management triples in the response.

PUTs the LDP resource named in #rdf_subject, populating it’s content (graph) from the object’s RDF::Graph.



18
19
20
21
22
# File 'lib/krikri/ldp/rdf_source.rb', line 18

def save(*)
  result = super(dump(:ttl))
  get({}, true)
  result
end

#save_with_provenance(activity_uri) ⇒ Object

TODO:

Assuming a Marmotta LDP server, there are version URIs available (via Memento) which could be used for a direct PROV implementation. Consider options for doing that either alongside or in place of this approach.

Adds an appropritate provenance statement with the given URI and saves the resource.

This method treats RDFSources as stateful resources. This is in conflict with the PROV model, which assumes each revision is its own Resource. The internal predicate ‘dpla:wasRevisedBy` is used for non-generating revisions of stateful RDFSources.

Parameters:

  • activity_uri (#to_term)

    the URI of the prov:Activity to mark as generating or revising the saved resource.

See Also:



56
57
58
59
60
61
# File 'lib/krikri/ldp/rdf_source.rb', line 56

def save_with_provenance(activity_uri)
  predicate =
    exists? ? RDF::DPLA.wasRevisedBy : RDF::PROV.wasGeneratedBy
  self << RDF::Statement(self, predicate, activity_uri)
  save
end