Sha256: 4cd9092ac28a42377801082dd1dfdc48aba52be74f8f524e29e6964938d7856e

Contents?: true

Size: 1.49 KB

Versions: 4

Compression:

Stored size: 1.49 KB

Contents

require 'yowl'

module YOWL

  class Import < YOWL::LabelledDocObject
    
    attr_reader :importedSchema
    attr_reader :importedOntology
 
    def initialize(resource_, schema_)
      super(resource_, schema_)
      
      @importedSchema = schema_.repository.getSchemaForImport(self)
      @importedOntology = @importedSchema ? @importedSchema.ontology : nil
      
      if @importedSchema.nil?
        puts "WARNING: #{@schema.fileName}: Created Import #{uri} but did not find schema for it "
      end
      if @importedOntology.nil?
        puts "WARNING: #{@schema.fileName}: Created Import #{uri} but did not find ontology for it "
      end
    end
    
    def name
      if @importedSchema
        return @importedSchema.name
      end
      prefix, ns = @schema.prefixForNamespace(uri)
      if prefix
        return prefix
      end
      return short_name
    end
    
    def resourceNameHtml
      return "#{@name}.html"
    end
    
    def imports
      return @importedOntology ? @importedOntology.imports : []
    end
    
    def isExternal?
      return (@importedSchema.nil? and @importedOntology.nil?)
    end

    #
    # See YOWL::Individual::classWithURI(uri)
    #    
    def classWithURI(uri_)
      if isExternal?
        return nil
      end
      if @importedSchema
        return @importedSchema.classWithURI(uri_)
      end
      puts "WARNING: Cannot check whether class #{uri_.to_s} exists in imported ontology #{uri} as this ontology is not loaded"
      return nil
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
yowl-0.4.2 lib/yowl/import.rb
yowl-0.4.1 lib/yowl/import.rb
yowl-0.4 lib/yowl/import.rb
yowl-0.4.pre lib/yowl/import.rb