Sha256: e2af0a325455d2ede9639c2eec19a7ab5d503682f1182597bee6de801157d073

Contents?: true

Size: 1.42 KB

Versions: 4

Compression:

Stored size: 1.42 KB

Contents

silence_warnings do
  Iqvoc::Label = nil
end

Iqvoc.searchable_class_names = {
    'Label::SKOSXL::Base' => 'xllabels',
    'Labeling::SKOSXL::Base' => 'labels',
    'Labeling::SKOSXL::PrefLabel' => 'pref_labels',
    'Labeling::SKOSXL::AltLabel' => 'alt_labels'
}

module SkosXlExporterExtensions
  extend ActiveSupport::Concern
  include LabelsHelper

  def add_skos_xl_labels(document)
    @logger.info 'Exporting xl labels...'

    offset = 0
    while true
      labels = Iqvoc::XLLabel.base_class.published.published.order('id').limit(100).offset(offset)
      limit = labels.size < 100 ? labels.size : 100
      break if labels.size == 0

      labels.each do |label|
        render_label_rdf(document, label)
      end

      @logger.info "Labels #{offset+1}-#{offset+limit} exported."
      offset += labels.size # Size is important!
    end

    @logger.info "Finished exporting xl labels (#{offset} labels exported)."
  end
end

module Iqvoc
  class SkosExporter
    include SkosXlExporterExtensions
  end
end

ActiveSupport.on_load :rdf_export_before_save do
  add_skos_xl_labels(@document)
end

ActiveSupport.on_load :skos_importer do
  SkosImporter.prepend_first_level_object_classes(Iqvoc::XLLabel.base_class)
  SkosImporter.second_level_object_classes +=
    [Label::SKOSXL::Properties::LiteralForm] +
    Iqvoc::XLLabel.note_classes +
    Iqvoc::XLLabel.relation_classes +
    Iqvoc::XLLabel.additional_association_classes.keys
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
iqvoc_skosxl-2.9.0 config/initializers/iqvoc.rb
iqvoc_skosxl-2.8.1 config/initializers/iqvoc.rb
iqvoc_skosxl-2.8.0 config/initializers/iqvoc.rb
iqvoc_skosxl-2.7.0 config/initializers/iqvoc.rb