Class: LD4L::OpenAnnotationRDF::Annotation
- Inherits:
-
ActiveTriples::Resource
- Object
- ActiveTriples::Resource
- LD4L::OpenAnnotationRDF::Annotation
- Defined in:
- lib/ld4l/open_annotation_rdf/annotation.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.localname_prefix ⇒ Object
readonly
Returns the value of attribute localname_prefix.
Class Method Summary collapse
Instance Method Summary collapse
-
#getBody ⇒ Object
Get the
ActiveTriples::Resource
instance holding the body of this annotation. -
#persist! ⇒ Object
Save all annotation and annotation body triples to the triple store.
-
#setAnnotatedAtNow ⇒ Object
Set annotatedAt property to now.
Class Attribute Details
.localname_prefix ⇒ Object (readonly)
Returns the value of attribute localname_prefix.
5 6 7 |
# File 'lib/ld4l/open_annotation_rdf/annotation.rb', line 5 def localname_prefix @localname_prefix end |
Class Method Details
.resume(uri_or_str) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/ld4l/open_annotation_rdf/annotation.rb', line 20 def self.resume(uri_or_str) # Let ActiveTriples::Resource validate uri_or_str when creating new Annotation a = new(uri_or_str) # get motivatedBy m = a.get_values(:motivatedBy) # TODO: Should m's class be validated? I've seen it be RDF::Vocabulary::Term and RDF::URI. For now, removing the validation. return a unless m.kind_of?(Array) && m.size > 0 # return a unless m.kind_of?(Array) && m.size > 0 && (m.first.kind_of?(RDF::Vocabulary::Term) || m.first.kind_of?(RDF::URI) # motivatedBy is set m_uri = m.first # currently only support commenting and tagging return LD4L::OpenAnnotationRDF::CommentAnnotation.new(uri_or_str) if m_uri == RDFVocabularies::OA.commenting return a unless m_uri == RDFVocabularies::OA.tagging # Tagging can be TagAnnotation or SemanticTagAnnotation. Only way to tell is by checking type of body. sta = LD4L::OpenAnnotationRDF::SemanticTagAnnotation.new(uri_or_str) stb = sta.getBody return sta if stb.type.include?(RDFVocabularies::OA.SemanticTag) ta = LD4L::OpenAnnotationRDF::TagAnnotation.new(uri_or_str) tb = ta.getBody return ta if tb.type.include?(RDFVocabularies::OA.Tag) # can't match to a known annotation type, so return as generic annotation return a end |
Instance Method Details
#getBody ⇒ Object
Get the ActiveTriples::Resource
instance holding the body of this annotation.
55 56 57 |
# File 'lib/ld4l/open_annotation_rdf/annotation.rb', line 55 def getBody @body end |
#persist! ⇒ Object
TODO:
What to return if annotation persists fine, but body fails to persist?
Save all annotation and annotation body triples to the triple store.
73 74 75 76 77 |
# File 'lib/ld4l/open_annotation_rdf/annotation.rb', line 73 def persist! persisted = super # persist annotation body_persisted = persisted && @body ? @body.persist! : false # persist body persisted end |
#setAnnotatedAtNow ⇒ Object
Set annotatedAt property to now.
63 64 65 |
# File 'lib/ld4l/open_annotation_rdf/annotation.rb', line 63 def setAnnotatedAtNow set_value(:annotatedAt, Time.now.utc.iso8601(0)) end |