# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig. # License: Apache License, Version 2.0 module RTM::AR class Name < Reifiable include RTM::Name wrapper_cache parent :topic property :type, :aka => [:ty,:t], :rw => true, :type => :Topic, :wrap => true property_set :scope, :type => :Topic, :wrap => true, :add => :scope, :remove => :scope property_set :variants, :aka => :vs, :type => :Variant, :wrap => true, :create => :variant_internal, :create_aka => :cv, :create_args => [ {:name => :value, :type => [:String, :Locator]}, {:name => :scope, :type => :Collection}] def create_variant(arg1, arg2, arg3 = :nothing) if arg1.is_a?(RTM::Locator) raise("create_variant(value,scope), value: Locator, scope must be an Array") unless arg2.is_a?(Array) if arg2.empty? raise("create_variant(value,scope), value: Locator, scope must not be empty") end arg2.each do |theme| raise("create_variant(value,scope), value: Locator, scope must contain Topic/Topic-References") unless (theme.is_a?(RTM::Topic) || theme.is_a?(String) || theme.is_a?(RTM::Locator)) end return create_variant_internal(arg1, topic_map._topic_by_locator!(arg2) + self.scope.map{|t| t.__getobj__}) elsif arg1.is_a?(String) if arg3 == :nothing raise("create_variant(value,scope), value: String, scope must be an Array") unless arg2.is_a?(Array) if arg2.empty? raise("create_variant(value,scope), value: String, scope must not be empty") end arg2.each do |theme| raise("create_variant(value,scope), value: String, scope must contain Topic/Topic-References") unless (theme.is_a?(RTM::Topic) || theme.is_a?(String) || theme.is_a?(RTM::Locator)) end return create_variant_internal(arg1, topic_map._topic_by_locator!(arg2) + self.scope.map{|t| t.__getobj__}) elsif (arg2.is_a?(Locator) || arg2.is_a?(String)) if ((arg2 == RTM::PSI[:String]) || (arg2 == topic_map.create_locator(RTM::PSI[:String]))) return create_variant_internal(arg1, topic_map.create_locator(RTM::PSI[:String]), topic_map._topic_by_locator!(arg3) + self.scope.map{|t| t.__getobj__}) elsif ((arg2 == RTM::PSI[:IRI]) || (arg2 == topic_map.create_locator(RTM::PSI[:IRI]))) return create_variant_internal(arg1, topic_map.create_locator(RTM::PSI[:IRI]), topic_map._topic_by_locator!(arg3) + self.scope.map{|t| t.__getobj__}) elsif ((arg2 == RTM::PSI[:XML]) || (arg2 == topic_map.create_locator(RTM::PSI[:XML]))) return create_variant_internal(arg1, topic_map.create_locator(RTM::PSI[:XML]), topic_map._topic_by_locator!(arg3) + self.scope.map{|t| t.__getobj__}) else raise("create_variant(value,datatype,scope), value: String, unknown datatype") end else raise("create_variant(value,datatype,scope), datatype must be a String (identifier) or Locator") end else raise "create_variant: value not a Locator or String" end end property :value, :rw => true, :type => :String, :aka => :v equality [:value, :type, :scope, :parent] end TopicName = Name class Variant < Reifiable include RTM::Variant wrapper_cache parent :name, :aka => :topic_name property :value, :rw => true, :type => :String, :aka => :v property :datatype, :rw => true, :type => :Locator #, :wrap => true property_set :scope, :type => :Topic, :wrap => true, :add => :scope, :remove => :scope equality [:value, :datatype, :scope, :parent] end class Occurrence < Reifiable include RTM::Occurrence wrapper_cache parent :topic property :value, :rw => true, :type => :String, :aka => :v property :datatype, :rw => true, :type => :String property_set :scope, :type => :Topic, :wrap => true, :add => :scope, :remove => :scope property :type, :aka => [:ty,:t], :rw => true, :type => :Topic, :wrap => true equality [:value, :datatype, :scope, :type, :parent] end end