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.
- data/DISCLAIMER +10 -33
- data/LICENSE +201 -0
- data/README +3 -3
- data/lib/rtm.rb +148 -74
- data/lib/rtm/axes.rb +295 -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 +58 -0
- data/lib/rtm/extensions.rb +11 -1
- 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 +18 -0
- data/lib/rtm/io/from_xtm2_libxml.rb +2 -1
- data/lib/rtm/io/ontopia_io.rb +25 -0
- data/lib/rtm/io/tmapix.rb +234 -0
- data/lib/rtm/io/to_hash.rb +116 -0
- data/lib/rtm/io/to_jtm.rb +53 -103
- data/lib/rtm/io/to_rdf.rb +30 -0
- data/lib/rtm/io/to_string.rb +8 -6
- 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 +29 -98
- data/lib/rtm/navigation.rb +37 -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 +162 -0
- data/lib/rtm/navigation/topic/traverse.rb +51 -0
- data/lib/rtm/navigation/topic/types.rb +107 -0
- data/lib/rtm/psi.rb +33 -2
- data/lib/rtm/sugar.rb +34 -0
- data/lib/rtm/sugar/association/hash_access.rb +46 -0
- data/lib/rtm/sugar/occurrence/dynamic_value.rb +75 -0
- data/lib/rtm/{pimp_my_api.rb → sugar/occurrence/externalize.rb} +3 -0
- data/lib/rtm/sugar/role/counterparts.rb +133 -46
- data/lib/rtm/sugar/topic/characteristics.rb +126 -12
- data/lib/rtm/sugar/topic/counterparts.rb +130 -7
- data/lib/rtm/sugar/topic/hash_access.rb +140 -30
- data/lib/rtm/sugar/topic/scoped.rb +65 -0
- data/lib/rtm/sugar/topic/topic_ref.rb +35 -0
- data/lib/rtm/sugar/topic/typed.rb +159 -0
- data/lib/rtm/sugar/typed/types.rb +38 -0
- data/lib/rtm/validation.rb +8 -5
- data/lib/rtm/version.rb +18 -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_spec.rb +85 -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 +16 -0
- data/spec/rtm/sugar/role/counterparts_spec.rb +191 -0
- data/spec/rtm/sugar/topic/characteristics_spec.rb +318 -0
- data/spec/rtm/sugar/topic/counterparts_spec.rb +184 -0
- data/spec/rtm/sugar/topic/hash_access_spec.rb +234 -0
- data/spec/rtm/sugar/topic/scoped_spec.rb +131 -0
- data/spec/rtm/sugar/topic/topic_ref_spec.rb +44 -0
- data/spec/rtm/sugar/topic/typed_spec.rb +155 -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/name_spec.rb +85 -0
- data/spec/rtm/tmapi/core/occurrence_spec.rb +96 -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 +403 -0
- data/spec/rtm/tmapi/core/topic_map_spec.rb +648 -0
- data/spec/rtm/tmapi/core/topic_spec.rb +992 -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 +94 -0
- data/spec/spec_helper.rb +23 -0
- data/test/base_unit_test.rb +161 -0
- data/test/{base_test.rb → base_unit_test_tmapi.rb} +46 -43
- metadata +122 -66
- 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/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/lib/rtm/merging/merging.rb
DELETED
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
module RTM
|
|
2
|
-
class MergeException < Exception; end
|
|
3
|
-
class TopicMergeException < MergeException; end
|
|
4
|
-
module Merging
|
|
5
|
-
module ReWrap
|
|
6
|
-
protected
|
|
7
|
-
def merge_rewrap(other)
|
|
8
|
-
# let the wrapper point to the new object
|
|
9
|
-
old_getobj = other.__getobj__
|
|
10
|
-
other.__setobj__(self.__getobj__) if self.respond_to?(:__getobj__) && other.respond_to?(:__setobj__)
|
|
11
|
-
# and destroy the old one
|
|
12
|
-
old_getobj.reload
|
|
13
|
-
__getobj__.reload
|
|
14
|
-
old_getobj.destroy
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
module MergeItemIdentifiers
|
|
18
|
-
protected
|
|
19
|
-
def merge_item_identifiers(other)
|
|
20
|
-
#self.item_identifiers.add_all other.item_identifiers
|
|
21
|
-
RTM::AR::TMDM::ItemIdentifier.move_all(
|
|
22
|
-
["topic_map_construct_id", other.__getobj__.id, self.__getobj__.id],
|
|
23
|
-
["topic_map_construct_type", other.__getobj__.class.name, self.__getobj__.class.name]
|
|
24
|
-
)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
module MergeReifiable
|
|
28
|
-
include MergeItemIdentifiers
|
|
29
|
-
include ReWrap
|
|
30
|
-
protected
|
|
31
|
-
def merge_reifiable(other)
|
|
32
|
-
if other.reifier && self.reifier
|
|
33
|
-
self.reifier.merge(other.reifier)
|
|
34
|
-
elsif other.reifier
|
|
35
|
-
self.reifier = other.reifier
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
module Association
|
|
41
|
-
include Merging::MergeReifiable
|
|
42
|
-
|
|
43
|
-
def merge(other)
|
|
44
|
-
# The procedure for merging two association items A and B is given below.
|
|
45
|
-
|
|
46
|
-
# 1. Create a new association item, C.
|
|
47
|
-
# -> we will instead just modify a
|
|
48
|
-
|
|
49
|
-
# 2. Set C's [type] property to the value of A's [type] property. B's value is equal to that of A and need not be taken into account.
|
|
50
|
-
# 3. Set C's [scope] property to the value of A's [scope] property. B's value is equal to that of A and need not be taken into account.
|
|
51
|
-
# 4. Set C's [roles] property to the value of A's [roles] property. B's value is equal to that of A and need not be taken into account.
|
|
52
|
-
# -> nothing to do till here
|
|
53
|
-
|
|
54
|
-
# 5. Set C's [reifier] property to the value of A's [reifier] property if it is not null, and to the value of B's [reifier] property if A's property is null. If both A and B have non-null values, the topic items shall be merged, and the topic item resulting from the merge set as the value of C's [reifier] property.
|
|
55
|
-
self.merge_reifiable other
|
|
56
|
-
|
|
57
|
-
# 6. Set C's [item identifiers] property to the union of the values of A's and B's [item identifiers] properties.
|
|
58
|
-
self.merge_item_identifiers other
|
|
59
|
-
|
|
60
|
-
# 7. Remove A and B from the [associations] property of the topic map item in their [parent] properties, and add C.
|
|
61
|
-
#self.parent.associations.remove other
|
|
62
|
-
|
|
63
|
-
# let the wrapper point to the new object
|
|
64
|
-
#other.__setobj__(self.__getobj__) if self.respond_to?(:__getobj__) && other.respond_to?(:__setobj__)
|
|
65
|
-
self.merge_rewrap other
|
|
66
|
-
|
|
67
|
-
self
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
module AssociationRole
|
|
72
|
-
include Merging::MergeReifiable
|
|
73
|
-
|
|
74
|
-
def merge(other)
|
|
75
|
-
# The procedure for merging two association role items A and B is given below.
|
|
76
|
-
# -> we will instead just modify a
|
|
77
|
-
|
|
78
|
-
# 1. Create a new association role item, C.
|
|
79
|
-
# 2. Set C's [player] property to the value of A's [player] property. B's value is equal to that of A and need not be taken into account.
|
|
80
|
-
# 3. Set C's [type] property to the value of A's [type] property. B's value is equal to that of A and need not be taken into account.
|
|
81
|
-
# -> nothing to do till here
|
|
82
|
-
|
|
83
|
-
# 4. Set C's [item identifiers] property to the union of the values of A's and B's [item identifiers] properties.
|
|
84
|
-
self.merge_item_identifiers other
|
|
85
|
-
|
|
86
|
-
# 5. Set C's [reifier] property to the value of A's [reifier] property if it is not null,
|
|
87
|
-
# and to the value of B's [reifier] property if A's property is null.
|
|
88
|
-
# If both A and B have non-null values, the topic items shall be merged,
|
|
89
|
-
# and the topic item resulting from the merge set as the value of C's [reifier] property.
|
|
90
|
-
self.merge_reifiable other
|
|
91
|
-
|
|
92
|
-
# 6. Remove A and B from the [roles] property of the association item in their [parent] properties, and add C.
|
|
93
|
-
#self.parent.roles.remove other
|
|
94
|
-
|
|
95
|
-
#puts "#{self.parent.object_id} and #{other.parent.object_id}"
|
|
96
|
-
|
|
97
|
-
# let the wrapper point to the new object
|
|
98
|
-
#other.__setobj__(self.__getobj__) if self.respond_to?(:__getobj__) && other.respond_to?(:__setobj__)
|
|
99
|
-
self.merge_rewrap other
|
|
100
|
-
|
|
101
|
-
self
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
module Occurrence
|
|
106
|
-
include Merging::MergeReifiable
|
|
107
|
-
|
|
108
|
-
def merge(other)
|
|
109
|
-
# 1. Create a new occurrence item, C.
|
|
110
|
-
# -> we will instead just modify a
|
|
111
|
-
|
|
112
|
-
# 2. Set C's [value] property to the value of A's [value] property. B's value is equal to that of A and need not be taken into account.
|
|
113
|
-
# 3. Set C's [datatype] property to the value of A's [datatype] property. B's value is equal to that of A and need not be taken into account.
|
|
114
|
-
# 4. Set C's [scope] property to the value of A's [scope] property. B's value is equal to that of A and need not be taken into account.
|
|
115
|
-
# 5. Set C's [type] property to the value of A's [type] property. B's value is equal to that of A and need not be taken into account.
|
|
116
|
-
# -> nothing to do till here
|
|
117
|
-
|
|
118
|
-
# 6. Set C's [reifier] property to the value of A's [reifier] property if it is not null, and to the value of B's [reifier] property if A's property is null. If both A and B have non-null values, the topic items shall be merged, and the topic item resulting from the merge set as the value of C's [reifier] property.
|
|
119
|
-
self.merge_reifiable other
|
|
120
|
-
|
|
121
|
-
# 7. Set C's [item identifiers] property to the union of the values of A's and B's [item identifiers] properties.
|
|
122
|
-
self.merge_item_identifiers other
|
|
123
|
-
|
|
124
|
-
# 8. Remove A and B from the [occurrences] property of the topic item in their [parent] properties, and add C.
|
|
125
|
-
#self.parent.occurrences.remove other
|
|
126
|
-
|
|
127
|
-
# let the wrapper point to the new object
|
|
128
|
-
#other.__setobj__(self.__getobj__) if self.respond_to?(:__getobj__) && other.respond_to?(:__setobj__)
|
|
129
|
-
self.merge_rewrap other
|
|
130
|
-
|
|
131
|
-
self
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
module Topic
|
|
136
|
-
include Merging::ReWrap
|
|
137
|
-
include Merging::MergeItemIdentifiers
|
|
138
|
-
|
|
139
|
-
def merge(other)
|
|
140
|
-
return unless other
|
|
141
|
-
# The procedure for merging two topic items A and B
|
|
142
|
-
# -> we will instead just modify a
|
|
143
|
-
# (whose [parent] properties shall contain the same topic map item) is given below.
|
|
144
|
-
raise TopicMergeException, "Both topics must belong to the same topic map!" if self.parent.__getobj__ != other.parent.__getobj__
|
|
145
|
-
# It is an error if A and B both have non-null values in their [reified] properties which are different.
|
|
146
|
-
raise TopicMergeException, "The Topics must not reify different things." if self.reified && other.reified && self.reified.__getobj__ != other.reified.__getobj__
|
|
147
|
-
|
|
148
|
-
# 1. Create a new topic item C.
|
|
149
|
-
# 2. Replace A by C wherever it appears in one of the following properties
|
|
150
|
-
# of an information item: [topics], [scope], [type], [player], and [reifier].
|
|
151
|
-
# -> nothing to do here
|
|
152
|
-
|
|
153
|
-
# 3. Repeat for B.
|
|
154
|
-
# [topics]
|
|
155
|
-
# done below, in rewrap
|
|
156
|
-
# [scope]
|
|
157
|
-
RTM::AR::TMDM::ScopedObjectsTopic.move_all(["topic_id", other.__getobj__.id, self.__getobj__.id])
|
|
158
|
-
# [type]
|
|
159
|
-
RTM::AR::TMDM::Association.move_all(["ttype_id", other.__getobj__.id, self.__getobj__.id])
|
|
160
|
-
RTM::AR::TMDM::AssociationRole.move_all(["ttype_id", other.__getobj__.id, self.__getobj__.id])
|
|
161
|
-
RTM::AR::TMDM::TopicName.move_all(["ttype_id", other.__getobj__.id, self.__getobj__.id])
|
|
162
|
-
RTM::AR::TMDM::Occurrence.move_all(["ttype_id", other.__getobj__.id, self.__getobj__.id])
|
|
163
|
-
|
|
164
|
-
# [player]
|
|
165
|
-
RTM::AR::TMDM::AssociationRole.move_all(["topic_id", other.__getobj__.id, self.__getobj__.id])
|
|
166
|
-
|
|
167
|
-
# [reifier]
|
|
168
|
-
if other.reified
|
|
169
|
-
self.reified = other.reified
|
|
170
|
-
end
|
|
171
|
-
# 4. Set C's [topic names] property to the union of the values of A and B's [topic names] properties.
|
|
172
|
-
#self.names.add_all other.names
|
|
173
|
-
count = RTM::AR::TMDM::TopicName.move_all(["topic_id", other.__getobj__.id, self.__getobj__.id])
|
|
174
|
-
if count != 0 && count != names.size
|
|
175
|
-
names.each_with_index do |n,i|
|
|
176
|
-
(i+1).upto(names.size-1) do |j|
|
|
177
|
-
if n == names[j]
|
|
178
|
-
n.merge names[j]
|
|
179
|
-
end
|
|
180
|
-
end
|
|
181
|
-
end
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
# 5. Set C's [occurrences] property to the union of the values of A and B's [occurrences] properties.
|
|
185
|
-
#self.occurrences.add_all other.occurrences
|
|
186
|
-
RTM::AR::TMDM::Occurrence.move_all(["topic_id", other.__getobj__.id, self.__getobj__.id])
|
|
187
|
-
if count != 0 && count != occurrences.size
|
|
188
|
-
occurrences.each_with_index do |o,i|
|
|
189
|
-
(i+1).upto(occurrences.size-1) do |j|
|
|
190
|
-
if o == occurrences[j]
|
|
191
|
-
o.merge occurrences[j]
|
|
192
|
-
end
|
|
193
|
-
end
|
|
194
|
-
end
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
# 6. Set C's [subject identifiers] property to the union of the values of A and B's [subject identifiers] properties.
|
|
198
|
-
#self.subject_identifiers.add_all other.subject_identifiers
|
|
199
|
-
RTM::AR::TMDM::SubjectIdentifier.move_all(["topic_id", other.__getobj__.id, self.__getobj__.id])
|
|
200
|
-
|
|
201
|
-
# 7. Set C's [subject locators] property to the union of the values of A and B's [subject locators] properties.
|
|
202
|
-
#self.subject_locators.add_all other.subject_locators
|
|
203
|
-
RTM::AR::TMDM::SubjectLocator.move_all(["topic_id", other.__getobj__.id, self.__getobj__.id])
|
|
204
|
-
|
|
205
|
-
# 8. Set C's [item identifiers] property to the union of the values of A and B's [item identifiers] properties.
|
|
206
|
-
#self.item_identifiers.add_all other.item_identifiers
|
|
207
|
-
#RTM::AR::TMDM::ItemIdentifier.update_all "topic_map_construct_id = #{self.__getobj__.id}, topic_map_construct_type = '#{self.__getobj__.class.name}'", "topic_map_construct_id = #{other.__getobj__.id} and topic_map_construct_type = '#{other.__getobj__.class.name}'"
|
|
208
|
-
RTM::AR::TMDM::ItemIdentifier.move_all(
|
|
209
|
-
["topic_map_construct_id", other.__getobj__.id, self.__getobj__.id],
|
|
210
|
-
["topic_map_construct_type", other.__getobj__.class.name, self.__getobj__.class.name]
|
|
211
|
-
)
|
|
212
|
-
|
|
213
|
-
self.merge_rewrap other
|
|
214
|
-
|
|
215
|
-
self
|
|
216
|
-
end
|
|
217
|
-
alias :merge_in :merge
|
|
218
|
-
end
|
|
219
|
-
|
|
220
|
-
module TopicMap
|
|
221
|
-
include Merging::MergeReifiable
|
|
222
|
-
|
|
223
|
-
def merge(other) # other:TopicMap
|
|
224
|
-
self.topics.add_all other.topics
|
|
225
|
-
self.associations.add_all other.associations
|
|
226
|
-
self.merge_reifiable other
|
|
227
|
-
self.merge_item_identifiers other
|
|
228
|
-
|
|
229
|
-
self.merge_rewrap other
|
|
230
|
-
self
|
|
231
|
-
end
|
|
232
|
-
alias :merge_in :merge
|
|
233
|
-
end
|
|
234
|
-
|
|
235
|
-
module TopicName
|
|
236
|
-
def merge(other)
|
|
237
|
-
# The procedure for merging two topic name items A and B is given below.
|
|
238
|
-
# -> we will instead just modify a
|
|
239
|
-
|
|
240
|
-
# 1. Create a new topic name item C.
|
|
241
|
-
# 2. Set C's [value] property to the value of the [value] property of A. B's value is equal that of A and need not be taken into account.
|
|
242
|
-
# 3. Set C's [type] property to the value of the [type] property of A. B's value is equal that of A and need not be taken into account.
|
|
243
|
-
# 4. Set C's [scope] property to the value of the [scope] property of A. B's value is equal that of A and need not be taken into account.
|
|
244
|
-
# -> nothing to do till here
|
|
245
|
-
|
|
246
|
-
# 5. Set C's [variants] property to the union of the [variants] properties of A and B.
|
|
247
|
-
#self.variants.add_all other.variants
|
|
248
|
-
count = RTM::AR::TMDM::Variant.move_all(["topic_name_id", other.__getobj__.id, self.__getobj__.id])
|
|
249
|
-
if count != 0 && count != variants.size
|
|
250
|
-
variants.each_with_index do |v,i|
|
|
251
|
-
(i+1).upto(variants.size-1) do |j|
|
|
252
|
-
if v == variants[j]
|
|
253
|
-
v.merge variants[j]
|
|
254
|
-
end
|
|
255
|
-
end
|
|
256
|
-
end
|
|
257
|
-
end
|
|
258
|
-
|
|
259
|
-
# 6. Set C's [reifier] property to the value of A's [reifier] property if it is not null, and to the value of B's [reifier] property if A's property is null. If both A and B have non-null values, the topic items shall be merged, and the topic item resulting from the merge be set as the value of C's [reifier] property.
|
|
260
|
-
self.merge_reifiable other
|
|
261
|
-
|
|
262
|
-
# 7. Set C's [item identifiers] property to the union of the value of the [item identifiers] properties of A and B.
|
|
263
|
-
self.merge_item_identifiers other
|
|
264
|
-
|
|
265
|
-
# 8. Remove A and B from the [topic names] property of the topic item in their [parent] properties, and add C.
|
|
266
|
-
#self.parent.names.remove other
|
|
267
|
-
|
|
268
|
-
# let the wrapper point to the new object
|
|
269
|
-
#other.__setobj__(self.__getobj__) if self.respond_to?(:__getobj__) && other.respond_to?(:__setobj__)
|
|
270
|
-
self.merge_rewrap other
|
|
271
|
-
|
|
272
|
-
self
|
|
273
|
-
end
|
|
274
|
-
end
|
|
275
|
-
|
|
276
|
-
module Variant
|
|
277
|
-
include Merging::MergeReifiable
|
|
278
|
-
|
|
279
|
-
def merge(other)
|
|
280
|
-
#The procedure for merging two variant items A and B is given below.
|
|
281
|
-
# -> we will instead just modify a
|
|
282
|
-
|
|
283
|
-
# 1. Create a new variant item, C.
|
|
284
|
-
# 2. Set C's [value] property to the value of A's [value] property. B's value is equal to that of A and need not be taken into account.
|
|
285
|
-
# 3. Set C's [datatype] property to the value of A's [datatype] property. B's value is equal to that of A and need not be taken into account.
|
|
286
|
-
# 4. Set C's [scope] property to the value of A's [scope] property. B's value is equal to that of A and need not be taken into account.
|
|
287
|
-
# -> nothing to do till here
|
|
288
|
-
|
|
289
|
-
# 5. Set C's [reifier] property to the value of A's [reifier] property if it is not null, and to the value of B's [reifier] property if A's property is null. If both A and B have non-null values, the topic items shall be merged, and the topic item resulting from the merge set as the value of C's [reifier] property.
|
|
290
|
-
self.merge_reifiable other
|
|
291
|
-
|
|
292
|
-
# 6. Set C's [item identifiers] property to the union of the values of A's and B's [item identifiers] properties.
|
|
293
|
-
self.merge_item_identifiers other
|
|
294
|
-
|
|
295
|
-
# 7. Remove A and B from the [variants] property of the topic name item in their [parent] properties, and add C.
|
|
296
|
-
#self.parent.variants.remove other
|
|
297
|
-
|
|
298
|
-
# let the wrapper point to the new object
|
|
299
|
-
#other.__setobj__(self.__getobj__) if self.respond_to?(:__getobj__) && other.respond_to?(:__setobj__)
|
|
300
|
-
self.merge_rewrap other
|
|
301
|
-
|
|
302
|
-
self
|
|
303
|
-
end
|
|
304
|
-
end
|
|
305
|
-
RTM.register_extension( self )
|
|
306
|
-
end
|
|
307
|
-
end
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
module RTM::Sugar
|
|
2
|
-
module Topic
|
|
3
|
-
module PredefinedAssociations
|
|
4
|
-
extend RTM::AR::TraverseAssociations
|
|
5
|
-
# maybe these pairs could be declared each with a single statement and a reversible option
|
|
6
|
-
define_association :types, :type => :Topic, :rule => {
|
|
7
|
-
:transitive => false,
|
|
8
|
-
:role_type => RTM::PSI[:instance],
|
|
9
|
-
:association_type => RTM::PSI[:type_instance],
|
|
10
|
-
:association_arity => 2,
|
|
11
|
-
:other_role_type => RTM::PSI[:type],
|
|
12
|
-
:infer_other => :supertypes,
|
|
13
|
-
:add => :type,
|
|
14
|
-
}
|
|
15
|
-
define_association :instances, :type => :Topic, :rule => {
|
|
16
|
-
:transitive => false,
|
|
17
|
-
:role_type => RTM::PSI[:type],
|
|
18
|
-
:association_type => RTM::PSI[:type_instance],
|
|
19
|
-
:association_arity => 2,
|
|
20
|
-
:other_role_type => RTM::PSI[:instance],
|
|
21
|
-
:infer => :subtypes,
|
|
22
|
-
:add => :instance,
|
|
23
|
-
}
|
|
24
|
-
define_association :supertypes, :type => :Topic, :rule => {
|
|
25
|
-
:transitive => true,
|
|
26
|
-
:role_type => RTM::PSI[:subtype],
|
|
27
|
-
:association_type => RTM::PSI[:supertype_subtype],
|
|
28
|
-
:association_arity => 2,
|
|
29
|
-
:other_role_type => RTM::PSI[:supertype],
|
|
30
|
-
:add => :supertype,
|
|
31
|
-
}
|
|
32
|
-
define_association :subtypes, :type => :Topic, :rule => {
|
|
33
|
-
:transitive => true,
|
|
34
|
-
:role_type => RTM::PSI[:supertype],
|
|
35
|
-
:association_type => RTM::PSI[:supertype_subtype],
|
|
36
|
-
:association_arity => 2,
|
|
37
|
-
:other_role_type => RTM::PSI[:subtype],
|
|
38
|
-
:add => :subtype,
|
|
39
|
-
}
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
data/lib/run_main_project.rb
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
require 'rtm'
|
|
2
|
-
RTM.connect
|
|
3
|
-
puts "connected"
|
|
4
|
-
tm = RTM.create "a:b"
|
|
5
|
-
bla = tm.get!("bla")
|
|
6
|
-
bla["-name"] = "test"
|
|
7
|
-
n = bla["-name"].first
|
|
8
|
-
puts n.inspect
|
|
9
|
-
|
|
10
|
-
bla["-"] = "defaultname yeah!"
|
|
11
|
-
|
|
12
|
-
puts tm.t.size
|
|
13
|
-
dm = tm.get!("delete_me")
|
|
14
|
-
puts tm.t.size
|
|
15
|
-
dm.remove
|
|
16
|
-
puts tm.t.size
|