Class: Iqvoc::SkosImporter
- Inherits:
-
Object
- Object
- Iqvoc::SkosImporter
- Defined in:
- lib/iqvoc/skos_importer.rb
Constant Summary collapse
- FIRST_LEVEL_OBJECT_CLASSES =
[Iqvoc::Concept.base_class, Iqvoc::Collection.base_class]
- SECOND_LEVEL_OBJECT_CLASSES =
Iqvoc::Concept.labeling_classes.keys + Iqvoc::Concept.note_classes + Iqvoc::Concept.relation_classes + Iqvoc::Concept.match_classes + Iqvoc::Concept.notation_classes + Iqvoc::Concept.additional_association_classes.keys + [Iqvoc::Concept.root_class] + [Iqvoc::Collection.member_class]
Instance Method Summary collapse
-
#initialize(file, default_namespace_url, logger = Rails.logger, publish = true) ⇒ SkosImporter
constructor
A new instance of SkosImporter.
- #run ⇒ Object
Constructor Details
#initialize(file, default_namespace_url, logger = Rails.logger, publish = true) ⇒ SkosImporter
Returns a new instance of SkosImporter.
16 17 18 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 |
# File 'lib/iqvoc/skos_importer.rb', line 16 def initialize(file, default_namespace_url, logger = Rails.logger, publish = true) @file = file @publish = publish @logger = logger unless @file.is_a?(File) || @file.is_a?(Array) raise "Iqvoc::SkosImporter#import: Parameter 'file' should be a File or an Array." end # Some general Namespaces to support in any case @prefixes = { "http://www.w3.org/2004/02/skos/core#" => "skos:", "http://www.w3.org/2008/05/skos#" => "skos:", "http://www.w3.org/1999/02/22-rdf-syntax-ns#" => "rdf:", default_namespace_url => ":" } # Add the namespaces specified in the Iqvoc config Iqvoc.rdf_namespaces.each do |pref, uri| @prefixes[uri] = "#{pref.to_s}:" end @seen_first_level_objects = {} # Concept cache (don't load any concept twice from db) # Assign the default concept scheme singleton instance as a seen first level object upfront # in order to handle a missing scheme definition in ntriple data @seen_first_level_objects[Iqvoc::Concept.root_class.instance.origin] = Iqvoc::Concept.root_class.instance @new_subjects = [] # Concepts to be published later # Triples the importer doesn't understand immediately. Example: # # :a skos:prefLabel "foo". # => What is :a? Remember this and try again later # .... # :a rdf:type skos:Concept # => Now I know :a, good I remebered it's prefLabel... @unknown_second_level_triples = [] # Hash of arrays of arrays: { "_:n123" => [["pred1", "obj1"], ["pred2", "obj2"]] } @blank_nodes = {} @existing_origins = {} # To prevent the creation of first level objects we already have Iqvoc::RDFAPI::FIRST_LEVEL_OBJECT_CLASSES.each do |klass| klass.select('origin').load.each do |thing| @existing_origins[thing.origin] = klass end end end |
Instance Method Details
#run ⇒ Object
64 65 66 |
# File 'lib/iqvoc/skos_importer.rb', line 64 def run import @file end |