Class: Ld4lVirtualCollection::Note

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/ld4l_virtual_collection/note.rb

Class Method Summary collapse

Class Method Details

.all(collection, item) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'app/models/ld4l_virtual_collection/note.rb', line 4

def self.all(collection,item)
  notes = []
  item_uri = item.id
  all_annotations_uris = LD4L::OpenAnnotationRDF::Annotation.find_by_target(item_uri)
  all_annotations_uris.each do |uri|
    anno = LD4L::OpenAnnotationRDF::Annotation.resume(uri)
    notes << anno  if anno.kind_of?(LD4L::OpenAnnotationRDF::CommentAnnotation)
  end
  notes
end

.destroy(note) ⇒ Object



41
42
43
44
# File 'app/models/ld4l_virtual_collection/note.rb', line 41

def self.destroy(note)
  # puts("*** Entering MODEL: destroy note")

end

.find(uri) ⇒ Object



46
47
48
49
# File 'app/models/ld4l_virtual_collection/note.rb', line 46

def self.find(uri)
  # puts("*** Entering MODEL: find note")
  LD4L::OpenAnnotationRDF::CommentAnnotation.new(uri)
end

.new(collection, item, *params) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/models/ld4l_virtual_collection/note.rb', line 15

def self.new(collection,item,*params)
  # puts("*** Entering MODEL: new note")
  item_uri = item.id
  item_uri = RDF::URI(item_uri)  unless item_uri.kind_of?(RDF::URI)
  note = LD4L::OpenAnnotationRDF::CommentAnnotation.new(ActiveTriples::LocalName::Minter.generate_local_name(
                  LD4L::OpenAnnotationRDF::CommentAnnotation, 5, {:prefix=>'n'} ))
  note.hasTarget = item_uri
  note.setComment("")                    unless params && params.size > 0 && params[0][:new_value]
  note.setComment(params[0][:new_value]) if     params && params.size > 0 && params[0][:new_value]
  # note.annotatedBy = p
  note.setAnnotatedAtNow
  note
end

.update(note, *params) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'app/models/ld4l_virtual_collection/note.rb', line 29

def self.update(note,*params)
  # puts("*** Entering MODEL: update note")
  item_uri = params.first[:item_id]
  item_uri = RDF::URI(item_uri)  unless item_uri.kind_of?(RDF::URI)
  note.hasTarget = item_uri
  comment = params.first[:new_value]
  note.setComment(comment)
  note.setAnnotatedAtNow
  # note.annotatedBy = p
  note
end