triannon 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/triannon/annotation.rb +14 -7
- data/app/services/triannon/ldp_loader.rb +8 -5
- data/app/services/triannon/ldp_to_oa_mapper.rb +11 -3
- data/lib/triannon/graph.rb +5 -7
- data/lib/triannon/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38673b232f1a66c6710ed058242fcd79fb49ec92
|
4
|
+
data.tar.gz: eedb16b6f71893c5a8559d3f45628790392eaf61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4791ad9be0bb23424dfdfe2de1e63249a527d30aa8c908f5b2718a4c166c0d9f8a013271f7a349ba0d6d1c250675782bacd27975dfd14d9d57b15ce0919e342
|
7
|
+
data.tar.gz: dc163e2632dfb58b34f4bd07517e04701fc05ce8a54f8c047b3829289f575b00c3de726d993d6e734decc0c997ed55cb0990f7c696b9a5e642d83f2b520c853e
|
@@ -26,11 +26,12 @@ module Triannon
|
|
26
26
|
a
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
# @param [String] id the unique id of the annotation. Can include base_uri prefix or omit it.
|
30
|
+
def self.find(id)
|
31
|
+
oa_graph = Triannon::LdpLoader.load id
|
31
32
|
anno = Triannon::Annotation.new
|
32
33
|
anno.graph = oa_graph
|
33
|
-
anno.id =
|
34
|
+
anno.id = id
|
34
35
|
anno
|
35
36
|
end
|
36
37
|
|
@@ -65,9 +66,13 @@ module Triannon
|
|
65
66
|
end
|
66
67
|
end
|
67
68
|
|
68
|
-
# @param
|
69
|
+
# @param either a Triannon::Graph or RDF::Graph object
|
69
70
|
def graph= g
|
70
|
-
|
71
|
+
if g.is_a? Triannon::Graph
|
72
|
+
@graph = g
|
73
|
+
elsif g.kind_of? RDF::Graph
|
74
|
+
@graph = Triannon::Graph.new g
|
75
|
+
end
|
71
76
|
end
|
72
77
|
|
73
78
|
# @return json-ld representation of anno with OpenAnnotation context as a url
|
@@ -94,8 +99,10 @@ protected
|
|
94
99
|
|
95
100
|
# Add annotation to Solr as a Solr document
|
96
101
|
def solr_save
|
97
|
-
#
|
98
|
-
|
102
|
+
# to be certain we are in sync, and to get the anno id within the graph, reload
|
103
|
+
# the graph from Trianon storage
|
104
|
+
graph_from_storage = Triannon::LdpLoader.load id
|
105
|
+
solr_writer.add(graph_from_storage.solr_hash)
|
99
106
|
end
|
100
107
|
|
101
108
|
# Delete annotation from Solr
|
@@ -4,8 +4,10 @@ module Triannon
|
|
4
4
|
# Loads an existing Annotation from the LDP server
|
5
5
|
class LdpLoader
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
|
8
|
+
# @param [String] id the unique id of the annotation. Can include base_uri prefix or omit it.
|
9
|
+
def self.load id
|
10
|
+
l = Triannon::LdpLoader.new id
|
9
11
|
l.load_anno_container
|
10
12
|
l.load_bodies
|
11
13
|
l.load_targets
|
@@ -21,15 +23,16 @@ module Triannon
|
|
21
23
|
|
22
24
|
attr_accessor :ldp_annotation
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
+
# @param [String] id the unique id of the annotation. Can include base_uri prefix or omit it.
|
27
|
+
def initialize id = nil
|
28
|
+
@id = id
|
26
29
|
@base_uri = Triannon.config[:ldp_url]
|
27
30
|
@ldp_annotation = Triannon::AnnotationLdp.new
|
28
31
|
end
|
29
32
|
|
30
33
|
# load annotation container object into @ldp_annotation's (our Triannon::AnnotationLdp object) graph
|
31
34
|
def load_anno_container
|
32
|
-
load_object_into_annotation_graph(@
|
35
|
+
load_object_into_annotation_graph(@id)
|
33
36
|
end
|
34
37
|
|
35
38
|
# load body objects into @ldp_annotation's (our Triannon::AnnotationLdp object) graph
|
@@ -15,14 +15,22 @@ module Triannon
|
|
15
15
|
def initialize ldp_anno
|
16
16
|
@ldp_anno = ldp_anno
|
17
17
|
@ldp_anno_graph = ldp_anno.stripped_graph
|
18
|
-
|
18
|
+
g = RDF::Graph.new
|
19
|
+
@oa_graph = Triannon::Graph.new g
|
19
20
|
end
|
20
21
|
|
21
22
|
def extract_base
|
23
|
+
root_subject_solns = @ldp_anno_graph.query Triannon::Graph.anno_query
|
24
|
+
if root_subject_solns.count == 1
|
25
|
+
@id = root_subject_solns[0].s.to_s.split('/').last
|
26
|
+
base_url = Triannon.config[:triannon_base_url]
|
27
|
+
base_url.strip!
|
28
|
+
base_url.chop! if base_url[-1] == '/'
|
29
|
+
@root_uri = RDF::URI.new(base_url + "/#{@id}")
|
30
|
+
end
|
31
|
+
|
22
32
|
@ldp_anno_graph.each_statement do |stmnt|
|
23
33
|
if stmnt.predicate == RDF.type && stmnt.object == RDF::OpenAnnotation.Annotation
|
24
|
-
@id = stmnt.subject.to_s.split('/').last
|
25
|
-
@root_uri = RDF::URI.new(Triannon.config[:triannon_base_url] + "/#{@id}")
|
26
34
|
@oa_graph << [@root_uri, RDF.type, RDF::OpenAnnotation.Annotation]
|
27
35
|
elsif stmnt.predicate == RDF::OpenAnnotation.motivatedBy
|
28
36
|
@oa_graph << [@root_uri, stmnt.predicate, stmnt.object]
|
data/lib/triannon/graph.rb
CHANGED
@@ -49,17 +49,15 @@ module Triannon
|
|
49
49
|
hash_from_json.to_json
|
50
50
|
end
|
51
51
|
|
52
|
-
#
|
53
|
-
#
|
54
|
-
# @param [String] the Triannon id for this anno. Defaults to nil, in which case id_as_url will be used.
|
52
|
+
# DO NOT CALL before anno is stored.
|
53
|
+
# The graph should have an assigned url for the @id of the root; it shouldn't be a blank node
|
55
54
|
# @return [Hash] a hash to be written to Solr, populated appropriately
|
56
|
-
def solr_hash
|
55
|
+
def solr_hash
|
57
56
|
doc_hash = {}
|
58
57
|
# chars in Solr/Lucene query syntax are a big pain in Solr id fields, so we only use
|
59
58
|
# the uuid portion of the Triannon anno id, not the full url
|
60
|
-
|
61
|
-
|
62
|
-
doc_hash[:id] = solr_id.sub(/^\//, "")
|
59
|
+
solr_id = id_as_url.sub(Triannon.config[:triannon_base_url], "")
|
60
|
+
doc_hash[:id] = solr_id.sub(/^\//, "") # remove first char slash if it is there
|
63
61
|
|
64
62
|
# use short strings for motivation field
|
65
63
|
doc_hash[:motivation] = motivated_by.map { |m| m.sub(RDF::OpenAnnotation.to_s, "") }
|
data/lib/triannon/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: triannon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-02-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 4.2.0
|
21
|
+
version: 4.2.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 4.2.0
|
28
|
+
version: 4.2.0
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: linkeddata
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -158,28 +158,28 @@ dependencies:
|
|
158
158
|
requirements:
|
159
159
|
- - "~>"
|
160
160
|
- !ruby/object:Gem::Version
|
161
|
-
version:
|
161
|
+
version: 3.1.0
|
162
162
|
type: :development
|
163
163
|
prerelease: false
|
164
164
|
version_requirements: !ruby/object:Gem::Requirement
|
165
165
|
requirements:
|
166
166
|
- - "~>"
|
167
167
|
- !ruby/object:Gem::Version
|
168
|
-
version:
|
168
|
+
version: 3.1.0
|
169
169
|
- !ruby/object:Gem::Dependency
|
170
170
|
name: rspec-rails
|
171
171
|
requirement: !ruby/object:Gem::Requirement
|
172
172
|
requirements:
|
173
173
|
- - "~>"
|
174
174
|
- !ruby/object:Gem::Version
|
175
|
-
version:
|
175
|
+
version: 3.1.0
|
176
176
|
type: :development
|
177
177
|
prerelease: false
|
178
178
|
version_requirements: !ruby/object:Gem::Requirement
|
179
179
|
requirements:
|
180
180
|
- - "~>"
|
181
181
|
- !ruby/object:Gem::Version
|
182
|
-
version:
|
182
|
+
version: 3.1.0
|
183
183
|
- !ruby/object:Gem::Dependency
|
184
184
|
name: engine_cart
|
185
185
|
requirement: !ruby/object:Gem::Requirement
|