Class: Concept::Relation::SKOS::Base

Inherits:
Base
  • Object
show all
Defined in:
app/models/concept/relation/skos/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.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

by_owner, by_owner_origin, by_target_origin, edit_partial_name, partial_name, published, #rank, #rank=, rankable?, reverse_relation_class, singular?, target_editor_selectable, target_in_edit_mode, view_section, view_section_sort_key

Class Method Details

.build_from_rdf(subject, predicate, object) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'app/models/concept/relation/skos/base.rb', line 21

def self.build_from_rdf(subject, predicate, object)
  raise "Labeling::SKOS::Base#build_from_rdf: Subject (#{subject}) must be a Concept." unless subject.is_a?(Concept::Base)
  raise "Labeling::SKOS::Base#build_from_rdf: Object (#{object}) must be a Concept." unless object.is_a?(Concept::Base)

  if subject.send(self.name.to_relation_name).select{|rel| rel.target_id == object.id || rel.target == object}.empty?
    subject.send(self.name.to_relation_name) << self.new(:target => object)
  end
  if self.reverse_relation_class && object.send(self.reverse_relation_class.name.to_relation_name).select{|rel| rel.target_id == subject.id || rel.target == subject}.empty?
    object.send(self.reverse_relation_class.name.to_relation_name) << self.reverse_relation_class.new(:target => subject)
  end
end

Instance Method Details

#build_rdf(document, subject) ⇒ Object



33
34
35
# File 'app/models/concept/relation/skos/base.rb', line 33

def build_rdf(document, subject)
  subject.send(self.rdf_namespace.camelcase).send(self.rdf_predicate, IqRdf.build_uri(target.origin))
end