Class: Triannon::LdpLoader
- Inherits:
-
Object
- Object
- Triannon::LdpLoader
- Defined in:
- app/services/triannon/ldp_loader.rb
Overview
Loads an existing Annotation from the LDP server
Instance Attribute Summary collapse
-
#ldp_annotation ⇒ Object
Returns the value of attribute ldp_annotation.
Class Method Summary collapse
-
.find_all ⇒ Object
deprecated
Deprecated.
was needed by old annotations#index action, which now redirects to search (2015-04)
- .load(id) ⇒ Object
Instance Method Summary collapse
-
#find_all ⇒ Array<Triannon::Annotation>
deprecated
Deprecated.
was needed by old annotations#index action, which now redirects to search (2015-04).
-
#initialize(id = nil) ⇒ LdpLoader
constructor
A new instance of LdpLoader.
-
#load_anno_container ⇒ Object
load annotation container object into @ldp_annotation’s (our Triannon::AnnotationLdp object) graph.
-
#load_bodies ⇒ Object
load body objects into @ldp_annotation’s (our Triannon::AnnotationLdp object) graph.
-
#load_targets ⇒ Object
load target objects into @ldp_annotation’s (our Triannon::AnnotationLdp object) graph.
Constructor Details
#initialize(id = nil) ⇒ LdpLoader
Returns a new instance of LdpLoader.
28 29 30 31 32 |
# File 'app/services/triannon/ldp_loader.rb', line 28 def initialize id = nil @id = id @base_uri = Triannon.config[:ldp_url] @ldp_annotation = Triannon::AnnotationLdp.new end |
Instance Attribute Details
#ldp_annotation ⇒ Object
Returns the value of attribute ldp_annotation.
25 26 27 |
# File 'app/services/triannon/ldp_loader.rb', line 25 def ldp_annotation @ldp_annotation end |
Class Method Details
Instance Method Details
#find_all ⇒ Array<Triannon::Annotation>
was needed by old annotations#index action, which now redirects to search (2015-04).
Returns an array of Triannon::Annotation objects with just the id set. Enough info to build the index page.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/services/triannon/ldp_loader.rb', line 57 def find_all root_ttl = get_ttl objs = [] g = RDF::Graph.new g.from_ttl root_ttl root_uri = RDF::URI.new @base_uri results = g.query [root_uri, RDF::LDP.contains, nil] results.each do |stmt| id = stmt.object.to_s.split('/').last objs << Triannon::Annotation.new(:id => id) end objs end |
#load_anno_container ⇒ Object
load annotation container object into @ldp_annotation’s (our Triannon::AnnotationLdp object) graph
35 36 37 |
# File 'app/services/triannon/ldp_loader.rb', line 35 def load_anno_container load_object_into_annotation_graph(@id) end |
#load_bodies ⇒ Object
load body objects into @ldp_annotation’s (our Triannon::AnnotationLdp object) graph
40 41 42 43 44 45 |
# File 'app/services/triannon/ldp_loader.rb', line 40 def load_bodies @ldp_annotation.body_uris.each { |body_uri| body_obj_path = body_uri.to_s.split(@base_uri + '/').last load_object_into_annotation_graph(body_obj_path) } end |
#load_targets ⇒ Object
load target objects into @ldp_annotation’s (our Triannon::AnnotationLdp object) graph
48 49 50 51 52 53 |
# File 'app/services/triannon/ldp_loader.rb', line 48 def load_targets @ldp_annotation.target_uris.each { |target_uri| target_obj_path = target_uri.to_s.split(@base_uri + '/').last load_object_into_annotation_graph(target_obj_path) } end |