Class: Label::SKOSXL::Base

Inherits:
Base
  • Object
show all
Includes:
Iqvoc::Versioning
Defined in:
app/models/label/skosxl/base.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.by_origin(origin) ⇒ Object

********** Scopes



98
99
100
# File 'app/models/label/skosxl/base.rb', line 98

def self.by_origin(origin)
  where(:origin => origin)
end


129
130
131
# File 'app/models/label/skosxl/base.rb', line 129

def self.edit_link_partial_name
  "partials/label/skosxl/edit_link_base"
end

.for_dashboardObject



106
107
108
# File 'app/models/label/skosxl/base.rb', line 106

def self.for_dashboard
  unpublished_or_follow_up.includes(:locking_user)
end

def self.search_result_partial_name

'partials/labeling/skosxl/search_result'

end



125
126
127
# File 'app/models/label/skosxl/base.rb', line 125

def self.new_link_partial_name
  "partials/label/skosxl/new_link_base"
end

.with_associationsObject



102
103
104
# File 'app/models/label/skosxl/base.rb', line 102

def self.with_associations
  includes(:labelings => :owner)
end

Instance Method Details

#associated_objects_in_editing_modeObject

Responsible for displaying a warning message about associated objects which are currently edited y another user.



195
196
197
198
199
# File 'app/models/label/skosxl/base.rb', line 195

def associated_objects_in_editing_mode
  {
    :label_relations => Label::Relation::Base.by_domain(id).range_in_edit_mode
  }
end

#build_rdf_subject(&block) ⇒ Object



133
134
135
136
137
# File 'app/models/label/skosxl/base.rb', line 133

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



139
140
141
142
# File 'app/models/label/skosxl/base.rb', line 139

def concepts_for_labeling_class(labeling_class)
  labeling_class = labeling_class.name if labeling_class < ActiveRecord::Base # Use the class name string
  labelings.select{ |l| l.class.name == labeling_class.to_s }.map(&:owner)
end

#from_rdf(str) ⇒ Object



154
155
156
157
158
159
# File 'app/models/label/skosxl/base.rb', line 154

def from_rdf(str)
  raise "invalid rdf literal" unless str =~ /^"(.+)"(@(.+))$/
  self.value = $1
  self.language = $3
  self
end

#from_rdf!(str) ⇒ Object



161
162
163
164
# File 'app/models/label/skosxl/base.rb', line 161

def from_rdf!(str)
  from_rdf(str)
  save(:validate => false)
end

#has_concept_or_label_relations?Boolean

Returns:

  • (Boolean)


170
171
172
173
174
175
# File 'app/models/label/skosxl/base.rb', line 170

def has_concept_or_label_relations?
  # Check if one of the additional association methods return elements
  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

#invalid_with_full_validation?Boolean

Returns:

  • (Boolean)


188
189
190
191
# File 'app/models/label/skosxl/base.rb', line 188

def invalid_with_full_validation?
  @full_validation = true
  invalid?
end

#notes_for_class(note_class) ⇒ Object



149
150
151
152
# File 'app/models/label/skosxl/base.rb', line 149

def notes_for_class(note_class)
  note_class = note_class.name if note_class < ActiveRecord::Base # Use the class name string
  notes.select{ |note| note.class.name == note_class }
end


144
145
146
147
# File 'app/models/label/skosxl/base.rb', line 144

def related_labels_for_relation_class(relation_class)
  relation_class = relation_class.name if relation_class < ActiveRecord::Base # Use the class name string
  relations.select{ |rel| rel.class.name == relation_class }.map(&:range)
end

#save_with_full_validation!Object



177
178
179
180
# File 'app/models/label/skosxl/base.rb', line 177

def save_with_full_validation!
  @full_validation = true
  save!
end

#to_paramObject



166
167
168
# File 'app/models/label/skosxl/base.rb', line 166

def to_param
  origin
end

#valid_with_full_validation?Boolean

FIXME: should not @full_validation be set back to the value it had before??? This method changes the state!

Returns:

  • (Boolean)


183
184
185
186
# File 'app/models/label/skosxl/base.rb', line 183

def valid_with_full_validation?
  @full_validation = true
  valid?
end