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
@@ -1,278 +0,0 @@
1
- require 'rtm'
2
- # Yep, this is the easter egg I told of on the website.
3
- # See the source code at the very end of this file for an explanation.
4
- # Pleace note, this is not beta code, not even alpha - it's just an experiment.
5
-
6
- module ActiveTopicMaps
7
- class Base
8
- def self.inherited(klass)
9
- klass.send(:include, ActiveTopicMaps::Topic)
10
- end
11
- end
12
-
13
- module Topic
14
- def self.included(klass)
15
- klass.extend(ClassMethods)
16
- end
17
- def initialize(topic)
18
- @topic = topic
19
- end
20
- def topic;@topic;end
21
-
22
- module ClassMethods
23
- def acts_as_topic
24
- self.class_eval <<-EOS
25
- def method_missing(name, *args)
26
- @topic.send(name, *args)
27
- end
28
-
29
- alias atm_old_respond_to? respond_to?
30
- def respond_to?(*args)
31
- atm_old_respond_to?(*args) || @topic.respond_to?(*args)
32
- end
33
-
34
- alias old_methods methods
35
- def methods
36
- @methods ||= (old_methods + @topic.methods).uniq
37
- end
38
- EOS
39
- end
40
-
41
- # def acts_smart
42
- # self.class_eval <<-EOS
43
- # alias atm_old_method_missing method_missing
44
- # def method_missing(name, *args)
45
- # if @topic.respond_to?(name)
46
- # @topic.send(name, *args)
47
- # else
48
- # begin
49
- # if name =~ /=$/
50
- # smart_setter(name, *args)
51
- # else
52
- # smart_getter(name, *args)
53
- # end
54
- # rescue
55
- # atm_old_method_missing(name, *args)
56
- # end
57
- # end
58
- # end
59
- #
60
- # def smart_getter(name, *args)
61
- # val = instance_variable_set(("smart_prop_" + name.to_s).to_sym, smart_prop_name)
62
- # prefix = ""
63
- # smart_prop_name ||= (iname = @topic["#{prefix}#{name}"].first) ? iname.value : nil
64
- # instance_variable_set(name, smart_prop_name)
65
- # end
66
- #
67
- # def smart_setter(name, *args)
68
- #
69
- # end
70
- #
71
- # alias atm_old_respond_to? respond_to?
72
- # def respond_to?(*args)
73
- # atm_old_respond_to?(*args) || @topic.respond_to?(*args)
74
- # end
75
- # EOS
76
- # end
77
-
78
- def name(name, type=nil)
79
- type ||= name
80
- prop_getter(name, type, "-")
81
- prop_setter(name, type, "-")
82
- end
83
-
84
- def names(name, type=nil)
85
- type ||= name.singularize
86
- prop_getters(name, type, "-")
87
- prop_adderremover(name, type, "-")
88
- end
89
-
90
- def occurrence(name, type=nil)
91
- type ||= name
92
- prop_getter(name, type)
93
- prop_setter(name, type)
94
- end
95
-
96
- def occurrences(name, type=nil)
97
- type ||= name.singularize
98
- prop_getters(name, type)
99
- prop_adderremover(name, type)
100
- end
101
-
102
- def prop_getter(name, type, prefix="")
103
- self.class_eval <<-EOS
104
- def #{name}
105
- @#{name} ||= (iname = @topic["#{prefix}#{type}"].first) ? iname.value : nil
106
- end
107
- EOS
108
- end
109
-
110
- def prop_getters(name, type, prefix="")
111
- self.class_eval <<-EOS
112
- def #{name}
113
- @#{name} ||= @topic["#{prefix}#{type}"].map{|n| n.value}
114
- end
115
- EOS
116
- end
117
-
118
- def prop_setter(name, type, prefix="")
119
- self.class_eval <<-EOS
120
- def #{name}=(name)
121
- old = @topic["#{prefix}#{type}"].first
122
- @#{name} = if old
123
- old.value = name
124
- else
125
- @topic["#{prefix}#{type}"] = name
126
- end
127
- end
128
- EOS
129
- end
130
-
131
- def prop_adderremover(name, type, prefix="")
132
- self.class_eval <<-EOS
133
- def add_#{name.singularize}(name)
134
- @topic["#{prefix}#{type}"] = name
135
- end
136
- def remove_#{name.singularize}(name)
137
- @topic["#{prefix}#{type}"].each {|item| item.remove if item.value == name}
138
- end
139
- EOS
140
- end
141
-
142
- def has_many(name, rt1, at, rt2, klass)
143
- eval(<<-EOS)
144
- class RTM::AR::Topic
145
- index_property_set :#{name}, :type => :Topic, :rule => {
146
- :transitive => true,
147
- :role_type => "#{rt1}",
148
- :association_type => "#{at}",
149
- :association_arity => 2,
150
- :other_role_type => "#{rt2}",
151
- :add => "#{name.to_s.singularize}",
152
- }
153
- end
154
- EOS
155
- self.class_eval <<-EOS
156
- def #{name}
157
- @topic.#{name}.map{|o| #{klass}.new(o)}
158
- end
159
- def add_#{name.to_s.singularize}(o)
160
- @topic.add_#{name.to_s.singularize}(o.topic)
161
- end
162
- def remove_#{name.to_s.singularize}(o)
163
- @topic.remove_#{name.to_s.singularize}(o.topic)
164
- end
165
- EOS
166
- end
167
-
168
- def topic_map(base_uri_or_tm)
169
- @tm = base_uri_or_tm.is_a?(RTM::TopicMap) ? base_uri_or_tm : RTM.create(base_uri_or_tm)
170
- end
171
-
172
- def create(ref)
173
- t = @tm.get!(ref)
174
- if @psi
175
- @ty ||= @tm.get!(@psi)
176
- t.add_type @ty unless t.types.include? @ty
177
- end
178
- self.new(t)
179
- end
180
- alias get! create
181
-
182
- def find(ref)
183
- t = @tm.get(ref)
184
- self.new(t) if t
185
- end
186
- alias get find
187
-
188
- def find_by_type(ref=nil)
189
- ref ||= @psi
190
- ty = @tm.get(ref)
191
- ty.instances.map {|t| self.new(t)}
192
- end
193
-
194
- def psi(ref)
195
- @psi = ref
196
- end
197
- end
198
- end
199
- end
200
-
201
-
202
- #require 'activetopicmaps'
203
- #RTM.connect
204
- #
205
- #class Person < ActiveTopicMaps::Base
206
- # topic_map "urn:/base"
207
- # psi "person"
208
- #
209
- # name :name
210
- # occurrence :age
211
- # occurrence :shoesize, "http://rtm.rubyforge.org/psi/shoesize" # this tells ActiveTM to use this as occurrence type
212
- #
213
- # def to_s
214
- # a = " (#{age})" if age
215
- # "#{name}#{a}"
216
- # end
217
- #end
218
- #
219
- #class Country
220
- # include ActiveTopicMaps::Topic
221
- #
222
- # topic_map "urn:/base"
223
- # psi "country"
224
- #
225
- # acts_as_topic
226
- #
227
- # name :name
228
- # occurrence :population
229
- # occurrence :size
230
- #
231
- # has_many :inhabitants, "country", "country-inhabitant", "inhabitant", :Person
232
- #
233
- # def to_s
234
- # "There is a country called #{name} with #{population} inhabitants and a size of #{size} km^2.\n" +
235
- # "These are some of the inhabitants: #{inhabitants.map{|i| i.to_s}.join(", ")}."
236
- # end
237
- #end
238
- #
239
- ## create a new object with a (new?) topic
240
- #p = Person.create("max")
241
- #
242
- ## set name, age, shoesize
243
- #p.name = "Max Mustermann"
244
- #p.age = 30
245
- #p.shoesize = 44 # european ;)
246
- #
247
- ## print out the name
248
- #puts p.name
249
- #
250
- ## create a new object, using a topic (might be queried before, ... you know)
251
- #h = Person.new(RTM[0].get!("hans"))
252
- #
253
- ## set name
254
- #h.name = "Hans Maier"
255
- ## set another name (overwrites the old one! this is different from topic["-name"] !!!)
256
- #h.name = "Hans Meyer"
257
- #
258
- ## don't know what that does, maybe you?
259
- #puts h.name
260
- #
261
- ## Norway is the item identifier, here
262
- #no=Country.create("Norway")
263
- #
264
- #no.name="Norway"
265
- #no.population = "4.743.000"
266
- #no.size = "385.199"
267
- #
268
- ## use real person objects here
269
- #no.add_inhabitant h
270
- #no.add_inhabitant p
271
- #
272
- ## use this nice to_s method we provided above
273
- #puts no.to_s
274
- #
275
- ## find hans
276
- #puts "Trying to find Hans: #{Person.find("hans")}"
277
- ## won't find otto
278
- #puts "Trying to find Otto: #{Person.find("otto")}"
@@ -1,58 +0,0 @@
1
- class Class
2
- alias :rtm_old_const_missing :const_missing
3
- def const_missing(const_name)
4
- puts "Constant missing: #{const_name.inspect}"
5
- rtm_old_const_missing(const_name)
6
- end
7
- end
8
- # The following methods allow automatic +map+ping on arrays to their containees properties.
9
- # However this is a dirt hack and did no longer work in ActiveRecord 2.1.0.
10
- # This should be fixed some time later.
11
- #
12
- #class Array
13
- # alias :rtm_old_method_missing :method_missing
14
- # def method_missing(method_name, *args)
15
- # if size > 0 && first.respond_to?(method_name) && (![:__getobj__, :__setobj__].include?(method_name))
16
- # inject([]) {|all,single| all << single.send(method_name, *args)}
17
- # else
18
- # rtm_old_method_missing(method_name, *args)
19
- # end
20
- # end
21
- #
22
- # alias :rtm_old_respond_to? :respond_to?
23
- # def respond_to?(method_name, *args)
24
- # resp = rtm_old_respond_to?(method_name, *args)
25
- # return resp if resp # i.e. if true
26
- # # check for special calls we don't want to pass
27
- # return false if [:__getobj__, :__setobj__].include?(method_name)
28
- # # ... and ask first child otherwise
29
- # @obj && @obj.size > 0 && first.respond_to?(method_name, *args)
30
- # end
31
- #
32
- # def compact_empty
33
- # compact.reject{|e| e.empty?}
34
- # end
35
- #end
36
- class ActiveRecord::Associations::AssociationProxy
37
- # this is needed to prevent the associations from being instantly loaded
38
- alias :rtm_old_respond_to? :respond_to?
39
- def respond_to?(method_name, *args)
40
- return false if method_name == :__getobj__
41
- rtm_old_respond_to?(method_name, *args)
42
- end
43
- end
44
- # ActiveRecord implementation
45
- module RTM::AR
46
- require 'uri'
47
- require 'rtm/backend/active_record/tmdm'
48
- require 'rtm/backend/active_record/tm_delegator'
49
- require 'rtm/backend/active_record/tm_set_delegator'
50
- require 'rtm/backend/active_record/tm_construct'
51
- require 'rtm/backend/active_record/topic_map'
52
- require 'rtm/backend/active_record/traverse_associations'
53
- require 'rtm/backend/active_record/topic'
54
- require 'rtm/backend/active_record/association_and_role'
55
- require 'rtm/backend/active_record/name_variant_occurrence'
56
- require 'rtm/backend/active_record/locators'
57
- require 'rtm/backend/active_record/set_wrapper'
58
- end
@@ -1,116 +0,0 @@
1
- require 'active_record'
2
-
3
- module RTM
4
- module AR
5
- module TMDM
6
- class InitialSchema < ActiveRecord::Migration
7
- def self.up
8
- create_table :topic_maps do |t|
9
- t.column :base_locator, :string, :null => false
10
- end
11
- create_table :topics do |t|
12
- t.column :topic_map_id, :integer, :null => false
13
- t.column :reified_id, :integer
14
- t.column :reified_type, :string
15
- end
16
- create_table :associations do |t|
17
- t.column :topic_map_id, :integer, :null => false
18
- t.column :ttype_id, :integer
19
- end
20
- create_table :association_roles do |t|
21
- t.column :association_id, :integer, :null => false
22
- t.column :ttype_id, :integer
23
- t.column :topic_id, :integer
24
- end
25
- create_table :topic_names do |t|
26
- t.column :topic_id, :integer, :null => false
27
- t.column :ttype_id, :integer
28
- t.column :value, :string
29
- end
30
- create_table :occurrences do |t|
31
- t.column :topic_id, :integer, :null => false
32
- t.column :ttype_id, :integer
33
- t.column :value, :text
34
- t.column :datatype, :string
35
- end
36
- create_table :variants do |t|
37
- t.column :topic_name_id, :integer, :null => false
38
- t.column :value, :text
39
- t.column :datatype, :string
40
- end
41
- create_table :item_identifiers do |t|
42
- t.column :topic_map_id, :integer, :null => false
43
- t.column :reference, :string, :null => false
44
- t.column :topic_map_construct_id, :integer
45
- t.column :topic_map_construct_type, :string
46
- end
47
- create_table :subject_identifiers do |t|
48
- t.column :topic_map_id, :integer, :null => false
49
- t.column :reference, :string, :null => false
50
- t.column :topic_id, :integer
51
- end
52
- create_table :subject_locators do |t|
53
- t.column :topic_map_id, :integer, :null => false
54
- t.column :reference, :string, :null => false
55
- t.column :topic_id, :integer
56
- end
57
- create_table :scoped_objects_topics do |t|
58
- t.column :scoped_object_id, :integer
59
- t.column :scoped_object_type, :string
60
- t.column :topic_id, :integer
61
- end
62
- # execute("
63
- # create view associations_rolecount as
64
- # select a.id as id, a.topic_map_id as topic_map_id, a.ttype_id as ttype_id, count(a.id) as rcnt
65
- # from associations a inner join association_roles r1 on a.id == r1.association_id;
66
- # ")
67
- #
68
- # execute("
69
- # create view associations_cache as
70
- # select distinct
71
- # a.id as id, a.topic_map_id, a.ttype_id, a.rcnt,
72
- # r1.id as role1_id, r1.ttype_id as type1_id, r1.topic_id as player1_id,
73
- # r2.id as role2_id, r2.ttype_id as type2_id, r2.topic_id as player2_id
74
- # from associations_rolecount a
75
- # inner join association_roles r1 on a.id == r1.association_id
76
- # inner join association_roles r2 on a.id == r2.association_id
77
- # where r1.id != r2.id;
78
- # ")
79
- # execute("
80
- # create view associationcache as
81
- # select distinct
82
- # a.id as association_id, a.topic_map_id, a.ttype_id,
83
- # r1.id as association_role1_id, r1.ttype_id as role_type1_id, r1.topic_id as player1_id,
84
- # r2.id as association_role2_id, r2.ttype_id as role_type2_id, r2.topic_id as player2_id
85
- # from associations a
86
- # inner join association_roles r1 on a.id == r1.association_id
87
- # inner join association_roles r2 on a.id == r2.association_id
88
- # where r1.id != r2.id
89
- # ")
90
- end
91
-
92
- def self.down
93
- drop_table :topic_maps
94
- drop_table :topic
95
- drop_table :associations
96
- drop_table :association_roles
97
- drop_table :topic_names
98
- drop_table :occurrences
99
- drop_table :variants
100
- drop_table :scoped_objects_topics
101
- end
102
-
103
- end
104
- end
105
- end
106
- end
107
-
108
- if __FILE__ == $0
109
- puts "Generating SQLite3 Databse tmdm.sqlite3."
110
- ActiveRecord::Base.establish_connection(
111
- :adapter => "sqlite3",
112
- :database => "tmdm.sqlite3"
113
- )
114
- RTM::AR::TMDM::InitialSchema.migrate(:up)
115
- end
116
-