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.
- data/DISCLAIMER +10 -33
- data/LICENSE +201 -0
- data/README +32 -3
- data/lib/rtm.rb +126 -74
- data/lib/rtm/axes.rb +298 -0
- data/lib/rtm/axes/association.rb +76 -0
- data/lib/rtm/axes/associations.rb +96 -0
- data/lib/rtm/axes/assocs_names_occs.rb +56 -0
- data/lib/rtm/axes/characteristic.rb +68 -0
- data/lib/rtm/axes/characteristics.rb +93 -0
- data/lib/rtm/axes/string.rb +76 -0
- data/lib/rtm/axes/strings.rb +87 -0
- data/lib/rtm/axes/topic.rb +233 -0
- data/lib/rtm/axes/topics.rb +280 -0
- data/lib/rtm/{backward_compatibility.rb → deprecated/index_property_set.rb} +3 -0
- data/lib/rtm/engine.rb +101 -0
- data/lib/rtm/extensions.rb +65 -5
- data/lib/rtm/{locator_helpers.rb → helpers/locator.rb} +15 -4
- data/lib/rtm/{helpers.rb → helpers/no_output.rb} +3 -0
- data/lib/rtm/helpers/uri.rb +13 -0
- data/lib/rtm/io.rb +19 -0
- data/lib/rtm/io/from_xtm2_libxml.rb +2 -1
- data/lib/rtm/io/tmapix_from.rb +155 -0
- data/lib/rtm/io/tmapix_to.rb +223 -0
- data/lib/rtm/io/to_hash.rb +154 -0
- data/lib/rtm/io/to_jtm.rb +53 -103
- data/lib/rtm/io/to_rdf.rb +45 -0
- data/lib/rtm/io/to_string.rb +21 -8
- data/lib/rtm/io/to_xtm1.rb +6 -4
- data/lib/rtm/io/to_xtm2.rb +10 -8
- data/lib/rtm/io/to_yaml.rb +59 -100
- data/lib/rtm/navigation.rb +23 -0
- data/lib/rtm/navigation/association/players.rb +25 -0
- data/lib/rtm/navigation/name/atomify.rb +19 -0
- data/lib/rtm/navigation/name/characteristics.rb +33 -0
- data/lib/rtm/navigation/occurrence/atomify.rb +19 -0
- data/lib/rtm/navigation/occurrence/characteristics.rb +33 -0
- data/lib/rtm/navigation/topic/characteristics.rb +33 -0
- data/lib/rtm/navigation/topic/indicators.rb +31 -0
- data/lib/rtm/navigation/topic/items.rb +31 -0
- data/lib/rtm/navigation/topic/locators.rb +31 -0
- data/lib/rtm/navigation/topic/players.rb +27 -0
- data/lib/rtm/navigation/topic/supertypes.rb +166 -0
- data/lib/rtm/navigation/topic/traverse.rb +51 -0
- data/lib/rtm/navigation/topic/types.rb +109 -0
- data/lib/rtm/psi.rb +39 -2
- data/lib/rtm/sugar.rb +47 -0
- data/lib/rtm/sugar/association/hash_access.rb +46 -0
- data/lib/rtm/sugar/occurrence/dynamic_value.rb +58 -0
- data/lib/rtm/sugar/occurrence/external.rb +53 -0
- data/lib/rtm/sugar/reifiable/reifier.rb +21 -0
- data/lib/rtm/sugar/role/counterparts.rb +139 -46
- data/lib/rtm/sugar/topic/best_name.rb +74 -0
- data/lib/rtm/sugar/topic/characteristics.rb +126 -12
- data/lib/rtm/sugar/topic/counterparts.rb +145 -10
- data/lib/rtm/sugar/topic/hash_access.rb +140 -30
- data/lib/rtm/sugar/topic/scoped.rb +114 -0
- data/lib/rtm/sugar/topic/topic_ref.rb +86 -0
- data/lib/rtm/sugar/topic/typed.rb +207 -0
- data/lib/rtm/sugar/topic_map/query_cache.rb +66 -0
- data/lib/rtm/sugar/topic_map/themes.rb +53 -0
- data/lib/rtm/sugar/typed/types.rb +38 -0
- data/lib/rtm/validation.rb +7 -4
- data/lib/rtm/version.rb +30 -0
- data/spec/helpers/spec_exampleexamplegroup.rb +14 -0
- data/spec/rtm/axes/association_spec.rb +88 -0
- data/spec/rtm/axes/associations_spec.rb +60 -0
- data/spec/rtm/axes/assocs_names_occs_spec.rb +9 -0
- data/spec/rtm/axes/characteristic_spec.rb +90 -0
- data/spec/rtm/axes/characteristics_spec.rb +85 -0
- data/spec/rtm/axes/string_spec.rb +145 -0
- data/spec/rtm/axes/strings_spec.rb +168 -0
- data/spec/rtm/axes/topic_spec.rb +124 -0
- data/spec/rtm/axes/topics_spec.rb +103 -0
- data/spec/rtm/base_spec.rb +32 -0
- data/spec/rtm/io/tmapix_from_spec.rb +76 -0
- data/spec/rtm/io/tmapix_to_spec.rb +159 -0
- data/spec/rtm/io/to_hash_spec.rb +90 -0
- data/spec/rtm/io/to_rdf_spec.rb +37 -0
- data/spec/rtm/io/to_string_spec.rb +122 -0
- data/spec/rtm/io/to_yaml_spec.rb +89 -0
- data/spec/rtm/navigation/association/players_spec.rb +58 -0
- data/spec/rtm/navigation/association_spec.rb +52 -0
- data/spec/rtm/navigation/name/atomify_spec.rb +27 -0
- data/spec/rtm/navigation/name/characteristics_spec.rb +34 -0
- data/spec/rtm/navigation/name_spec.rb +52 -0
- data/spec/rtm/navigation/occurrence/atomify_spec.rb +27 -0
- data/spec/rtm/navigation/occurrence/characteristics_spec.rb +34 -0
- data/spec/rtm/navigation/occurrence_spec.rb +52 -0
- data/spec/rtm/navigation/string_spec.rb +51 -0
- data/spec/rtm/navigation/topic/characteristics_spec.rb +55 -0
- data/spec/rtm/navigation/topic/indicators_spec.rb +43 -0
- data/spec/rtm/navigation/topic/items_spec.rb +44 -0
- data/spec/rtm/navigation/topic/locators_spec.rb +44 -0
- data/spec/rtm/navigation/topic/players_spec.rb +48 -0
- data/spec/rtm/navigation/topic/scope_spec.rb +41 -0
- data/spec/rtm/navigation/topic/supertypes_spec.rb +376 -0
- data/spec/rtm/navigation/topic/traverse_spec.rb +64 -0
- data/spec/rtm/navigation/topic/types_spec.rb +195 -0
- data/spec/rtm/navigation/topic_spec.rb +153 -0
- data/spec/rtm/sugar/association/hash_access_spec.rb +55 -0
- data/spec/rtm/sugar/occurrence/dynamic_value_spec.rb +171 -0
- data/spec/rtm/sugar/occurrence/external_spec.rb +129 -0
- data/spec/rtm/sugar/reifiable/reifier_spec.rb +41 -0
- data/spec/rtm/sugar/role/counterparts_spec.rb +193 -0
- data/spec/rtm/sugar/topic/best_name_spec.rb +25 -0
- data/spec/rtm/sugar/topic/characteristics_spec.rb +333 -0
- data/spec/rtm/sugar/topic/counterparts_spec.rb +224 -0
- data/spec/rtm/sugar/topic/hash_access_spec.rb +234 -0
- data/spec/rtm/sugar/topic/scoped_spec.rb +195 -0
- data/spec/rtm/sugar/topic/topic_ref_spec.rb +44 -0
- data/spec/rtm/sugar/topic/typed_spec.rb +217 -0
- data/spec/rtm/sugar/topic_map/themes_spec.rb +67 -0
- data/spec/rtm/sugar/typed/types_spec.rb +24 -0
- data/spec/rtm/tmapi/core/association_spec.rb +169 -0
- data/spec/rtm/tmapi/core/construct_spec.rb +25 -0
- data/spec/rtm/tmapi/core/datatype_aware_spec.rb +236 -0
- data/spec/rtm/tmapi/core/name_spec.rb +270 -0
- data/spec/rtm/tmapi/core/occurrence_spec.rb +53 -0
- data/spec/rtm/tmapi/core/reifiable_spec.rb +168 -0
- data/spec/rtm/tmapi/core/role_spec.rb +73 -0
- data/spec/rtm/tmapi/core/scoped_spec.rb +441 -0
- data/spec/rtm/tmapi/core/topic_map_spec.rb +716 -0
- data/spec/rtm/tmapi/core/topic_spec.rb +1468 -0
- data/spec/rtm/tmapi/core/typed_spec.rb +112 -0
- data/spec/rtm/tmapi/core/variant_spec.rb +52 -0
- data/spec/rtm/tmapi/ext/java_util_set_spec.rb +34 -0
- data/spec/rtm/tmapi_spec.rb +44 -0
- data/spec/rtm/utils/sparql_spec.rb +26 -0
- data/spec/rtm_spec.rb +93 -0
- data/spec/spec_helper.rb +28 -0
- data/test/javalibs/junit-4.5.jar +0 -0
- data/test/javalibs/tmapi-2.0-tests.jar +0 -0
- data/test/tmapi_tests.rb +25 -0
- metadata +169 -65
- data/COPYRIGHT +0 -4
- data/lib/Rakefile.rb +0 -42
- data/lib/activetopicmaps.rb +0 -278
- data/lib/rtm/backend/active_record.rb +0 -58
- data/lib/rtm/backend/active_record/001_initial_schema.rb +0 -116
- data/lib/rtm/backend/active_record/association_and_role.rb +0 -33
- data/lib/rtm/backend/active_record/locators.rb +0 -55
- data/lib/rtm/backend/active_record/name_variant_occurrence.rb +0 -45
- data/lib/rtm/backend/active_record/quaaxtm2rtm.rb +0 -113
- data/lib/rtm/backend/active_record/quaaxtm2rtmviews.rb +0 -134
- data/lib/rtm/backend/active_record/set_wrapper.rb +0 -98
- data/lib/rtm/backend/active_record/tm_construct.rb +0 -62
- data/lib/rtm/backend/active_record/tm_delegator.rb +0 -345
- data/lib/rtm/backend/active_record/tm_set_delegator.rb +0 -195
- data/lib/rtm/backend/active_record/tmdm.rb +0 -298
- data/lib/rtm/backend/active_record/topic.rb +0 -87
- data/lib/rtm/backend/active_record/topic_map.rb +0 -314
- data/lib/rtm/backend/active_record/traverse_associations.rb +0 -87
- data/lib/rtm/base.rb +0 -92
- data/lib/rtm/connect.rb +0 -92
- data/lib/rtm/core_ext.rb +0 -6
- data/lib/rtm/io/from_xtm2.rb +0 -263
- data/lib/rtm/merging/merging.rb +0 -307
- data/lib/rtm/pimp_my_api.rb +0 -28
- data/lib/rtm/sugar/topic/identifier_direct.rb +0 -11
- data/lib/rtm/sugar/topic/predefined_associations.rb +0 -42
- data/lib/run_main_project.rb +0 -16
- data/test/base_test.rb +0 -162
data/lib/rtm/axes.rb
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
|
|
2
|
+
# License: Apache License, Version 2.0
|
|
3
|
+
|
|
4
|
+
module RTM
|
|
5
|
+
module Axes
|
|
6
|
+
|
|
7
|
+
# ---- Proxy ---------------------------------------------------------------#
|
|
8
|
+
class Proxy
|
|
9
|
+
#attr_accessor :construct
|
|
10
|
+
attr_reader :construct
|
|
11
|
+
attr_reader :tm
|
|
12
|
+
|
|
13
|
+
def initialize(construct,tm)
|
|
14
|
+
test_for_type(construct)
|
|
15
|
+
@construct = construct
|
|
16
|
+
@tm = tm
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# ---- ItemProxy -----------------------------------------------------------#
|
|
21
|
+
class ItemProxy < Proxy
|
|
22
|
+
alias result construct
|
|
23
|
+
alias :tmapi :result
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# ---- RTM::Axes::Topic ----------------------------------------#
|
|
27
|
+
class Topic < ItemProxy
|
|
28
|
+
require "rtm/axes/topic"
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def test_for_type(construct)
|
|
33
|
+
unless construct.is_a?(RTM::Topic)
|
|
34
|
+
raise("This is not a Topic. A RTM::Axes::Topic object requires a RTM::Topic.")
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# ---- Association ---------------------------------------------------------#
|
|
40
|
+
class Association < ItemProxy
|
|
41
|
+
require "rtm/axes/association"
|
|
42
|
+
|
|
43
|
+
private
|
|
44
|
+
|
|
45
|
+
def test_for_type(construct)
|
|
46
|
+
unless construct.is_a?(RTM::Association)
|
|
47
|
+
raise("This is not an Association. An RTM::Axes::Association object requires a RTM::Association.")
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# ---- RTM::Axes::Characteristic -------------------------------#
|
|
53
|
+
class Characteristic < ItemProxy
|
|
54
|
+
require "rtm/axes/characteristic"
|
|
55
|
+
|
|
56
|
+
private
|
|
57
|
+
|
|
58
|
+
def test_for_type(construct)
|
|
59
|
+
unless construct.is_a?(RTM::Name) || construct.is_a?(RTM::Occurrence)
|
|
60
|
+
raise("This is not a Name or Occurrence. A RTM::Axes::Characteristic object requires a RTM::Name or RTM::Occurrence.")
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# ---- RTM::Axes::Name -----------------------------------------#
|
|
66
|
+
class Name < Characteristic
|
|
67
|
+
|
|
68
|
+
private
|
|
69
|
+
|
|
70
|
+
def test_for_type(construct)
|
|
71
|
+
unless construct.is_a?(RTM::Name)
|
|
72
|
+
raise("This is not a Name. A RTM::Axes::Name object requires a RTM::Name.")
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
# ---- RTM::Axes::Occurrence -----------------------------------#
|
|
77
|
+
class Occurrence < Characteristic
|
|
78
|
+
|
|
79
|
+
private
|
|
80
|
+
|
|
81
|
+
def test_for_type(construct)
|
|
82
|
+
unless construct.is_a?(RTM::Occurrence)
|
|
83
|
+
raise("This is not a Occurrence. A RTM::Axes::Occurrence object requires a RTM::Occurrence.")
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# ---- RTM::Axes::String ---------------------------------------#
|
|
89
|
+
class String < ItemProxy
|
|
90
|
+
require "rtm/axes/string"
|
|
91
|
+
|
|
92
|
+
private
|
|
93
|
+
|
|
94
|
+
def test_for_type(construct)
|
|
95
|
+
unless construct.is_a?(Object::String)
|
|
96
|
+
raise("This is not a String. A RTM::Axes::String object requires a String.")
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# ---- ArrayProxy ----------------------------------------------------------#
|
|
102
|
+
module ArrayProxy
|
|
103
|
+
def define_helper(method,*args)
|
|
104
|
+
inject([]){|all,containee| all << containee.send(method,*args)}.flatten
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# # ---- ArrayProxy ----------------------------------------------------------#
|
|
109
|
+
# class ArrayProxy < Proxy
|
|
110
|
+
## def method_missing(method,*args)
|
|
111
|
+
## if @construct.all? {|containee| containee.respond_to?(method)}
|
|
112
|
+
## ArrayProxy.new(@construct.inject([]){|all,containee| all << containee.send(method,*args)})
|
|
113
|
+
## else
|
|
114
|
+
## super
|
|
115
|
+
## end
|
|
116
|
+
## end
|
|
117
|
+
#
|
|
118
|
+
#
|
|
119
|
+
#
|
|
120
|
+
# def self.define_proxy_return_topics(method,*args)
|
|
121
|
+
# define_method method do |*args|
|
|
122
|
+
# _res = filter_helper(method,*args)
|
|
123
|
+
# _res = _res.map{|item| item.construct}.flatten
|
|
124
|
+
# if _res.empty?
|
|
125
|
+
# EmptyArrayProxy.new(_res)
|
|
126
|
+
# else
|
|
127
|
+
# Topics.new(_res)
|
|
128
|
+
# end
|
|
129
|
+
# end
|
|
130
|
+
# end
|
|
131
|
+
#
|
|
132
|
+
# def self.define_proxy_return_associations(method,*args)
|
|
133
|
+
# define_method method do |*args|
|
|
134
|
+
# _res = filter_helper(method,*args)
|
|
135
|
+
# _res = _res.map{|item| item.construct}.flatten
|
|
136
|
+
# if _res.empty?
|
|
137
|
+
# EmptyArrayProxy.new(_res)
|
|
138
|
+
# else
|
|
139
|
+
# Associations.new(_res)
|
|
140
|
+
# end
|
|
141
|
+
# end
|
|
142
|
+
# end
|
|
143
|
+
#
|
|
144
|
+
# def self.define_proxy_return_characteristics(method,*args)
|
|
145
|
+
# define_method method do |*args|
|
|
146
|
+
# _res = filter_helper(method,*args)
|
|
147
|
+
# _res = _res.map{|item| item.construct}.flatten
|
|
148
|
+
# if _res.empty?
|
|
149
|
+
# EmptyArrayProxy.new(_res)
|
|
150
|
+
# else
|
|
151
|
+
# Characteristics.new(_res)
|
|
152
|
+
# end
|
|
153
|
+
# end
|
|
154
|
+
# end
|
|
155
|
+
#
|
|
156
|
+
# def self.define_proxy_return_strings(method,*args)
|
|
157
|
+
# define_method method do |*args|
|
|
158
|
+
# _res = filter_helper(method,*args)
|
|
159
|
+
# _res = _res.map{|item| item.construct}.flatten
|
|
160
|
+
# if _res.empty?
|
|
161
|
+
# EmptyArrayProxy.new(_res)
|
|
162
|
+
# else
|
|
163
|
+
# Strings.new(_res)
|
|
164
|
+
# end
|
|
165
|
+
# end
|
|
166
|
+
# end
|
|
167
|
+
#
|
|
168
|
+
# def self.define_proxy_return_string(method,*args)
|
|
169
|
+
# define_method method do |*args|
|
|
170
|
+
# _res = filter_helper(method,*args)
|
|
171
|
+
# if _res.empty?
|
|
172
|
+
# EmptyArrayProxy.new(_res)
|
|
173
|
+
# else
|
|
174
|
+
# Strings.new(_res)
|
|
175
|
+
# end
|
|
176
|
+
# end
|
|
177
|
+
# end
|
|
178
|
+
#
|
|
179
|
+
# def self.define_proxy_return_item(method,*args)
|
|
180
|
+
# define_method method do |*args|
|
|
181
|
+
# _res = filter_helper(method,*args)
|
|
182
|
+
# if _res.empty?
|
|
183
|
+
# EmptyArrayProxy.new(_res)
|
|
184
|
+
# else
|
|
185
|
+
# AssocsNamesOccsProxy.new(_res)
|
|
186
|
+
# end
|
|
187
|
+
# end
|
|
188
|
+
# end
|
|
189
|
+
#
|
|
190
|
+
# def result
|
|
191
|
+
# @construct.map{|containee| containee.result}
|
|
192
|
+
# end
|
|
193
|
+
# alias :tmapi :result
|
|
194
|
+
#
|
|
195
|
+
# def filter_helper(method,*args)
|
|
196
|
+
# _res = define_helper(method,*args) #Array
|
|
197
|
+
# _res = _res.reject{|item| item.empty? }
|
|
198
|
+
# _res = _res.reject{|item| item.class == NilProxy}
|
|
199
|
+
# end
|
|
200
|
+
#
|
|
201
|
+
# def define_helper(method,*args)
|
|
202
|
+
# #@construct.inject([]){|all,containee| all << containee.send(method,*args).construct}.flatten
|
|
203
|
+
# @construct.inject([]){|all,containee| all << containee.send(method,*args)}
|
|
204
|
+
# end
|
|
205
|
+
# end
|
|
206
|
+
|
|
207
|
+
# # ---- Topics ---------------------------------------------------------#
|
|
208
|
+
# class Topics < ArrayProxy
|
|
209
|
+
# define_proxy_return_characteristics(:characteristics)
|
|
210
|
+
# define_proxy_return_strings(:indicators)
|
|
211
|
+
# define_proxy_return_string(:item)
|
|
212
|
+
# define_proxy_return_strings(:locators)
|
|
213
|
+
# define_proxy_return_associations(:reverse_players)
|
|
214
|
+
# define_proxy_return_item(:reifier)
|
|
215
|
+
#
|
|
216
|
+
# define_proxy_return_topics(:supertypes)
|
|
217
|
+
#
|
|
218
|
+
# define_proxy_return_topics(:subtypes)
|
|
219
|
+
# define_proxy_return_topics(:traverse)
|
|
220
|
+
# define_proxy_return_topics(:types)
|
|
221
|
+
# define_proxy_return_topics(:instances)
|
|
222
|
+
# define_proxy_return_topics(:reverse_types)
|
|
223
|
+
# define_proxy_return_topics(:reverse_instances)
|
|
224
|
+
# define_proxy_return_associations(:reverse_roles)
|
|
225
|
+
# end
|
|
226
|
+
end
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
module RTM::AxesExtension;end
|
|
230
|
+
module RTM::AxesExtension::Topic
|
|
231
|
+
|
|
232
|
+
# Changes from TMAPI-mode to Axes-mode.
|
|
233
|
+
#
|
|
234
|
+
# :call-seq:
|
|
235
|
+
# axes -> RTM::Axes::Topic
|
|
236
|
+
#
|
|
237
|
+
def axes(tm = self.topic_map)
|
|
238
|
+
RTM::Axes::Topic.new(self, tm)
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
module RTM::AxesExtension::Name
|
|
243
|
+
|
|
244
|
+
# Changes from TMAPI-mode to Axes-mode.
|
|
245
|
+
#
|
|
246
|
+
# :call-seq:
|
|
247
|
+
# axes -> RTM::Axes::Name
|
|
248
|
+
#
|
|
249
|
+
def axes(tm = self.topic_map)
|
|
250
|
+
RTM::Axes::Name.new(self, tm)
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
module RTM::AxesExtension::Occurrence
|
|
255
|
+
|
|
256
|
+
# Changes from TMAPI-mode to Axes-mode.
|
|
257
|
+
#
|
|
258
|
+
# :call-seq:
|
|
259
|
+
# axes -> RTM::Axes::Occurrence
|
|
260
|
+
#
|
|
261
|
+
def axes(tm = self.topic_map)
|
|
262
|
+
RTM::Axes::Occurrence.new(self, tm)
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
module RTM::AxesExtension::Association
|
|
267
|
+
|
|
268
|
+
# Changes from TMAPI-mode to Axes-mode.
|
|
269
|
+
#
|
|
270
|
+
# :call-seq:
|
|
271
|
+
# axes -> RTM::Axes::Association
|
|
272
|
+
#
|
|
273
|
+
def axes(tm = self.topic_map)
|
|
274
|
+
RTM::Axes::Association.new(self, tm)
|
|
275
|
+
end
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
class String
|
|
279
|
+
|
|
280
|
+
# Changes from TMAPI-mode to Axes-mode.
|
|
281
|
+
#
|
|
282
|
+
# A TopicMap must be specified.
|
|
283
|
+
#
|
|
284
|
+
# :call-seq:
|
|
285
|
+
# axes(topic_map) -> RTM::Axes::String
|
|
286
|
+
#
|
|
287
|
+
def axes(tm)
|
|
288
|
+
RTM::Axes::String.new(self,tm)
|
|
289
|
+
end
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
RTM.register_extension(RTM::AxesExtension)
|
|
293
|
+
|
|
294
|
+
require "rtm/axes/topics"
|
|
295
|
+
require "rtm/axes/associations"
|
|
296
|
+
require "rtm/axes/characteristics"
|
|
297
|
+
require "rtm/axes/assocs_names_occs"
|
|
298
|
+
require "rtm/axes/strings"
|
|
@@ -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
|
+
|
|
6
|
+
class Association < ItemProxy
|
|
7
|
+
|
|
8
|
+
# ---- players-axis ------------------------------------------------------#
|
|
9
|
+
|
|
10
|
+
# Returns all Role players of Roles in this Association.
|
|
11
|
+
#
|
|
12
|
+
# The optional identifier specifies the type of the Roles to be considered.
|
|
13
|
+
# The identifier may be a topic reference.
|
|
14
|
+
#
|
|
15
|
+
# Multiple instances of the same Topic are possible.
|
|
16
|
+
# The result may be empty.
|
|
17
|
+
#
|
|
18
|
+
# :call-seq:
|
|
19
|
+
# players -> Array of Topics
|
|
20
|
+
# players(identifier) -> Array of Topics
|
|
21
|
+
#
|
|
22
|
+
def players(type=:any)
|
|
23
|
+
_res = @construct.players(type).map{|r| r.axes}
|
|
24
|
+
_res.extend(Topics)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# ---- reifier-axis ------------------------------------------------------#
|
|
28
|
+
|
|
29
|
+
# Returns the reifing Topic or nil, if no such Topic exists.
|
|
30
|
+
#
|
|
31
|
+
# :call-seq:
|
|
32
|
+
# reverse_reified -> Topic or nil
|
|
33
|
+
#
|
|
34
|
+
def reverse_reifier
|
|
35
|
+
_res = @construct.reifier #Topic or nil
|
|
36
|
+
RTM::Axes::Topic.new(_res,@tm) if _res
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# ---- roles-axis --------------------------------------------------------#
|
|
40
|
+
|
|
41
|
+
# Returns all Topics that are types of Roles of this Association.
|
|
42
|
+
# Multiple instances of the same Topic are possible.
|
|
43
|
+
#
|
|
44
|
+
# The result may be empty.
|
|
45
|
+
#
|
|
46
|
+
# :call-seq:
|
|
47
|
+
# roles -> Array of Topics
|
|
48
|
+
#
|
|
49
|
+
def roles
|
|
50
|
+
_res = @construct.getRoles.map {|r| r.getType }
|
|
51
|
+
_res = _res.map{|r| r.axes}
|
|
52
|
+
_res.extend(Topics)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# ---- scope-axis --------------------------------------------------------#
|
|
56
|
+
|
|
57
|
+
# Returns the scope of this Association.
|
|
58
|
+
#
|
|
59
|
+
# The result may be empty.
|
|
60
|
+
#
|
|
61
|
+
# :call-seq:
|
|
62
|
+
# scope -> Array of Topics
|
|
63
|
+
#
|
|
64
|
+
def scope
|
|
65
|
+
_res = @construct.scope.map{|r| r.axes} #Array of Topics or empty Array
|
|
66
|
+
_res.extend(Topics)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# # ---- traverse-axis -----------------------------------------------------#
|
|
70
|
+
# #def reverse_traverse
|
|
71
|
+
# #
|
|
72
|
+
# #end
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
|
|
2
|
+
# License: Apache License, Version 2.0
|
|
3
|
+
|
|
4
|
+
module RTM::Axes
|
|
5
|
+
module Associations
|
|
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
|
+
# ---- players-axis ------------------------------------------------------#
|
|
17
|
+
|
|
18
|
+
# Returns all Role players of Roles in these Associations.
|
|
19
|
+
#
|
|
20
|
+
# The optional identifier specifies the type of the Roles to be considered.
|
|
21
|
+
# The identifier may be a topic reference.
|
|
22
|
+
#
|
|
23
|
+
# Multiple instances of the same Topic are possible.
|
|
24
|
+
# The result may be empty.
|
|
25
|
+
#
|
|
26
|
+
# :call-seq:
|
|
27
|
+
# players -> Array of Topics
|
|
28
|
+
# players(identifier) -> Array of Topics
|
|
29
|
+
#
|
|
30
|
+
def players(type=:any)
|
|
31
|
+
_res = self.inject([]){|all,containee| all << containee.send(:players,type)}.flatten
|
|
32
|
+
### NO UNIQUE ###
|
|
33
|
+
_res = _res.extend(Topics)
|
|
34
|
+
_res
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# ---- reifier-axis ------------------------------------------------------#
|
|
38
|
+
|
|
39
|
+
# Returns the reifing Topics of these Assocations only
|
|
40
|
+
# if such Topics exist.
|
|
41
|
+
#
|
|
42
|
+
# The result may be empty.
|
|
43
|
+
#
|
|
44
|
+
# :call-seq:
|
|
45
|
+
# reverse_reified -> Array of Topics
|
|
46
|
+
#
|
|
47
|
+
def reverse_reifier
|
|
48
|
+
_res = self.inject([]){|all,containee| all << containee.send(:reverse_reifier)}.flatten
|
|
49
|
+
_res = _res.select{|i| i}
|
|
50
|
+
### NO UNIQUE NEEDED
|
|
51
|
+
_res = _res.extend(Topics)
|
|
52
|
+
_res
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# ---- roles-axis --------------------------------------------------------#
|
|
56
|
+
|
|
57
|
+
# Returns all Topics that are types of Roles in these Associations.
|
|
58
|
+
# Multiple instances of the same Topic are possible.
|
|
59
|
+
#
|
|
60
|
+
# The result may be empty.
|
|
61
|
+
#
|
|
62
|
+
# :call-seq:
|
|
63
|
+
# roles -> Array of Topics
|
|
64
|
+
#
|
|
65
|
+
def roles
|
|
66
|
+
_res = self.inject([]){|all,containee| all << containee.send(:roles)}.flatten
|
|
67
|
+
### NO UNIQUE ###
|
|
68
|
+
_res = _res.extend(Topics)
|
|
69
|
+
_res
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# ---- scope-axis --------------------------------------------------------#
|
|
73
|
+
|
|
74
|
+
# Returns the scope of these Associations.
|
|
75
|
+
#
|
|
76
|
+
# The result may be empty.
|
|
77
|
+
#
|
|
78
|
+
# :call-seq:
|
|
79
|
+
# scope -> Array of Topics
|
|
80
|
+
#
|
|
81
|
+
def scope
|
|
82
|
+
_res = self.inject([]){|all,containee| all << containee.send(:scope)}.flatten
|
|
83
|
+
### FLAG UNIQUE ###
|
|
84
|
+
_res = _res.map{|i| i.construct}.uniq.map{|i| i.axes}
|
|
85
|
+
### ###
|
|
86
|
+
_res = _res.extend(Topics)
|
|
87
|
+
_res
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# # ---- traverse-axis -----------------------------------------------------#
|
|
91
|
+
# #def reverse_traverse
|
|
92
|
+
# #
|
|
93
|
+
# #end
|
|
94
|
+
|
|
95
|
+
end
|
|
96
|
+
end
|