Class: Triannon::AnnotationLdp

Inherits:
Object
  • Object
show all
Defined in:
app/models/triannon/annotation_ldp.rb

Overview

an LDP aware model of an Annotation – basically, a shim between the OA

notion of an annotation and the LDP storage.

Instance Method Summary collapse

Instance Method Details

#base_uriObject



16
17
18
19
# File 'app/models/triannon/annotation_ldp.rb', line 16

def base_uri
  res = graph.query OA::Graph.anno_query
  res.first.s
end

#body_urisArray<String>

Returns the uris of each LDP body resource.

Returns:

  • (Array<String>)

    the uris of each LDP body resource



22
23
24
25
26
27
28
29
30
31
# File 'app/models/triannon/annotation_ldp.rb', line 22

def body_uris
  q = OA::Graph.anno_query.dup
  q << [:s, RDF::Vocab::OA.hasBody, :body_uri]
  solns = graph.query q
  result = []
  solns.distinct.each { |soln|
    result << soln.body_uri
  }
  result
end

#graphObject

RDF::Graph object with all triples, including back end (e.g. LDP, Fedora)



7
8
9
# File 'app/models/triannon/annotation_ldp.rb', line 7

def graph
  @g ||= RDF::Graph.new
end

#load_statements_into_graph(statements) ⇒ Object

add the passed statements to #graph

Parameters:

  • statements (Array<RDF::Statement>)

    an array of RDF statements to be loaded into the graph



48
49
50
# File 'app/models/triannon/annotation_ldp.rb', line 48

def load_statements_into_graph(statements)
  graph.insert(statements) if statements && statements.size > 0
end

#stripped_graphObject

RDF::Graph without any back end (e.g. LDP, Fedora) triples



12
13
14
# File 'app/models/triannon/annotation_ldp.rb', line 12

def stripped_graph
  OA::Graph.remove_ldp_triples(OA::Graph.remove_fedora_triples(graph))
end

#target_urisArray<String>

Returns the uris of each LDP target resource.

Returns:

  • (Array<String>)

    the uris of each LDP target resource



34
35
36
37
38
39
40
41
42
43
# File 'app/models/triannon/annotation_ldp.rb', line 34

def target_uris
  q = OA::Graph.anno_query.dup
  q << [:s, RDF::Vocab::OA.hasTarget, :target_uri]
  solns = graph.query q
  result = []
  solns.distinct.each { |soln|
    result << soln.target_uri
  }
  result
end