triannon 0.5.5 → 0.5.6

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: bfed3de76ceff6faec0e84730e6d0e66177c0e2c
4
- data.tar.gz: 08d53c74dc0facd2974a95640101e971eadcf0df
3
+ metadata.gz: 54a4a66f7d3970f51d9378924c414dc14ac866fe
4
+ data.tar.gz: d1454821e3b02177c5f3c81e72c06ddd556c460a
5
5
  SHA512:
6
- metadata.gz: c0d4eb37e3692bdf5b25b94bf931fe581ed3653cc1d417a0e74aeedbf33f92c2cdd3ae4b548db8a4f03fe0c5b2d5fe025c7c094bf922e09c892bc40877b67f97
7
- data.tar.gz: 0910a11f4e22e70d90a14538918a7f73f142d7adc6fb7cde4f1e3f50a4f1e39dc24c5caac307089d4620d54d0d7c0d7b13d393e1ca7c964b48e3116504b91172
6
+ metadata.gz: 5dade8b77d9d3f4aa003ec5f327d9d8cc6ac6707999392d2f5d8eb7defc434cc5fdf30dede163d74611aa113265c8546cc3d3724c12d055c4a47094ce1633339
7
+ data.tar.gz: 34f4a938d2ab43fd3a2c410c2fa7d4c9fd922bce5675bcab518f42f84eb81ee8f592e402b92a57ae53311c9fc05aac41a772bbe3f5f17c7935b7e05f4c9a7d7f
data/README.md CHANGED
@@ -87,6 +87,8 @@ Note that OA (Open Annotation) is the default context if none is specified.
87
87
  ### Create an anno
88
88
  `POST`: `http://(host)/annotations`
89
89
  * the body of the HTTP request should contain the annotation, as jsonld, turtle, or rdfxml
90
+ * Wrap the annotation in an object, as such:
91
+ * `{ "commit" => "Create Annotation", "annotation" => { "data" => oa_jsonld } }`
90
92
  * the `Content-Type` header should be the mime type matching the body
91
93
  * the anno to be created should NOT already have an assigned @id
92
94
  * to get a particular format back, use the HTTP `Accept` header
@@ -43,9 +43,12 @@ module Triannon
43
43
 
44
44
  def save
45
45
  _run_save_callbacks do
46
- # check if valid?
47
- graph
46
+ # TODO: check if valid anno?
48
47
  @id = Triannon::LdpWriter.create_anno self if graph && graph.size > 2
48
+ # reload from storage to get the anno id within the graph
49
+ # TODO: do graph manipulation to add id instead?
50
+ @graph = Triannon::LdpLoader.load id
51
+ id
49
52
  end
50
53
  end
51
54
 
@@ -99,10 +102,7 @@ protected
99
102
 
100
103
  # Add annotation to Solr as a Solr document
101
104
  def solr_save
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_hash = graph_from_storage.solr_hash
105
+ solr_hash = graph.solr_hash if graph && graph.id_as_url
106
106
  solr_writer.add(solr_hash) if solr_hash && solr_hash.size > 0
107
107
  end
108
108
 
@@ -92,8 +92,8 @@ module Triannon
92
92
  # @return [Array<RDF::Statements>] the RDF statements represented in the ttl
93
93
  def statements_from_ttl_minus_fedora ttl
94
94
  # RDF::Turtle::Reader.new(ttl).statements.to_a
95
- g = RDF::Graph.new.from_ttl(ttl)
96
- RDF::FCRepo4.remove_fedora_triples(g).statements
95
+ g = RDF::Graph.new.from_ttl(ttl) if ttl
96
+ RDF::FCRepo4.remove_fedora_triples(g).statements if g
97
97
  end
98
98
 
99
99
  def conn
@@ -34,8 +34,10 @@ module Triannon
34
34
  # May be a compound id, such as uuid1/t/uuid2, in which case the LDP container object uuid2 and its children
35
35
  # are deleted from the LDP store, but LDP containers uuid1/t and uuid1 are not deleted from the LDP store.
36
36
  def self.delete_container id
37
- ldpw = Triannon::LdpWriter.new nil
38
- ldpw.delete_containers id
37
+ if id && id.size > 0
38
+ ldpw = Triannon::LdpWriter.new nil
39
+ ldpw.delete_containers id
40
+ end
39
41
  end
40
42
 
41
43
  class << self
@@ -101,6 +103,7 @@ module Triannon
101
103
  # e.g. [@base_uri/(uuid1)/t/(uuid2), @base_uri/(uuid1)/t/(uuid3)] or [@base_uri/(uuid)] or (uuid)
102
104
  # @return true if a resource was deleted; false otherwise
103
105
  def delete_containers ldp_container_uris
106
+ return false if !ldp_container_uris || ldp_container_uris.empty?
104
107
  if ldp_container_uris.kind_of? String
105
108
  ldp_container_uris = [ldp_container_uris]
106
109
  end
@@ -126,6 +129,7 @@ module Triannon
126
129
  # or (anno_id)/b for a body resource (inside the body container of anno_id)
127
130
  # @return [String] uuid representing the unique id of the newly created LDP container
128
131
  def create_resource ttl, parent_path = nil
132
+ return if !ttl || ttl.empty?
129
133
  resp = conn.post do |req|
130
134
  req.url parent_path if parent_path
131
135
  req.headers['Content-Type'] = 'application/x-turtle'
@@ -1,3 +1,3 @@
1
1
  module Triannon
2
- VERSION = "0.5.5"
2
+ VERSION = "0.5.6"
3
3
  end
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.5
4
+ version: 0.5.6
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-03-12 00:00:00.000000000 Z
13
+ date: 2015-03-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails