Class: Label::SKOSXL::Base
- Inherits:
-
Base
- Object
- Base
- Label::SKOSXL::Base
show all
- Includes:
- FirstLevelObjectValidations, Validations, Versioning
- Defined in:
- app/models/label/skosxl/base.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#origin_has_to_be_escaped
Class Method Details
.by_origin(origin) ⇒ Object
90
91
92
|
# File 'app/models/label/skosxl/base.rb', line 90
def self.by_origin(origin)
where(origin: origin)
end
|
.edit_link_partial_name ⇒ Object
121
122
123
|
# File 'app/models/label/skosxl/base.rb', line 121
def self.edit_link_partial_name
'partials/label/skosxl/edit_link_base'
end
|
.for_dashboard ⇒ Object
98
99
100
|
# File 'app/models/label/skosxl/base.rb', line 98
def self.for_dashboard
unpublished_or_follow_up.includes(:locking_user)
end
|
.new_link_partial_name ⇒ Object
def self.search_result_partial_name
'partials/labeling/skosxl/search_result'
end
117
118
119
|
# File 'app/models/label/skosxl/base.rb', line 117
def self.new_link_partial_name
'partials/label/skosxl/new_link_base'
end
|
.with_associations ⇒ Object
94
95
96
|
# File 'app/models/label/skosxl/base.rb', line 94
def self.with_associations
includes(labelings: :owner)
end
|
Instance Method Details
#associated_objects_in_editing_mode ⇒ Object
Responsible for displaying a warning message about associated objects which are currently edited y another user.
181
182
183
184
185
|
# File 'app/models/label/skosxl/base.rb', line 181
def associated_objects_in_editing_mode
{
label_relations: Label::Relation::Base.by_domain(id).range_in_edit_mode
}
end
|
#build_rdf_subject(&block) ⇒ Object
135
136
137
138
139
|
# File 'app/models/label/skosxl/base.rb', line 135
def build_rdf_subject(&block)
ns = IqRdf::Namespace.find_namespace_class(self.rdf_namespace.to_sym)
raise "Namespace '#{rdf_namespace}' is not defined in IqRdf document." unless ns
IqRdf.build_uri(self.origin, ns.build_uri(self.rdf_class), &block)
end
|
#concepts_for_labeling_class(labeling_class) ⇒ Object
141
142
143
144
|
# File 'app/models/label/skosxl/base.rb', line 141
def concepts_for_labeling_class(labeling_class)
labeling_class = labeling_class.name if labeling_class < ActiveRecord::Base labelings.select{ |l| l.class.name == labeling_class.to_s }.map(&:owner)
end
|
#from_rdf(str) ⇒ Object
156
157
158
159
160
161
|
# File 'app/models/label/skosxl/base.rb', line 156
def from_rdf(str)
raise 'invalid rdf literal' unless str =~ /^"(.+)"(@(.+))$/
self.value = $1
self.language = $3
self
end
|
#from_rdf!(str) ⇒ Object
163
164
165
166
|
# File 'app/models/label/skosxl/base.rb', line 163
def from_rdf!(str)
from_rdf(str)
save(validate: false)
end
|
#has_concept_or_label_relations? ⇒ Boolean
172
173
174
175
176
177
|
# File 'app/models/label/skosxl/base.rb', line 172
def has_concept_or_label_relations?
Iqvoc::XLLabel.additional_association_classes.each do |association_class, foreign_key|
return true if send(association_class.name.to_relation_name).count > 0
end
end
|
#notes_for_class(note_class) ⇒ Object
125
126
127
128
|
# File 'app/models/label/skosxl/base.rb', line 125
def notes_for_class(note_class)
note_class = note_class.name if note_class < ActiveRecord::Base notes.select{ |note| note.class.name == note_class }
end
|
146
147
148
149
|
# File 'app/models/label/skosxl/base.rb', line 146
def related_labels_for_relation_class(relation_class)
relation_class = relation_class.name if relation_class < ActiveRecord::Base relations.select{ |rel| rel.class.name == relation_class }.map(&:range)
end
|
#relations_for_class(relation_class) ⇒ Object
130
131
132
133
|
# File 'app/models/label/skosxl/base.rb', line 130
def relations_for_class(relation_class)
relation_class = relation_class.name if relation_class < ActiveRecord::Base relations.select{ |rel| rel.class.name == relation_class }
end
|
#to_param ⇒ Object
168
169
170
|
# File 'app/models/label/skosxl/base.rb', line 168
def to_param
origin
end
|