rtm 0.1.6 → 0.2

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 (163) hide show
  1. data/DISCLAIMER +10 -33
  2. data/LICENSE +201 -0
  3. data/README +32 -3
  4. data/lib/rtm.rb +126 -74
  5. data/lib/rtm/axes.rb +298 -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 +101 -0
  17. data/lib/rtm/extensions.rb +65 -5
  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 +19 -0
  22. data/lib/rtm/io/from_xtm2_libxml.rb +2 -1
  23. data/lib/rtm/io/tmapix_from.rb +155 -0
  24. data/lib/rtm/io/tmapix_to.rb +223 -0
  25. data/lib/rtm/io/to_hash.rb +154 -0
  26. data/lib/rtm/io/to_jtm.rb +53 -103
  27. data/lib/rtm/io/to_rdf.rb +45 -0
  28. data/lib/rtm/io/to_string.rb +21 -8
  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 +59 -100
  32. data/lib/rtm/navigation.rb +23 -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 +166 -0
  44. data/lib/rtm/navigation/topic/traverse.rb +51 -0
  45. data/lib/rtm/navigation/topic/types.rb +109 -0
  46. data/lib/rtm/psi.rb +39 -2
  47. data/lib/rtm/sugar.rb +47 -0
  48. data/lib/rtm/sugar/association/hash_access.rb +46 -0
  49. data/lib/rtm/sugar/occurrence/dynamic_value.rb +58 -0
  50. data/lib/rtm/sugar/occurrence/external.rb +53 -0
  51. data/lib/rtm/sugar/reifiable/reifier.rb +21 -0
  52. data/lib/rtm/sugar/role/counterparts.rb +139 -46
  53. data/lib/rtm/sugar/topic/best_name.rb +74 -0
  54. data/lib/rtm/sugar/topic/characteristics.rb +126 -12
  55. data/lib/rtm/sugar/topic/counterparts.rb +145 -10
  56. data/lib/rtm/sugar/topic/hash_access.rb +140 -30
  57. data/lib/rtm/sugar/topic/scoped.rb +114 -0
  58. data/lib/rtm/sugar/topic/topic_ref.rb +86 -0
  59. data/lib/rtm/sugar/topic/typed.rb +207 -0
  60. data/lib/rtm/sugar/topic_map/query_cache.rb +66 -0
  61. data/lib/rtm/sugar/topic_map/themes.rb +53 -0
  62. data/lib/rtm/sugar/typed/types.rb +38 -0
  63. data/lib/rtm/validation.rb +7 -4
  64. data/lib/rtm/version.rb +30 -0
  65. data/spec/helpers/spec_exampleexamplegroup.rb +14 -0
  66. data/spec/rtm/axes/association_spec.rb +88 -0
  67. data/spec/rtm/axes/associations_spec.rb +60 -0
  68. data/spec/rtm/axes/assocs_names_occs_spec.rb +9 -0
  69. data/spec/rtm/axes/characteristic_spec.rb +90 -0
  70. data/spec/rtm/axes/characteristics_spec.rb +85 -0
  71. data/spec/rtm/axes/string_spec.rb +145 -0
  72. data/spec/rtm/axes/strings_spec.rb +168 -0
  73. data/spec/rtm/axes/topic_spec.rb +124 -0
  74. data/spec/rtm/axes/topics_spec.rb +103 -0
  75. data/spec/rtm/base_spec.rb +32 -0
  76. data/spec/rtm/io/tmapix_from_spec.rb +76 -0
  77. data/spec/rtm/io/tmapix_to_spec.rb +159 -0
  78. data/spec/rtm/io/to_hash_spec.rb +90 -0
  79. data/spec/rtm/io/to_rdf_spec.rb +37 -0
  80. data/spec/rtm/io/to_string_spec.rb +122 -0
  81. data/spec/rtm/io/to_yaml_spec.rb +89 -0
  82. data/spec/rtm/navigation/association/players_spec.rb +58 -0
  83. data/spec/rtm/navigation/association_spec.rb +52 -0
  84. data/spec/rtm/navigation/name/atomify_spec.rb +27 -0
  85. data/spec/rtm/navigation/name/characteristics_spec.rb +34 -0
  86. data/spec/rtm/navigation/name_spec.rb +52 -0
  87. data/spec/rtm/navigation/occurrence/atomify_spec.rb +27 -0
  88. data/spec/rtm/navigation/occurrence/characteristics_spec.rb +34 -0
  89. data/spec/rtm/navigation/occurrence_spec.rb +52 -0
  90. data/spec/rtm/navigation/string_spec.rb +51 -0
  91. data/spec/rtm/navigation/topic/characteristics_spec.rb +55 -0
  92. data/spec/rtm/navigation/topic/indicators_spec.rb +43 -0
  93. data/spec/rtm/navigation/topic/items_spec.rb +44 -0
  94. data/spec/rtm/navigation/topic/locators_spec.rb +44 -0
  95. data/spec/rtm/navigation/topic/players_spec.rb +48 -0
  96. data/spec/rtm/navigation/topic/scope_spec.rb +41 -0
  97. data/spec/rtm/navigation/topic/supertypes_spec.rb +376 -0
  98. data/spec/rtm/navigation/topic/traverse_spec.rb +64 -0
  99. data/spec/rtm/navigation/topic/types_spec.rb +195 -0
  100. data/spec/rtm/navigation/topic_spec.rb +153 -0
  101. data/spec/rtm/sugar/association/hash_access_spec.rb +55 -0
  102. data/spec/rtm/sugar/occurrence/dynamic_value_spec.rb +171 -0
  103. data/spec/rtm/sugar/occurrence/external_spec.rb +129 -0
  104. data/spec/rtm/sugar/reifiable/reifier_spec.rb +41 -0
  105. data/spec/rtm/sugar/role/counterparts_spec.rb +193 -0
  106. data/spec/rtm/sugar/topic/best_name_spec.rb +25 -0
  107. data/spec/rtm/sugar/topic/characteristics_spec.rb +333 -0
  108. data/spec/rtm/sugar/topic/counterparts_spec.rb +224 -0
  109. data/spec/rtm/sugar/topic/hash_access_spec.rb +234 -0
  110. data/spec/rtm/sugar/topic/scoped_spec.rb +195 -0
  111. data/spec/rtm/sugar/topic/topic_ref_spec.rb +44 -0
  112. data/spec/rtm/sugar/topic/typed_spec.rb +217 -0
  113. data/spec/rtm/sugar/topic_map/themes_spec.rb +67 -0
  114. data/spec/rtm/sugar/typed/types_spec.rb +24 -0
  115. data/spec/rtm/tmapi/core/association_spec.rb +169 -0
  116. data/spec/rtm/tmapi/core/construct_spec.rb +25 -0
  117. data/spec/rtm/tmapi/core/datatype_aware_spec.rb +236 -0
  118. data/spec/rtm/tmapi/core/name_spec.rb +270 -0
  119. data/spec/rtm/tmapi/core/occurrence_spec.rb +53 -0
  120. data/spec/rtm/tmapi/core/reifiable_spec.rb +168 -0
  121. data/spec/rtm/tmapi/core/role_spec.rb +73 -0
  122. data/spec/rtm/tmapi/core/scoped_spec.rb +441 -0
  123. data/spec/rtm/tmapi/core/topic_map_spec.rb +716 -0
  124. data/spec/rtm/tmapi/core/topic_spec.rb +1468 -0
  125. data/spec/rtm/tmapi/core/typed_spec.rb +112 -0
  126. data/spec/rtm/tmapi/core/variant_spec.rb +52 -0
  127. data/spec/rtm/tmapi/ext/java_util_set_spec.rb +34 -0
  128. data/spec/rtm/tmapi_spec.rb +44 -0
  129. data/spec/rtm/utils/sparql_spec.rb +26 -0
  130. data/spec/rtm_spec.rb +93 -0
  131. data/spec/spec_helper.rb +28 -0
  132. data/test/javalibs/junit-4.5.jar +0 -0
  133. data/test/javalibs/tmapi-2.0-tests.jar +0 -0
  134. data/test/tmapi_tests.rb +25 -0
  135. metadata +169 -65
  136. data/COPYRIGHT +0 -4
  137. data/lib/Rakefile.rb +0 -42
  138. data/lib/activetopicmaps.rb +0 -278
  139. data/lib/rtm/backend/active_record.rb +0 -58
  140. data/lib/rtm/backend/active_record/001_initial_schema.rb +0 -116
  141. data/lib/rtm/backend/active_record/association_and_role.rb +0 -33
  142. data/lib/rtm/backend/active_record/locators.rb +0 -55
  143. data/lib/rtm/backend/active_record/name_variant_occurrence.rb +0 -45
  144. data/lib/rtm/backend/active_record/quaaxtm2rtm.rb +0 -113
  145. data/lib/rtm/backend/active_record/quaaxtm2rtmviews.rb +0 -134
  146. data/lib/rtm/backend/active_record/set_wrapper.rb +0 -98
  147. data/lib/rtm/backend/active_record/tm_construct.rb +0 -62
  148. data/lib/rtm/backend/active_record/tm_delegator.rb +0 -345
  149. data/lib/rtm/backend/active_record/tm_set_delegator.rb +0 -195
  150. data/lib/rtm/backend/active_record/tmdm.rb +0 -298
  151. data/lib/rtm/backend/active_record/topic.rb +0 -87
  152. data/lib/rtm/backend/active_record/topic_map.rb +0 -314
  153. data/lib/rtm/backend/active_record/traverse_associations.rb +0 -87
  154. data/lib/rtm/base.rb +0 -92
  155. data/lib/rtm/connect.rb +0 -92
  156. data/lib/rtm/core_ext.rb +0 -6
  157. data/lib/rtm/io/from_xtm2.rb +0 -263
  158. data/lib/rtm/merging/merging.rb +0 -307
  159. data/lib/rtm/pimp_my_api.rb +0 -28
  160. data/lib/rtm/sugar/topic/identifier_direct.rb +0 -11
  161. data/lib/rtm/sugar/topic/predefined_associations.rb +0 -42
  162. data/lib/run_main_project.rb +0 -16
  163. data/test/base_test.rb +0 -162
@@ -1,4 +1,6 @@
1
- # Ruby Topic Maps (RTM) http://rtm.rubyforge.org/
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
2
4
  module RTM::IO
3
5
  # XTM1 Export
4
6
  module TOXTM1
@@ -98,9 +100,9 @@ module RTM::IO
98
100
  end
99
101
  end
100
102
 
101
- module TopicName
103
+ module Name
102
104
  def to_xtm1
103
- warn("TOXTM1: Warning: outputting invalid TopicName #{self}") unless valid?
105
+ warn("TOXTM1: Warning: outputting invalid Name #{self}") unless valid?
104
106
  # name = element name { reifiable, type?, scope?, value, variant* }
105
107
  x = REXML::Element.new 'name'
106
108
  x.add_attribute('reifier', reifier.xtm1_id) if reifier
@@ -128,7 +130,7 @@ module RTM::IO
128
130
  end
129
131
  end
130
132
 
131
- module AssociationRole
133
+ module Role
132
134
  def to_xtm1
133
135
  warn("TOXTM1: Warning: outputting invalid AssociationRole #{self}") unless valid?
134
136
  # role = element role { reifiable, type, topicRef }
@@ -1,4 +1,6 @@
1
- # Ruby Topic Maps (RTM) http://rtm.rubyforge.org/
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
2
4
 
3
5
  module RTM::IO
4
6
  # XTM2 Export.
@@ -92,7 +94,7 @@ module RTM::IO
92
94
  # association = element association { reifiable, type, scope?, role+ }
93
95
  x = REXML::Element.new 'association'
94
96
  x.add_attribute('reifier', reifier.xtm2_id) if reifier
95
- item_identifiers.each { |ii| x << TOXTM2.ii(ii) } # itemIdentity
97
+ item_identifiers.each { |ii| x << TOXTM2.locator(ii) } # itemIdentity
96
98
  x << TOXTM2.type(type) if type
97
99
  x << TOXTM2.scope(scope) unless scope.empty?
98
100
  roles.each { |r| x << r.to_xtm2 }
@@ -100,13 +102,13 @@ module RTM::IO
100
102
  end
101
103
  end
102
104
 
103
- module TopicName
105
+ module Name
104
106
  def to_xtm2
105
- warn("TOXTM2: Warning: outputting invalid TopicName #{self}") unless valid?
107
+ warn("TOXTM2: Warning: outputting invalid Name #{self}") unless valid?
106
108
  # name = element name { reifiable, type?, scope?, value, variant* }
107
109
  x = REXML::Element.new 'name'
108
110
  x.add_attribute('reifier', reifier.xtm2_id) if reifier
109
- item_identifiers.each { |ii| x << TOXTM2.ii(ii) } # itemIdentity
111
+ item_identifiers.each { |ii| x << TOXTM2.locator(ii) } # itemIdentity
110
112
  x << TOXTM2.type(type) if type
111
113
  x << TOXTM2.scope(scope) unless scope.empty?
112
114
  (x << REXML::Element.new('value')).text = value # adds the value within a value-element
@@ -122,7 +124,7 @@ module RTM::IO
122
124
  # type, scope?, ( resourceRef | resourceData ) }
123
125
  x = REXML::Element.new 'occurrence'
124
126
  x.add_attribute('reifier', reifier.xtm2_id) if reifier
125
- item_identifiers.each { |ii| x << TOXTM2.ii(ii) } # itemIdentity
127
+ item_identifiers.each { |ii| x << TOXTM2.locator(ii) } # itemIdentity
126
128
  x << TOXTM2.type(type) if type
127
129
  x << TOXTM2.scope(scope) unless scope.empty?
128
130
  x << TOXTM2.value(datatype, value)
@@ -136,7 +138,7 @@ module RTM::IO
136
138
  # role = element role { reifiable, type, topicRef }
137
139
  x = REXML::Element.new 'role'
138
140
  x.add_attribute('reifier', reifier.xtm2_id) if reifier
139
- item_identifiers.each { |ii| x << TOXTM2.ii(ii) } # itemIdentity
141
+ item_identifiers.each { |ii| x << TOXTM2.locator(ii) } # itemIdentity
140
142
  x << TOXTM2.type(type) if type
141
143
  x << player.to_xtm2_ref if player
142
144
  x
@@ -149,7 +151,7 @@ module RTM::IO
149
151
  # variant = element variant { reifiable, scope, (resourceRef | resourceData) }
150
152
  x = REXML::Element.new 'variant'
151
153
  x.add_attribute('reifier', reifier.xtm2_id) if reifier
152
- item_identifiers.each { |ii| x << TOXTM2.ii(ii) } # itemIdentity
154
+ item_identifiers.each { |ii| x << TOXTM2.locator(ii) } # itemIdentity
153
155
  x << TOXTM2.scope(scope)
154
156
  x << TOXTM2.value(datatype, value)
155
157
  x
@@ -1,130 +1,89 @@
1
- # Ruby Topic Maps (RTM) http://rtm.rubyforge.org/
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
2
4
  module RTM::IO
3
- # YAML Export.
4
- # Each Topic Maps Construct gets a to_xtm2 method.
5
- module TOYAML
5
+ # Yaml Export.
6
+ # Each Topic Maps Construct gets a to_yaml method.
7
+ module ToYAML
6
8
 
7
9
  module TopicMap
8
- def to_yaml_hash(*a)
9
- y={}
10
- #j['base_locator'] = base_locator, # with absolute item_identifiers its not needed
11
- y['reifier'] = reifier.to_yaml_ref if reifier
12
- y['item_identifiers'] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
13
- y['topics'] = topics.map{|i| i.to_yaml_hash} unless topics.empty?
14
- y['associations'] = associations.map{|i| i.to_yaml_hash} unless associations.empty?
15
- y
16
- end
17
- # returns the YAML representation of this topic map
18
- def to_yaml(*a)
19
- to_yaml_hash.to_yaml(*a)
10
+ # Returns the YAML representation of this topic map as String.
11
+ #
12
+ # :call-seq:
13
+ # to_yaml -> String
14
+ #
15
+ def to_yaml
16
+ to_hash.to_yaml
20
17
  end
21
18
  end
22
19
 
23
20
  module Topic
24
- # returns the YAML representation of this topic
25
- def to_yaml_hash(*a)
26
- y={}
27
- y['item_identifiers'] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
28
- y['subject_identifiers'] = subject_identifiers.map{|i| i.reference} unless subject_identifiers.empty?
29
- unless y['item_identifiers'] || y['subject_identifiers']
30
- y['item_identifiers'] = [to_yaml_ref]
31
- end
32
- y['subject_locators'] = subject_locators.map{|i| i.reference} unless subject_locators.empty?
33
- y['names'] = names.map{|i| i.to_yaml_hash} unless names.empty?
34
- y['occurrences'] = occurrences.map{|i| i.to_yaml_hash} unless occurrences.empty?
35
- y
36
- end
37
- def to_yaml(*a)
38
- to_yaml_hash.to_yaml(*a)
39
- end
40
- def to_yaml_ref
41
- if subject_identifiers.first
42
- return subject_identifiers.first.reference
43
- end
44
- if item_identifiers.first
45
- return item_identifiers.first.reference
46
- end
47
- "t#{id}"
21
+ # Returns the YAML representation of this topic as String.
22
+ #
23
+ # :call-seq:
24
+ # to_yaml -> String
25
+ #
26
+ def to_yaml
27
+ to_hash.to_yaml
48
28
  end
49
29
  end
50
30
 
51
31
  module Association
52
- def to_yaml_hash(*a)
53
- y={}
54
- y['reifier'] = reifier.to_yaml_ref if reifier
55
- y['item_identifiers'] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
56
- y['type'] = type.to_yaml_ref if type
57
- y['scope'] = scope.map{|i| i.to_yaml_hash} unless scope.empty?
58
- y['roles'] = roles.map{|i| i.to_yaml_hash} unless roles.empty?
59
- y
60
- end
61
- # returns the YAML representation of this association
62
- def to_yaml(*a)
63
- to_yaml_hash.to_yaml(*a)
32
+ # Returns the YAML representation of this association as String.
33
+ #
34
+ # :call-seq:
35
+ # to_yaml -> String
36
+ #
37
+ def to_yaml
38
+ to_hash.to_yaml
64
39
  end
65
40
  end
66
41
 
67
- module TopicName
68
- def to_yaml_hash(*a)
69
- y={}
70
- y['reifier'] = reifier.to_yaml_ref if reifier
71
- y['item_identifiers'] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
72
- y['value'] = value if value
73
- y['type'] = type.to_yaml_ref if type
74
- y['scope'] = scope.map{|i| i.to_yaml_hash} unless scope.empty?
75
- y['variants'] = variants.map{|i| i.to_yaml_hash} unless variants.empty?
76
- y
77
- end
78
- def to_yaml(*a)
79
- to_yaml_hash.to_yaml(*a)
42
+ module Name
43
+ # Returns the YAML representation of this name as String.
44
+ #
45
+ # :call-seq:
46
+ # to_yaml -> String
47
+ #
48
+ def to_yaml
49
+ to_hash.to_yaml
80
50
  end
81
51
  end
82
52
 
83
53
  module Occurrence
84
- def to_yaml_hash(*a)
85
- y={}
86
- y['reifier'] = reifier.to_yaml_ref if reifier
87
- y['item_identifiers'] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
88
- y['value'] = value if value
89
- y['datatype'] = datatype if datatype
90
- y['type'] = type.to_yaml_ref if type
91
- y['scope'] = scope.map{|i| i.to_yaml_hash} unless scope.empty?
92
- y
93
- end
94
- def to_yaml(*a)
95
- to_yaml_hash.to_yaml(*a)
54
+ # Returns the YAML representation of this occurrence as String.
55
+ #
56
+ # :call-seq:
57
+ # to_yaml -> String
58
+ #
59
+ def to_yaml
60
+ to_hash.to_yaml
96
61
  end
97
62
  end
98
63
 
99
- module AssociationRole
100
- def to_yaml_hash(*a)
101
- y={}
102
- y['reifier'] = reifier.to_yaml_ref if reifier
103
- y['item_identifiers'] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
104
- y['player'] = player.to_yaml_ref if player
105
- y['type'] = type.to_yaml_ref if type
106
- y
107
- end
108
- def to_yaml(*a)
109
- to_yaml_hash.to_yaml(*a)
64
+ module Role
65
+ # Returns the YAML representation of this role as String.
66
+ #
67
+ # :call-seq:
68
+ # to_yaml -> String
69
+ #
70
+ def to_yaml
71
+ to_hash.to_yaml
110
72
  end
111
73
  end
112
74
 
113
75
  module Variant
114
- def to_yaml_hash(*a)
115
- y={}
116
- y['reifier'] = reifier.to_yaml_ref if reifier
117
- y['item_identifiers'] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
118
- y['value'] = value if value
119
- y['scope'] = scope.map{|i| i.to_yaml_hash} unless scope.empty?
120
- y
121
- end
122
- def to_yaml(*a)
123
- to_yaml_hash.to_yaml(*a)
76
+ # Returns the YAML representation of this variant as String.
77
+ #
78
+ # :call-seq:
79
+ # to_yaml -> String
80
+ #
81
+ def to_yaml
82
+ to_hash.to_yaml
124
83
  end
125
84
  end
126
-
85
+
127
86
  RTM.register_extension( self )
87
+
128
88
  end
129
89
  end
130
-
@@ -0,0 +1,23 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module RTM
5
+ module Navigation
6
+ end
7
+ end
8
+
9
+ require "rtm/navigation/association/players"
10
+ require "rtm/navigation/name/characteristics"
11
+ require "rtm/navigation/name/atomify"
12
+ require "rtm/navigation/occurrence/characteristics"
13
+ require "rtm/navigation/occurrence/atomify"
14
+ require "rtm/navigation/topic/characteristics"
15
+ require "rtm/navigation/topic/indicators"
16
+ require "rtm/navigation/topic/items"
17
+ require "rtm/navigation/topic/locators"
18
+ require "rtm/navigation/topic/players"
19
+ require "rtm/navigation/topic/supertypes"
20
+ require "rtm/navigation/topic/traverse"
21
+ require "rtm/navigation/topic/types"
22
+
23
+ RTM.register_extension(RTM::Navigation)
@@ -0,0 +1,25 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module RTM
5
+ module Navigation
6
+ module Association
7
+
8
+ # Returns all players of roles in this association.
9
+ #
10
+ # The optional identifier specifies the type of the roles to be considered.
11
+ # The identifier may be a topic reference.
12
+ #
13
+ # Multiple instances of the same topics are possible.
14
+ #
15
+ # :call-seq:
16
+ # players -> Array of Topics
17
+ # players(identifier) -> Array of Topics
18
+ #
19
+ def players(type = :any)
20
+ return roles(type).map{|r| r.player}
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,19 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module RTM
5
+ module Navigation
6
+ module Name
7
+
8
+ # Returns the atomic value of the Characteristic (Name/Occurrence).
9
+ #
10
+ # :call-seq:
11
+ # atomify -> String
12
+ #
13
+ def atomify
14
+ value
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,33 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module RTM
5
+ module Navigation
6
+ module Name
7
+
8
+ # Returns the Topic this Characteristic (Name/Occurrence) belongs to.
9
+ # The optional argument identifier filters the
10
+ # Characteristic for its type. If the type
11
+ # does not match, nil is returned.
12
+ #
13
+ # The identifier may be a topic reference.
14
+ #
15
+ # :call-seq:
16
+ # reverse_characteristics -> Topic
17
+ # reverse_characteristics(identifier) -> Topic or nil
18
+ #
19
+ def reverse_characteristics(type=:any)
20
+ return parent if type == :any
21
+ _topic = topic_map.get(type)
22
+ return nil unless _topic
23
+ #filter the Name/Occurrence for its type:
24
+ if _topic == self.type
25
+ return parent
26
+ else
27
+ return nil
28
+ end
29
+ end
30
+
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,19 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module RTM
5
+ module Navigation
6
+ module Occurrence
7
+
8
+ # Returns the atomic value of the Characteristic (Name/Occurrence).
9
+ #
10
+ # :call-seq:
11
+ # atomify -> String
12
+ #
13
+ def atomify
14
+ value
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,33 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module RTM
5
+ module Navigation
6
+ module Occurrence
7
+
8
+ # Returns the Topic this Characteristic (Name/Occurrence) belongs to.
9
+ # The optional argument identifier filters the
10
+ # Characteristic for its type. If the type
11
+ # does not match, nil is returned.
12
+ #
13
+ # The identifier may be a topic reference.
14
+ #
15
+ # :call-seq:
16
+ # reverse_characteristics -> Topic
17
+ # reverse_characteristics(identifier) -> Topic or nil
18
+ #
19
+ def reverse_characteristics(type=:any)
20
+ return parent if type == :any
21
+ _topic = topic_map.get(type)
22
+ return nil unless _topic
23
+ #filter the Name/Occurrence for its type:
24
+ if _topic == self.type
25
+ return parent
26
+ else
27
+ return nil
28
+ end
29
+ end
30
+
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,33 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module RTM
5
+ module Navigation
6
+ module Topic
7
+
8
+ # Returns all Names and Occurrences of this Topic.
9
+ # If an identifier is given, only those Names and Occurrences are returned,
10
+ # whose type or supertypes include the identifier.
11
+ #
12
+ # Identifier may be a topic reference.
13
+ #
14
+ # The result may be empty.
15
+ #
16
+ # :call-seq:
17
+ # characteristics -> Array of Names and Occurrences
18
+ # characteristics(identifier) -> Array of Names and Occurrences
19
+ #
20
+ def characteristics(type=:any)
21
+ # FIXME which version of the code?
22
+ return names.to_a + occurrences.to_a if type == :any
23
+ _topic = topic_map.get(type)
24
+ return [] unless _topic
25
+ #names.select{|n| n.type.include?(_topic) || n.type.supertypes.include?(_topic)}.to_a +
26
+ #occurrences.select{|o| o.type.include?(_topic) || o.type.supertypes.include?(_topic)}.to_a
27
+ names.select{|n| n.type.supertypes.include?(_topic)}.to_a +
28
+ occurrences.select{|o| o.type.supertypes.include?(_topic)}.to_a
29
+ end
30
+
31
+ end
32
+ end
33
+ end