Class: Note::Base

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

Overview

Copyright 2011 innoQ Deutschland GmbH

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Direct Known Subclasses

SKOS::Base

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.edit_partial_name(obj) ⇒ Object



107
108
109
# File 'app/models/note/base.rb', line 107

def self.edit_partial_name(obj)
  "partials/note/edit_base"
end

.from_rdf(str) ⇒ Object

TODO: This should move to umt because it highly proprietary



72
73
74
75
# File 'app/models/note/base.rb', line 72

def self.from_rdf(str)
  h = Iqvoc::RdfHelper.split_literal(str)
  self.new(:value => h[:value], :language => h[:language])
end

.partial_name(obj) ⇒ Object



103
104
105
# File 'app/models/note/base.rb', line 103

def self.partial_name(obj)
  "partials/note/base"
end

.search_result_partial_nameObject



118
119
120
# File 'app/models/note/base.rb', line 118

def self.search_result_partial_name
  'partials/note/search_result'
end

.single_query(params = {}) ⇒ Object



111
112
113
114
115
116
# File 'app/models/note/base.rb', line 111

def self.single_query(params = {})
  query_str = build_query_string(params)

  by_query_value(query_str).
    by_language(params[:languages].to_a)
end

.view_section(obj) ⇒ Object



95
96
97
# File 'app/models/note/base.rb', line 95

def self.view_section(obj)
  "notes"
end

.view_section_sort_key(obj) ⇒ Object



99
100
101
# File 'app/models/note/base.rb', line 99

def self.view_section_sort_key(obj)
  100
end

Instance Method Details

#<=>(other) ⇒ Object



77
78
79
# File 'app/models/note/base.rb', line 77

def <=>(other)
  self.to_s.downcase <=> other.to_s.downcase
end

#build_search_result_rdf(document, result) ⇒ Object



122
123
124
125
# File 'app/models/note/base.rb', line 122

def build_search_result_rdf(document, result)
  result.Sdc::link(IqRdf.build_uri(owner.origin))
  build_rdf(document, result)
end

#from_annotation_list!(str) ⇒ Object

TODO: This should move to umt because the “list” is more or less proprietary



82
83
84
85
86
87
88
89
# File 'app/models/note/base.rb', line 82

def from_annotation_list!(str)
  str.gsub(/\[|\]/, '').split('; ').map { |a| a.split(' ') }.each do |annotation|
    namespace, predicate = annotation.first.split(":", 2)
    annotations << Note::Annotated::Base.new(:value => annotation.second,
        :namespace => namespace, :predicate => predicate)
  end
  self
end

#to_sObject



91
92
93
# File 'app/models/note/base.rb', line 91

def to_s
  "#{self.value}"
end