rtm 0.1.6 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. data/DISCLAIMER +10 -33
  2. data/LICENSE +201 -0
  3. data/README +3 -3
  4. data/lib/rtm.rb +148 -74
  5. data/lib/rtm/axes.rb +295 -0
  6. data/lib/rtm/axes/association.rb +76 -0
  7. data/lib/rtm/axes/associations.rb +96 -0
  8. data/lib/rtm/axes/assocs_names_occs.rb +56 -0
  9. data/lib/rtm/axes/characteristic.rb +68 -0
  10. data/lib/rtm/axes/characteristics.rb +93 -0
  11. data/lib/rtm/axes/string.rb +76 -0
  12. data/lib/rtm/axes/strings.rb +87 -0
  13. data/lib/rtm/axes/topic.rb +233 -0
  14. data/lib/rtm/axes/topics.rb +280 -0
  15. data/lib/rtm/{backward_compatibility.rb → deprecated/index_property_set.rb} +3 -0
  16. data/lib/rtm/engine.rb +58 -0
  17. data/lib/rtm/extensions.rb +11 -1
  18. data/lib/rtm/{locator_helpers.rb → helpers/locator.rb} +15 -4
  19. data/lib/rtm/{helpers.rb → helpers/no_output.rb} +3 -0
  20. data/lib/rtm/helpers/uri.rb +13 -0
  21. data/lib/rtm/io.rb +18 -0
  22. data/lib/rtm/io/from_xtm2_libxml.rb +2 -1
  23. data/lib/rtm/io/ontopia_io.rb +25 -0
  24. data/lib/rtm/io/tmapix.rb +234 -0
  25. data/lib/rtm/io/to_hash.rb +116 -0
  26. data/lib/rtm/io/to_jtm.rb +53 -103
  27. data/lib/rtm/io/to_rdf.rb +30 -0
  28. data/lib/rtm/io/to_string.rb +8 -6
  29. data/lib/rtm/io/to_xtm1.rb +6 -4
  30. data/lib/rtm/io/to_xtm2.rb +10 -8
  31. data/lib/rtm/io/to_yaml.rb +29 -98
  32. data/lib/rtm/navigation.rb +37 -0
  33. data/lib/rtm/navigation/association/players.rb +25 -0
  34. data/lib/rtm/navigation/name/atomify.rb +19 -0
  35. data/lib/rtm/navigation/name/characteristics.rb +33 -0
  36. data/lib/rtm/navigation/occurrence/atomify.rb +19 -0
  37. data/lib/rtm/navigation/occurrence/characteristics.rb +33 -0
  38. data/lib/rtm/navigation/topic/characteristics.rb +33 -0
  39. data/lib/rtm/navigation/topic/indicators.rb +31 -0
  40. data/lib/rtm/navigation/topic/items.rb +31 -0
  41. data/lib/rtm/navigation/topic/locators.rb +31 -0
  42. data/lib/rtm/navigation/topic/players.rb +27 -0
  43. data/lib/rtm/navigation/topic/supertypes.rb +162 -0
  44. data/lib/rtm/navigation/topic/traverse.rb +51 -0
  45. data/lib/rtm/navigation/topic/types.rb +107 -0
  46. data/lib/rtm/psi.rb +33 -2
  47. data/lib/rtm/sugar.rb +34 -0
  48. data/lib/rtm/sugar/association/hash_access.rb +46 -0
  49. data/lib/rtm/sugar/occurrence/dynamic_value.rb +75 -0
  50. data/lib/rtm/{pimp_my_api.rb → sugar/occurrence/externalize.rb} +3 -0
  51. data/lib/rtm/sugar/role/counterparts.rb +133 -46
  52. data/lib/rtm/sugar/topic/characteristics.rb +126 -12
  53. data/lib/rtm/sugar/topic/counterparts.rb +130 -7
  54. data/lib/rtm/sugar/topic/hash_access.rb +140 -30
  55. data/lib/rtm/sugar/topic/scoped.rb +65 -0
  56. data/lib/rtm/sugar/topic/topic_ref.rb +35 -0
  57. data/lib/rtm/sugar/topic/typed.rb +159 -0
  58. data/lib/rtm/sugar/typed/types.rb +38 -0
  59. data/lib/rtm/validation.rb +8 -5
  60. data/lib/rtm/version.rb +18 -0
  61. data/spec/helpers/spec_exampleexamplegroup.rb +14 -0
  62. data/spec/rtm/axes/association_spec.rb +88 -0
  63. data/spec/rtm/axes/associations_spec.rb +60 -0
  64. data/spec/rtm/axes/assocs_names_occs_spec.rb +9 -0
  65. data/spec/rtm/axes/characteristic_spec.rb +90 -0
  66. data/spec/rtm/axes/characteristics_spec.rb +85 -0
  67. data/spec/rtm/axes/string_spec.rb +145 -0
  68. data/spec/rtm/axes/strings_spec.rb +168 -0
  69. data/spec/rtm/axes/topic_spec.rb +124 -0
  70. data/spec/rtm/axes/topics_spec.rb +103 -0
  71. data/spec/rtm/base_spec.rb +32 -0
  72. data/spec/rtm/io/tmapix_spec.rb +85 -0
  73. data/spec/rtm/navigation/association/players_spec.rb +58 -0
  74. data/spec/rtm/navigation/association_spec.rb +52 -0
  75. data/spec/rtm/navigation/name/atomify_spec.rb +27 -0
  76. data/spec/rtm/navigation/name/characteristics_spec.rb +34 -0
  77. data/spec/rtm/navigation/name_spec.rb +52 -0
  78. data/spec/rtm/navigation/occurrence/atomify_spec.rb +27 -0
  79. data/spec/rtm/navigation/occurrence/characteristics_spec.rb +34 -0
  80. data/spec/rtm/navigation/occurrence_spec.rb +52 -0
  81. data/spec/rtm/navigation/string_spec.rb +51 -0
  82. data/spec/rtm/navigation/topic/characteristics_spec.rb +55 -0
  83. data/spec/rtm/navigation/topic/indicators_spec.rb +43 -0
  84. data/spec/rtm/navigation/topic/items_spec.rb +44 -0
  85. data/spec/rtm/navigation/topic/locators_spec.rb +44 -0
  86. data/spec/rtm/navigation/topic/players_spec.rb +48 -0
  87. data/spec/rtm/navigation/topic/scope_spec.rb +41 -0
  88. data/spec/rtm/navigation/topic/supertypes_spec.rb +376 -0
  89. data/spec/rtm/navigation/topic/traverse_spec.rb +64 -0
  90. data/spec/rtm/navigation/topic/types_spec.rb +195 -0
  91. data/spec/rtm/navigation/topic_spec.rb +153 -0
  92. data/spec/rtm/sugar/association/hash_access_spec.rb +55 -0
  93. data/spec/rtm/sugar/occurrence/dynamic_value_spec.rb +16 -0
  94. data/spec/rtm/sugar/role/counterparts_spec.rb +191 -0
  95. data/spec/rtm/sugar/topic/characteristics_spec.rb +318 -0
  96. data/spec/rtm/sugar/topic/counterparts_spec.rb +184 -0
  97. data/spec/rtm/sugar/topic/hash_access_spec.rb +234 -0
  98. data/spec/rtm/sugar/topic/scoped_spec.rb +131 -0
  99. data/spec/rtm/sugar/topic/topic_ref_spec.rb +44 -0
  100. data/spec/rtm/sugar/topic/typed_spec.rb +155 -0
  101. data/spec/rtm/sugar/typed/types_spec.rb +24 -0
  102. data/spec/rtm/tmapi/core/association_spec.rb +169 -0
  103. data/spec/rtm/tmapi/core/construct_spec.rb +25 -0
  104. data/spec/rtm/tmapi/core/name_spec.rb +85 -0
  105. data/spec/rtm/tmapi/core/occurrence_spec.rb +96 -0
  106. data/spec/rtm/tmapi/core/reifiable_spec.rb +168 -0
  107. data/spec/rtm/tmapi/core/role_spec.rb +73 -0
  108. data/spec/rtm/tmapi/core/scoped_spec.rb +403 -0
  109. data/spec/rtm/tmapi/core/topic_map_spec.rb +648 -0
  110. data/spec/rtm/tmapi/core/topic_spec.rb +992 -0
  111. data/spec/rtm/tmapi/core/typed_spec.rb +112 -0
  112. data/spec/rtm/tmapi/core/variant_spec.rb +52 -0
  113. data/spec/rtm/tmapi/ext/java_util_set_spec.rb +34 -0
  114. data/spec/rtm/tmapi_spec.rb +44 -0
  115. data/spec/rtm/utils/sparql_spec.rb +26 -0
  116. data/spec/rtm_spec.rb +94 -0
  117. data/spec/spec_helper.rb +23 -0
  118. data/test/base_unit_test.rb +161 -0
  119. data/test/{base_test.rb → base_unit_test_tmapi.rb} +46 -43
  120. metadata +122 -66
  121. data/COPYRIGHT +0 -4
  122. data/lib/Rakefile.rb +0 -42
  123. data/lib/activetopicmaps.rb +0 -278
  124. data/lib/rtm/backend/active_record.rb +0 -58
  125. data/lib/rtm/backend/active_record/001_initial_schema.rb +0 -116
  126. data/lib/rtm/backend/active_record/association_and_role.rb +0 -33
  127. data/lib/rtm/backend/active_record/locators.rb +0 -55
  128. data/lib/rtm/backend/active_record/name_variant_occurrence.rb +0 -45
  129. data/lib/rtm/backend/active_record/quaaxtm2rtm.rb +0 -113
  130. data/lib/rtm/backend/active_record/quaaxtm2rtmviews.rb +0 -134
  131. data/lib/rtm/backend/active_record/set_wrapper.rb +0 -98
  132. data/lib/rtm/backend/active_record/tm_construct.rb +0 -62
  133. data/lib/rtm/backend/active_record/tm_delegator.rb +0 -345
  134. data/lib/rtm/backend/active_record/tm_set_delegator.rb +0 -195
  135. data/lib/rtm/backend/active_record/tmdm.rb +0 -298
  136. data/lib/rtm/backend/active_record/topic.rb +0 -87
  137. data/lib/rtm/backend/active_record/topic_map.rb +0 -314
  138. data/lib/rtm/backend/active_record/traverse_associations.rb +0 -87
  139. data/lib/rtm/base.rb +0 -92
  140. data/lib/rtm/connect.rb +0 -92
  141. data/lib/rtm/core_ext.rb +0 -6
  142. data/lib/rtm/io/from_xtm2.rb +0 -263
  143. data/lib/rtm/merging/merging.rb +0 -307
  144. data/lib/rtm/sugar/topic/identifier_direct.rb +0 -11
  145. data/lib/rtm/sugar/topic/predefined_associations.rb +0 -42
  146. data/lib/run_main_project.rb +0 -16
@@ -0,0 +1,56 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module RTM::Axes
5
+ module AssocsNamesOccs
6
+
7
+ def self.extended(k)
8
+ k.extend ArrayProxy
9
+ end
10
+
11
+ def result
12
+ self.map{|i| i.construct}
13
+ end
14
+ alias :tmapi :result
15
+
16
+ # ---- reifier-axis ------------------------------------------------------#
17
+
18
+ # Returns the reifing Topics of these Characteristics and
19
+ # Associations only
20
+ # if such Topics exists.
21
+ #
22
+ # The result may be empty.
23
+ #
24
+ # :call-seq:
25
+ # reverse_reified -> Array of Topics
26
+ #
27
+ def reverse_reifier
28
+ _res = self.inject([]){|all,containee| all << containee.send(:reverse_reifier)}.flatten
29
+ _res = _res.select{|i| i}
30
+ ### FLAG UNIQUE ###
31
+ _res = _res.map{|i| i.construct}.uniq.map{|i| i.axes}
32
+ ### ###
33
+ _res.extend(Topics)
34
+ end
35
+
36
+ # ---- scope-axis --------------------------------------------------------#
37
+
38
+ # Returns the scope of these Characteristics
39
+ # and Associations.
40
+ #
41
+ # The result may be empty.
42
+ #
43
+ # :call-seq:
44
+ # scope -> Array of Topics
45
+ #
46
+ def scope
47
+ _res = self.inject([]){|all,containee| all << containee.send(:scope)}.flatten
48
+ ### FLAG UNIQUE ###
49
+ _res = _res.map{|i| i.construct}.uniq.map{|i| i.axes}
50
+ ### ###
51
+ _res = _res.extend(Topics)
52
+ _res
53
+ end
54
+
55
+ end
56
+ end
@@ -0,0 +1,68 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module RTM::Axes
5
+
6
+ class Characteristic < ItemProxy
7
+
8
+ # ---- atomify-axis ------------------------------------------------------#
9
+
10
+ # Returns the atomic value of the Characteristic.
11
+ #
12
+ # :call-seq:
13
+ # atomify -> String
14
+ #
15
+ def atomify
16
+ _res = @construct.atomify #String
17
+ RTM::Axes::String.new(_res,@tm)
18
+ end
19
+
20
+ # ---- characteristics-axis ----------------------------------------------#
21
+
22
+ # Returns the Topic this Characteristic belongs to.
23
+ # The optional argument identifier filters the
24
+ # Characteristic for its type. If the type
25
+ # does not match, nil is returned.
26
+ #
27
+ # The identifier may be a Topic or Topic-Reference.
28
+ #
29
+ # :call-seq:
30
+ # reverse_characteristics -> Topic
31
+ # reverse_characteristics(identifier) -> Topic or nil
32
+ #
33
+ def reverse_characteristics(type=:any)
34
+ _res = @construct.reverse_characteristics(type) #Topic or nil
35
+ RTM::Axes::Topic.new(_res,@tm) if _res
36
+ end
37
+
38
+ # ---- reifier-axis ------------------------------------------------------#
39
+
40
+
41
+ # Returns the reifing Topic of this Characteristic or nil,
42
+ # if no such Topic exists.
43
+ #
44
+ # :call-seq:
45
+ # reverse_reified -> Topic or nil
46
+ #
47
+ def reverse_reifier
48
+ _res = @construct.reifier #Topic or nil
49
+ RTM::Axes::Topic.new(_res,@tm) if _res
50
+ end
51
+
52
+ # ---- scope-axis --------------------------------------------------------#
53
+
54
+ # Returns the scope of this Characteristic.
55
+ #
56
+ # The result may be empty.
57
+ #
58
+ # :call-seq:
59
+ # scope -> Array of Topics
60
+ #
61
+ def scope
62
+ _res = @construct.scope.map{|r| r.axes}
63
+ _res.extend(Topics)
64
+ end
65
+
66
+ end
67
+
68
+ end
@@ -0,0 +1,93 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module RTM::Axes
5
+ module Characteristics
6
+
7
+ def self.extended(k)
8
+ k.extend ArrayProxy
9
+ end
10
+
11
+ def result
12
+ self.map{|i| i.construct}
13
+ end
14
+ alias :tmapi :result
15
+
16
+ # ---- atomify-axis ------------------------------------------------------#
17
+
18
+ # Returns the atomic values of these Characteristics.
19
+ #
20
+ # :call-seq:
21
+ # atomify -> Array of Strings
22
+ #
23
+ def atomify
24
+ #self = Array of TopicProxies
25
+ #containee: RTM::Axes::Topic
26
+ #send -> Array of (String or nil)s
27
+ _res = self.inject([]){|all,containee| all << containee.send(:atomify)}.flatten
28
+ _res = _res.select{|i| i}
29
+ ### NO UNIQUE
30
+ _res.extend(Strings)
31
+ end
32
+
33
+ # ---- characteristics-axis ----------------------------------------------#
34
+
35
+ # Returns the Topics these Characteristics belong to.
36
+ # The optional argument identifier filters the
37
+ # Characteristics for their types. If the type
38
+ # does not match, the Topic is not returned.
39
+ #
40
+ # The identifier may be a Topic or Topic-Reference.
41
+ #
42
+ # :call-seq:
43
+ # reverse_characteristics -> Array of Topic
44
+ # reverse_characteristics(identifier) -> Array of Topic or empty Array
45
+ #
46
+ def reverse_characteristics(type=:any)
47
+ _res = self.inject([]){|all,containee| all << containee.send(:reverse_characteristics,type)}.flatten
48
+ _res = _res.select{|i| i}
49
+ ### FLAG UNIQUE ###
50
+ _res = _res.map{|i| i.construct}.uniq.map{|i| i.axes}
51
+ ### ###
52
+ _res.extend(Topics)
53
+ end
54
+
55
+ # ---- reifier-axis ------------------------------------------------------#
56
+
57
+ # Returns the reifing Topics of these Characteristics only
58
+ # if such Topics exists.
59
+ #
60
+ # The result may be empty.
61
+ #
62
+ # :call-seq:
63
+ # reverse_reified -> Array of Topics
64
+ #
65
+ def reverse_reifier
66
+ _res = self.inject([]){|all,containee| all << containee.send(:reverse_reifier)}.flatten
67
+ _res = _res.select{|i| i}
68
+ ### FLAG UNIQUE ###
69
+ _res = _res.map{|i| i.construct}.uniq.map{|i| i.axes}
70
+ ### ###
71
+ _res.extend(Topics)
72
+ end
73
+
74
+ # ---- scope-axis --------------------------------------------------------#
75
+
76
+ # Returns the scope of these Characteristics.
77
+ #
78
+ # The result may be empty.
79
+ #
80
+ # :call-seq:
81
+ # scope -> Array of Topics
82
+ #
83
+ def scope
84
+ _res = self.inject([]){|all,containee| all << containee.send(:scope)}.flatten
85
+ ### FLAG UNIQUE ###
86
+ _res = _res.map{|i| i.construct}.uniq.map{|i| i.axes}
87
+ ### ###
88
+ _res = _res.extend(Topics)
89
+ _res
90
+ end
91
+
92
+ end
93
+ end
@@ -0,0 +1,76 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module RTM::Axes
5
+ class String < ItemProxy
6
+
7
+ # ---- atomify-axis ------------------------------------------------------#
8
+
9
+ # Returns all Names and Occurrences which have
10
+ # String as data value. If the String is found as value of a Variant,
11
+ # the parent Name is returned.
12
+ #
13
+ # The result may be empty.
14
+ #
15
+ # :call-seq:
16
+ # reverse_atomify -> Array of Names and Occurrences
17
+ #
18
+ def reverse_atomify
19
+ index = @tm.literal_index
20
+ names = index.getNames(@construct).to_a
21
+ occs = index.getOccurrences(@construct).to_a
22
+ variants = index.getVariants(@construct).to_a
23
+ names2 = variants.map{|v| v.parent}
24
+ _res = names + occs + names2 #could be empty
25
+ _res = _res.map{|r| r.axes}
26
+ _res.extend(Characteristics)
27
+ end
28
+
29
+ # ---- indicators-axis ---------------------------------------------------#
30
+
31
+ # Returns the Topic which has this String as indicator (subject identifier)
32
+ # or nil if no such Topic exists.
33
+ #
34
+ # :call-seq:
35
+ # reverse_indicators -> Topic or nil
36
+ #
37
+ def reverse_indicators
38
+ _res = @tm.get_topic_by_subject_identifier(@construct) #Topic or nil
39
+ _res = RTM::Axes::Topic.new(_res,@tm) if _res
40
+ return _res
41
+ end
42
+
43
+ # ---- item-axis ---------------------------------------------------------#
44
+
45
+ # Returns one Topic which has this String as item identifer or nil
46
+ # if no such Topic exists.
47
+ #
48
+ # :call-seq:
49
+ # reverse_item -> Topic or nil
50
+ #
51
+ def reverse_item
52
+ _res = @tm.get_construct_by_item_identifier(@construct) #Construct or nil TODO -> Topic
53
+ return nil unless _res
54
+ if _res.is_a?(RTM::Topic)
55
+ return RTM::Axes::Topic.new(_res,@tm)
56
+ else
57
+ return nil
58
+ end
59
+ end
60
+
61
+ # ---- locators-axis -----------------------------------------------------#
62
+
63
+ # Returns the Topic which has this String as subject locator or nil
64
+ # if no such Topic exists.
65
+ #
66
+ # :call-seq:
67
+ # reverse_locators -> Topic or nil
68
+ #
69
+ def reverse_locators
70
+ _res = @tm.get_topic_by_subject_locator(@construct) #Topic or nil
71
+ _res = RTM::Axes::Topic.new(_res,@tm) if _res
72
+ return _res #RTM::Axes::Topic or nil
73
+ end
74
+
75
+ end
76
+ end
@@ -0,0 +1,87 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module RTM::Axes
5
+ module Strings
6
+
7
+ def self.extended(k)
8
+ k.extend ArrayProxy
9
+ end
10
+
11
+ def result
12
+ self.map{|i| i.construct}
13
+ end
14
+ alias :tmapi :result
15
+
16
+ # ---- atomify-axis ------------------------------------------------------#
17
+
18
+ # Returns all Names and Occurrences which have one of these
19
+ # Strings as data value. If one String is found as value of a Variant,
20
+ # the parent Name is returned.
21
+ #
22
+ # The result may be empty.
23
+ #
24
+ # :call-seq:
25
+ # reverse_atomify -> Array of Names and Occurrences
26
+ #
27
+ def reverse_atomify
28
+ _res = self.inject([]){|all,containee| all << containee.send(:reverse_atomify)}.flatten
29
+ ### NO UNIQUE NEEDED
30
+ _res = _res.extend(Characteristics)
31
+ _res
32
+ end
33
+
34
+ # ---- indicators-axis ---------------------------------------------------#
35
+
36
+ # Returns all Topics which have one of these Strings as indicator (subject identifier)
37
+ # only if such Topics exist.
38
+ #
39
+ # The result may be empty.
40
+ #
41
+ # :call-seq:
42
+ # reverse_indicators -> Array of Topics
43
+ #
44
+ def reverse_indicators
45
+ _res = self.inject([]){|all,containee| all << containee.send(:reverse_indicators)}.flatten
46
+ ### NO UNIQUE
47
+ _res = _res.select{|i| i} #reject nil
48
+ _res = _res.extend(Topics)
49
+ _res
50
+ end
51
+
52
+ # ---- item-axis ---------------------------------------------------------#
53
+
54
+ # Returns all Topics which have one of these Strings as item identifer
55
+ # only if such Topics exist.
56
+ #
57
+ # The result may be empty.
58
+ #
59
+ # :call-seq:
60
+ # reverse_item -> Array of Topics
61
+ #
62
+ def reverse_item
63
+ _res = self.inject([]){|all,containee| all << containee.send(:reverse_item)}.flatten
64
+ _res = _res.select{|i| i} #reject nil
65
+ _res = _res.extend(Topics)
66
+ _res
67
+ end
68
+
69
+ # ---- locators-axis -----------------------------------------------------#
70
+
71
+ # Returns all Topics which have one of these Strings as subject locator
72
+ # only if such Topics exist.
73
+ #
74
+ # The result may be empty.
75
+ #
76
+ # :call-seq:
77
+ # reverse_locators -> Array of Topics
78
+ #
79
+ def reverse_locators
80
+ _res = self.inject([]){|all,containee| all << containee.send(:reverse_locators)}.flatten
81
+ _res = _res.select{|i| i} #reject nil
82
+ _res = _res.extend(Topics)
83
+ _res
84
+ end
85
+
86
+ end
87
+ end
@@ -0,0 +1,233 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module RTM::Axes
5
+
6
+ class Topic < ItemProxy
7
+
8
+ # ---- characteristics-axis ----------------------------------------------#
9
+
10
+ # Returns all Names and Occurrences of this Topic.
11
+ # If an identifier is given, only those Names and Occurrences are returned,
12
+ # whose type or supertypes include the identifier.
13
+ #
14
+ # Identifier may be a Topic or Topic-Reference.
15
+ #
16
+ # The result may be empty.
17
+ #
18
+ # :call-seq:
19
+ # characteristics -> Array of Names and Occurrences
20
+ # characteristics(identifier) -> Array of Names and Occurrences
21
+ #
22
+ def characteristics(type=:any)
23
+ _res = @construct.characteristics(type).map{|r| r.axes}
24
+ _res.extend(Characteristics)
25
+ end
26
+
27
+ # ---- indicators-axis ---------------------------------------------------#
28
+
29
+ # Returns all indicators (subject identifiers) of this Topic.
30
+ #
31
+ # The result may be empty.
32
+ #
33
+ # :call-seq:
34
+ # indicators -> Array of Strings
35
+ #
36
+ def indicators
37
+ @construct.indicators #Array of Strings or empty
38
+ end
39
+
40
+ # ---- item-axis ---------------------------------------------------------#
41
+
42
+ # Returns one item identifier of this Topic or nil
43
+ # if this Topic has no item identifier.
44
+ #
45
+ # :call-seq:
46
+ # item -> String or nil
47
+ #
48
+ def item
49
+ @construct.item #String or nil
50
+ end
51
+
52
+ # ---- locators-axis ------------------------------------------------------#
53
+
54
+ # Returns all subject locators of this Topic.
55
+ #
56
+ # The result may be empty.
57
+ #
58
+ # :call-seq:
59
+ # locators -> Array of Strings
60
+ #
61
+ def locators
62
+ @construct.locators #Array of Strings or empty
63
+ end
64
+
65
+ # ---- players-axis ------------------------------------------------------#
66
+
67
+ # Returns all Associations in which this Topic plays a Role.
68
+ #
69
+ # The optional
70
+ # identifier specifies the type of the Roles to be considered.
71
+ # The identifier may be a Topic or Topic-Reference.
72
+ #
73
+ # Multiple instances of the same Association are possible.
74
+ # The result may be empty.
75
+ #
76
+ # :call-seq:
77
+ # reverse_players -> Array of Associations
78
+ # reverse_players(identifier) -> Array of Associations
79
+ #
80
+ def reverse_players(type=:any)
81
+ _res = @construct.reverse_players(type).map{|r| r.axes}
82
+ _res.extend(Associations)
83
+ end
84
+
85
+ # ---- reifier-axis ------------------------------------------------------#
86
+
87
+ # Alias for the TMAPI function getReified.
88
+ # Returns the Construct which is reified by this Topic
89
+ # or nil if this Topic does not reify a Construct.
90
+ #
91
+ # So far, only Associations, Names or Occurrences are returned.
92
+ #
93
+ # :call-seq:
94
+ # reifier -> Association, Name, Occurrence or nil
95
+ #
96
+ def reifier
97
+ #TODO: what if the reified construct is a Topic Map?
98
+ _res = @construct.getReified # Name,Occ,Assoc or nil
99
+ return RTM::Axes::Name.new(_res,@tm) if _res.is_a?(RTM::Name)
100
+ return RTM::Axes::Occurrence.new(_res,@tm) if _res.is_a?(RTM::Occurrence)
101
+ return RTM::Axes::Association.new(_res,@tm) if _res.is_a?(RTM::Association)
102
+ return nil
103
+ end
104
+
105
+ # ---- roles-axis --------------------------------------------------------#
106
+
107
+ # Returns all Associations that have Roles that have
108
+ # this Topic as Role type. Multiple instances of the same
109
+ # Association are possible.
110
+ #
111
+ # The result may be empty.
112
+ #
113
+ # :call-seq:
114
+ # reverse_roles -> Array of Associations
115
+ #
116
+ def reverse_roles
117
+ _res = @tm.type_instance_index.getRoles(@construct).map {|r| r.getParent }
118
+ _res = _res.map{|r| r.axes}
119
+ _res.extend(Associations)
120
+ end
121
+
122
+ # ---- scope-axis --------------------------------------------------------#
123
+
124
+ # Returns all Associations, Names and Occurrences that include this
125
+ # Topic (theme) in their scope.
126
+ #
127
+ # The result may be empty.
128
+ #
129
+ # :call-seq:
130
+ # reverse_scope -> Array of Names, Associations and Occurrences
131
+ #
132
+ def reverse_scope
133
+ _index = @tm.scoped_index
134
+ _res = _index.names(@construct).to_a + _index.occurrences(@construct).to_a + _index.associations(@construct).to_a
135
+ _res = _res.map{|r| r.axes}
136
+ _res.extend(AssocsNamesOccs)
137
+ end
138
+
139
+ # ---- supertypes-axis ---------------------------------------------------#
140
+
141
+ # Returns all supertypes of this Topic. The result includes
142
+ # all direct supertypes
143
+ # and the supertypes of these direct supertypes.
144
+ #
145
+ # The result may be an empty Array.
146
+ #
147
+ # :call-seq:
148
+ # supertypes -> Array of Topics
149
+ #
150
+ def supertypes
151
+ _res = @construct.transitive_supertypes_with_self.map{|r| r.axes}
152
+ _res.extend(Topics)
153
+ end
154
+
155
+ # Returns all subtypes of this Topic. The result includes the direct subtypes
156
+ # and the subtypes of these direct subtypes.
157
+ #
158
+ # The result may be an empty Array.
159
+ #
160
+ # :call-seq:
161
+ # subtypes -> Array of Topics
162
+ #
163
+ def subtypes
164
+ _res = @construct.transitive_subtypes_with_self.map{|r| r.axes}
165
+ _res.extend(Topics)
166
+ end
167
+
168
+ alias reverse_subtypes supertypes
169
+ alias reverse_supertypes subtypes
170
+
171
+ # ---- traverse-axis ---------------------------------------------------#
172
+
173
+ # First computes all Associations where this Topic playes a Role.
174
+ # There, the optional identifier filters the Associations for their type.
175
+ #
176
+ # Returns all Players of all Roles in these Associations.
177
+ # The current Topic is deducted ones from the returned Array.
178
+ # The result may be empty.
179
+ #
180
+ # The identifier may be a Topic or Topic-Reference.
181
+ #
182
+ # :call-seq:
183
+ # traverse(identifier) -> Array of Topics
184
+ #
185
+ def traverse(type=:any)
186
+ _res = @construct.traverse(type).map{|r| r.axes}
187
+ _res.extend(Topics)
188
+ end
189
+
190
+ # Always returns an empty Array
191
+ #
192
+ # :call-seq:
193
+ # reverse_traverse -> Array of Topics
194
+ #
195
+ def reverse_traverse
196
+ _res = [] #HARDCODED
197
+ _res.extend(Topics)
198
+ end
199
+
200
+ # ---- types-axis ---------------------------------------------------#
201
+
202
+ # Returns the Topics this Topic is an instance of. Calls
203
+ # the TMAPI getTypes method.
204
+ #
205
+ # The result may be empty.
206
+ #
207
+ # :call-seq:
208
+ # types -> Array of Topics
209
+ #
210
+ def types
211
+ _res = @construct.types.map{|r| r.axes}
212
+ _res.extend(Topics)
213
+ end
214
+
215
+ # Returns the Topics which are instances of this Topic.
216
+ # Uses the TMAPI TypeInstanceIndex.
217
+ #
218
+ # The result may be empty.
219
+ #
220
+ # :call-seq:
221
+ # instances -> Array of Topics
222
+ #
223
+ def instances
224
+ _res = @construct.instances.map{|r| r.axes}
225
+ _res.extend(Topics)
226
+ end
227
+
228
+ alias reverse_types instances
229
+ alias reverse_instances types
230
+
231
+ end #of Class
232
+
233
+ end