# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig. # License: Apache License, Version 2.0 module RTM::Axes module Topics def self.extended(k) k.extend ArrayProxy end def result self.map{|i| i.construct} end alias :tmapi :result # ---- characteristics-axis ----------------------------------------------# # Returns all Names and Occurrences of these Topics. # If an identifier is given, only those Names and Occurrences are returned, # whose type or supertypes include the identifier. # # Identifier may be a topic reference. # # The result may be empty. # # :call-seq: # characteristics -> Array of Names and Occurrences # characteristics(identifier) -> Array of Names and Occurrences # def characteristics(type=:any) _res = self.inject([]){|all,containee| all << containee.send(:characteristics,type)}.flatten ### NO UNIQUE NEEDED _res = _res.extend(Characteristics) _res end # ---- indicators-axis ---------------------------------------------------# # Returns all indicators (subject identifiers) of these Topics. # # The result may be empty. # # :call-seq: # indicators -> Array of Strings # def indicators #self = Array of TopicProxies #containee: RTM::Axes::Topic #send -> Array of Strings self.inject([]){|all,containee| all << containee.send(:indicators)}.flatten ### NO UNIQUE NEEDED end # ---- item-axis ---------------------------------------------------------# # Returns one item identifier for each of these Topics, only if # if the Topic has an item identifier. # # The result may be an empty Array. # # :call-seq: # item -> Array of Strings # def item #self = Array of TopicProxies #containee: RTM::Axes::Topic #send -> Array of (String or nil)s _res = self.inject([]){|all,containee| all << containee.send(:item)}.flatten _res = _res.select{|i| i} ### NO UNIQUE NEEDED end # ---- locators-axis -----------------------------------------------------# # Returns all subject locators of these Topics. # # The result may be empty. # # :call-seq: # locators -> Array of Strings # def locators self.inject([]){|all,containee| all << containee.send(:locators)}.flatten ### NO UNIQUE NEEDED end # ---- players-axis ------------------------------------------------------# # Returns all Associations in which these Topics play a Role. # # The optional # identifier specifies the type of the Roles to be considered. # The identifier may be a topic reference. # # Multiple instances of the same Association are possible. # The result may be empty. # # :call-seq: # reverse_players -> Array of Associations # reverse_players(identifier) -> Array of Associations # def reverse_players(type=:any) _res = self.inject([]){|all,containee| all << containee.send(:reverse_players,type)}.flatten ### NO UNIQUE ### _res = _res.extend(Associations) _res end # ---- reifier-axis ------------------------------------------------------# # Returns the Constructs which are reified by one of these Topics # only if such Constructs exist. # # :call-seq: # reifier -> Array of Associations, Names and Occurrences # def reifier _res = self.inject([]){|all,containee| all << containee.send(:reifier)}.flatten _res = _res.select{|i| i} #reject nil ### NO UNIQUE NEEDED _res = _res.extend(AssocsNamesOccs) _res end # ---- roles-axis --------------------------------------------------------# # Returns all Associations that have Roles that have one of # these Topics as Roletype. Multiple instances of the same # Association are possible. # # The result may be empty. # # :call-seq: # reverse_roles -> Array of Associations # def reverse_roles _res = self.inject([]){|all,containee| all << containee.send(:reverse_roles)}.flatten ### NO UNIQUE ### _res = _res.extend(Associations) _res end # ---- scope-axis --------------------------------------------------------# # Returns all Associations, Names and Occurrences that include at least one of these # Topics (themes) in their scope. # # The result may be empty. # # :call-seq: # reverse_scope -> Array of Names, Associations and Occurrences # def reverse_scope _res = self.inject([]){|all,containee| all << containee.send(:reverse_scope)}.flatten ### FLAG UNIQUE ### _res = _res.map{|i| i.construct}.uniq.map{|i| i.axes} ### ### _res = _res.extend(AssocsNamesOccs) _res end # ---- supertypes-axis ---------------------------------------------------# # Returns all supertypes of all of these Topics. The result includes # all direct supertypes # and the supertypes of these direct supertypes. # # The result may be an empty Array. # # :call-seq: # supertypes -> Array of Topics # def supertypes _res = self.define_helper(:supertypes) #_res = self.inject([]){|all,containee| all << containee.send(:supertypes)}.flatten ### FLAG UNIQUE ### _res = _res.map{|i| i.construct}.uniq.map{|i| i.axes} ### ### _res = _res.extend(Topics) _res end # Returns all subtypes of all of these Topics. The result includes the direct subtypes # and the subtypes of these direct subtypes. # # The result may be an empty Array. # # :call-seq: # subtypes -> Array of Topics # def subtypes _res = self.inject([]){|all,containee| all << containee.send(:subtypes)}.flatten ### FLAG UNIQUE ### _res = _res.map{|i| i.construct}.uniq.map{|i| i.axes} ### ### _res = _res.extend(Topics) _res end alias reverse_subtypes supertypes alias reverse_supertypes subtypes # ---- traverse-axis ---------------------------------------------------# # First computes all Associations where these Topics play a Role. # There, the optional identifier filters the Associations for their type. # # Returns all Players of all Roles in these Associations. # Each Topic is deducted ones from the returned Array. # The result may be empty. # # The identifier may be a topic reference. # # :call-seq: # traverse(identifier) -> Array of Topics # def traverse(type=:any) _res = self.inject([]){|all,containee| all << containee.send(:traverse,type)}.flatten ### NO UNIQUE ### _res = _res.extend(Topics) _res end # Always returns an empty Array # # :call-seq: # reverse_traverse -> Array of Topics # def reverse_traverse _res = [] #HARDCODED _res.extend(Topics) end # ---- types-axis --------------------------------------------------------# # Returns the Topics these Topics are instances of. Calls # the TMAPI getTypes method. # # The result may be empty. # # :call-seq: # types -> Array of Topics # def types #self = Array of TopicProxies #containee: RTM::Axes::Topic #send -> Array of TopicProxies #uniq -> Topics in Array, call unique on Array #convert to TopicProxies again #extend result-Array _res = self.inject([]){|all,containee| all << containee.send(:types)}.flatten ### FLAG UNIQUE ### _res = _res.map{|i| i.construct}.uniq.map{|i| i.axes} ### ### _res.extend(Topics) _res end # Returns the Topics which are instances of these Topics. # Uses the TMAPI TypeInstanceIndex. # # The result may be empty. # # :call-seq: # instances -> Array of Topics # def instances _res = self.inject([]){|all,containee| all << containee.send(:instances)}.flatten ### FLAG UNIQUE ### _res = _res.map{|i| i.construct}.uniq.map{|i| i.axes} ### ### _res.extend(Topics) _res end alias reverse_types instances alias reverse_instances types end end