Sha256: 3e10eb812d34be277f949da1f7ad72aed939beef135d6759d75b5c4aeec52178

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 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
    loop do
      labels = Iqvoc::XLLabel.base_class.published
                             .order('id')
                             .limit(100)
                             .offset(offset)

      limit = labels.size < 100 ? labels.size : 100
      break if labels.size.zero?

      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

ActiveSupport.on_load :rdf_export_before_save do
  class SkosExporter
    include SkosXlExporterExtensions
  end

  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

1 entries across 1 versions & 1 rubygems

Version Path
iqvoc_skosxl-2.9.1 config/initializers/iqvoc.rb