Module: RdfHelper

Defined in:
app/helpers/rdf_helper.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.

Instance Method Summary collapse

Instance Method Details

#render_concept(document, concept) ⇒ Object



19
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/helpers/rdf_helper.rb', line 19

def render_concept(document, concept)

  # You can not eager load polymorphic associations. That's why we're loading
  # the collections _one_ time and remember them for further _render_concept_
  # calls in the future.
  @rdf_helper_cached_collections ||= Iqvoc::Collection.base_class.select("id, origin").all.each_with_object({}) do |c, hash|
    hash[c.id] = c.origin
  end

  document << concept.build_rdf_subject(document, nil) do |c|

    concept.collection_members.each do |collection_member|
      if @rdf_helper_cached_collections[collection_member.collection_id]
        c.Schema::memberOf(IqRdf::Coll::build_uri(@rdf_helper_cached_collections[collection_member.collection_id]))
      end
    end

    c.Schema::expires(concept.expired_at.to_s) if concept.expired_at
    c.Owl::deprecated(true) if concept.expired_at and concept.expired_at <= Date.new

    c.Skos::topConceptOf IqRdf.build_uri(Iqvoc::Concept.root_class.instance.origin) if concept.top_term?

    concept.labelings.each do |labeling|
      labeling.build_rdf(document, c)
    end

    concept.relations.each do |relation|
      relation.build_rdf(document, c)
    end

    concept.notes.each do |note|
      note.build_rdf(document, c)
    end

    concept.matches.each do |match|
      match.build_rdf(document, c)
    end

    Iqvoc::Concept.additional_association_class_names.keys.each do |class_name|
      concept.send(class_name.to_relation_name).each do |additional_object|
        additional_object.build_rdf(document, c)
      end
    end
  end
end