def post(self): #-------------- name = self.full_uri text = self.get_argument('annotation', '').strip() if self.get_argument('action') == 'Annotate' and text: repo = options.repository target = self.get_argument('target') recording = repo.get_recording(target, with_signals=False, open_dataset=False) ann = Annotation.Note(recording.make_uri(prefix='annotation'), target, text, creator='%s/user/%s' % (repo.uri, self.current_user) if self.current_user is not None else None) repo.extend_graph(recording.graph.uri, ann.metadata_as_string()) self._show_contents(name, False)
r.save_metadata_to_graph(g) s = MyRecording.create_from_graph('http://example.org/uri1', g) assert(r.metadata_as_string(rdf.Format.TURTLE) == s.metadata_as_string(rdf.Format.TURTLE)) s.comment='From graph' user = '******' a1 = 'http://example.org/annotation/1' a2 = 'http://example.org/annotation/2' a3 = 'http://example.org/annotation/3' t1 = 'http://example.org/onto#tag1' t2 = 'http://example.org/onto#tag2' t3 = 'http://example.org/onto#tag3' a = Annotation.Note(a1, s.uri, user, 'A test recording...') b = Annotation.Tag(a2, s.uri, user, t1) c = Annotation(a3, s.uri, user, tags=[t2, t3], text='Multiple tags') #print a.metadata_as_string(rdf.Format.TURTLE) #print b.metadata_as_string(rdf.Format.TURTLE) #print c.metadata_as_string(rdf.Format.TURTLE) c.save_metadata_to_graph(g) d = Annotation.create_from_graph(a3, g) assert(c.metadata_as_string(rdf.Format.TURTLE) == d.metadata_as_string(rdf.Format.TURTLE)) s.metadata['zz'] = [ a, b, c ] print s.metadata_as_string(rdf.Format.TURTLE)