ld4l-open_annotation_rdf 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dead51a1f44d03f97a677dbefc02627755cde61f
4
- data.tar.gz: c112a5480577c43081b804fedd85ee2ec26da318
3
+ metadata.gz: 996d421c8a58b14c18ad5331339cc3b4a47aabcb
4
+ data.tar.gz: ebfc32df7ef5b5032f9a6cbd46e1ec4fc0752b51
5
5
  SHA512:
6
- metadata.gz: 6e0930ad32df385a13d6c6ea9b70c3b2793dcabeefa5d32bd51de3e11d72aeecce613eb5488cd2dd3669f8fa555cc1e683ff2c6ee08b80db9d07518d6cfbb7dc
7
- data.tar.gz: 5aa4a659b04fd50778cde628597470700bb75c9bb90a58535b3c81f827811c8b85c6b769ed971f785a1c28206336fe9d2513c0ad4aea62a3c60ed71b25930dc8
6
+ metadata.gz: 869d278fc412af9c22df0397dd19060605d4dd07d82bd4e46a407dc6f38507fdb73e20acbc04c1a809e4ea3bf6c73ecddd2d0aa3fdd66241e6734bb69b8c2015
7
+ data.tar.gz: 0e1cfbad3520be214c5943787d625b40caeab7554edeec229dd9036015102ef0c3d3df06c52e45e213ff32e59f7eb674ffd74fc4ac3cebcb217f211a37b04a31
@@ -75,6 +75,36 @@ module LD4L
75
75
  body_persisted = persisted && @body ? @body.persist! : false # persist body
76
76
  persisted
77
77
  end
78
+
79
+ ##
80
+ # Find annotation by target.
81
+ #
82
+ # @param [String, RDF::URI] uri for the work
83
+ #
84
+ # @return true if annotation successfully persisted; otherwise, false
85
+ #
86
+ # @todo What to return if annotation persists fine, but body fails to persist?
87
+ def self::find_by_target(target_uri)
88
+ raise ArgumentError, 'target_uri argument must be a uri string or an instance of RDF::URI' unless
89
+ target_uri.kind_of?(String) && target_uri.size > 0 || target_uri.kind_of?(RDF::URI)
90
+
91
+ # raise ArgumentError, 'repository argument must be an instance of RDF::Repository' unless
92
+ # repository.kind_of?(RDF::Repository)
93
+
94
+ target_uri = RDF::URI(target_uri) unless target_uri.kind_of?(RDF::URI)
95
+
96
+ repo = ActiveTriples::Repositories.repositories[repository]
97
+ query = RDF::Query.new({
98
+ :annotation => {
99
+ RDF.type => RDFVocabularies::OA.Annotation,
100
+ RDFVocabularies::OA.hasTarget => target_uri,
101
+ }
102
+ })
103
+ annotations = []
104
+ results = query.execute(repo)
105
+ results.each { |r| annotations << r.to_hash[:annotation] }
106
+ annotations
107
+ end
78
108
  end
79
109
  end
80
110
  end
@@ -12,7 +12,7 @@ module LD4L
12
12
  #
13
13
  # @param [String]
14
14
  #
15
- # @return instance of SemanticTagBody
15
+ # @return instance of CommentAnnotation
16
16
  def setComment(comment)
17
17
  @body = LD4L::OpenAnnotationRDF::CommentBody.new(
18
18
  ActiveTriples::LocalName::Minter.generate_local_name(
@@ -24,6 +24,15 @@ module LD4L
24
24
  @body
25
25
  end
26
26
 
27
+ ##
28
+ # Get the value of the comment stored in a comment annotation.
29
+ #
30
+ # @return text value of comment
31
+ def getComment
32
+ comments = @body.content
33
+ comments && comments.size > 0 ? comments.first : ""
34
+ end
35
+
27
36
  ##
28
37
  # Special processing for new and resumed CommentAnnotations
29
38
  #
@@ -27,7 +27,7 @@ module LD4L
27
27
  term_uri = RDF::URI(term_uri) unless term_uri.kind_of?(RDF::URI)
28
28
 
29
29
  # find usage by Annotations
30
- graph = ActiveTriples::Repositories.repositories[repository]
30
+ repo = ActiveTriples::Repositories.repositories[repository]
31
31
  query = RDF::Query.new({
32
32
  :annotation => {
33
33
  RDF.type => RDFVocabularies::OA.Annotation,
@@ -35,7 +35,7 @@ module LD4L
35
35
  }
36
36
  })
37
37
  annotations = []
38
- results = query.execute(graph)
38
+ results = query.execute(repo)
39
39
  results.each { |r| annotations << r.to_hash[:annotation] }
40
40
  annotations
41
41
  end
@@ -8,6 +8,15 @@ module LD4L
8
8
 
9
9
  # TODO: Should a tag be destroyed when the last annotation referencing the tag is destroyed?
10
10
 
11
+ ##
12
+ # Get the value of the tag stored in a tag annotation.
13
+ #
14
+ # @return text value of tag
15
+ def getTag
16
+ tags = @body.tag
17
+ tags && tags.size > 0 ? tags.first : "" # TODO What is the appropriate default value for a tag?
18
+ end
19
+
11
20
  ##
12
21
  # Set the hasBody property to the URI of the one and only TagBody holding the tag value. Create a new TagBody
13
22
  # if one doesn't exist with this value.
@@ -28,14 +28,14 @@ module LD4L
28
28
  tag_uri = tb.rdf_subject
29
29
 
30
30
  # find usage by Annotations
31
- graph = ActiveTriples::Repositories.repositories[repository]
31
+ repo = ActiveTriples::Repositories.repositories[repository]
32
32
  query = RDF::Query.new({
33
33
  :annotation => {
34
34
  RDF.type => RDFVocabularies::OA.Annotation,
35
35
  RDFVocabularies::OA.hasBody => tag_uri,
36
36
  }
37
37
  })
38
- results = query.execute(graph)
38
+ results = query.execute(repo)
39
39
 
40
40
  # process results
41
41
  annotations = []
@@ -54,7 +54,7 @@ module LD4L
54
54
  raise ArgumentError, 'Argument must be a string with at least one character' unless
55
55
  tag_value.kind_of?(String) && tag_value.size > 0
56
56
 
57
- graph = ActiveTriples::Repositories.repositories[repository]
57
+ repo = ActiveTriples::Repositories.repositories[repository]
58
58
  query = RDF::Query.new({
59
59
  :tagbody => {
60
60
  RDF.type => RDFVocabularies::OA.Tag,
@@ -63,7 +63,7 @@ module LD4L
63
63
  })
64
64
 
65
65
  tagbody = nil
66
- results = query.execute(graph)
66
+ results = query.execute(repo)
67
67
  unless( results.empty? )
68
68
  tagbody_uri = results[0].to_hash[:tagbody]
69
69
  tagbody = LD4L::OpenAnnotationRDF::TagBody.new(tagbody_uri)
@@ -1,5 +1,5 @@
1
1
  module LD4L
2
2
  module OpenAnnotationRDF
3
- VERSION = "0.0.10"
3
+ VERSION = "0.0.11"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ld4l-open_annotation_rdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - E. Lynette Rayle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-15 00:00:00.000000000 Z
11
+ date: 2015-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdf
@@ -211,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
211
  version: '0'
212
212
  requirements: []
213
213
  rubyforge_project:
214
- rubygems_version: 2.2.2
214
+ rubygems_version: 2.4.3
215
215
  signing_key:
216
216
  specification_version: 4
217
217
  summary: OpenAnnotation RDF models.
@@ -226,4 +226,3 @@ test_files:
226
226
  - spec/ld4l/open_annotation_rdf/tag_body_spec.rb
227
227
  - spec/ld4l/open_annotation_rdf_spec.rb
228
228
  - spec/spec_helper.rb
229
- has_rdoc: