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
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
|
|
2
|
+
# License: Apache License, Version 2.0
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
module RTM::IO
|
|
6
|
+
|
|
7
|
+
# RDF Export.
|
|
8
|
+
# RTM::TopicMap gets a to_rdf method.
|
|
9
|
+
module TORDF
|
|
10
|
+
module TopicMap
|
|
11
|
+
|
|
12
|
+
def to_rdf
|
|
13
|
+
case self
|
|
14
|
+
when net.ontopia.topicmaps.impl.tmapi2.TopicMapImpl then to_rdf_ontopia
|
|
15
|
+
else raise "Not supported for #{self}"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def to_rdf_ontopia
|
|
20
|
+
@out = java.io.StringWriter.new
|
|
21
|
+
w=Java::NetOntopiaTopicmapsUtilsRdf::RDFTopicMapWriter.new @out
|
|
22
|
+
w.write self.getWrapped
|
|
23
|
+
@out.to_s
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
RTM.register_extension self
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
end
|
data/lib/rtm/io/to_string.rb
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
#
|
|
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
|
# Each Topic Maps Construct gets a custom to_s method which supports optional :short or :long output.
|
|
4
6
|
module TOSTRING
|
|
@@ -53,20 +55,20 @@ module RTM::IO
|
|
|
53
55
|
when :long
|
|
54
56
|
r = " #{reifier.to_s(:short)}" if reifier
|
|
55
57
|
i = " iids=#{item_identifiers.to_s}" unless item_identifiers.empty?
|
|
56
|
-
"#<RTM::Association id=#{id}#{i}#{r} type=#{type.to_s(:short)} roles=[#{roles.entries.map { |ar| ar.to_s }.join(", ")}]>"
|
|
58
|
+
"#<RTM::Association id=#{id}#{i}#{r} type=#{type.to_s(:short)} roles=[#{roles.entries.map { |ar| ar.to_s(:long) }.join(", ")}]>"
|
|
57
59
|
else
|
|
58
60
|
super() # these () are needed, otherwise the own parameters are passed in
|
|
59
61
|
end
|
|
60
62
|
end
|
|
61
63
|
end
|
|
62
64
|
|
|
63
|
-
module
|
|
65
|
+
module Role
|
|
64
66
|
def to_s(style=:short)
|
|
65
67
|
case style
|
|
66
68
|
when :short
|
|
67
69
|
r = " #{reifier.to_s(:short)}" if reifier
|
|
68
70
|
i = " iids=#{item_identifiers.to_s}" unless item_identifiers.empty?
|
|
69
|
-
"#<RTM::
|
|
71
|
+
"#<RTM::Role id=#{id}#{i}#{r}>"
|
|
70
72
|
when :long
|
|
71
73
|
r = " #{reifier.to_s(:short)}" if reifier
|
|
72
74
|
i = " iids=#{item_identifiers.to_s}" unless item_identifiers.empty?
|
|
@@ -77,7 +79,7 @@ module RTM::IO
|
|
|
77
79
|
end
|
|
78
80
|
end
|
|
79
81
|
|
|
80
|
-
module
|
|
82
|
+
module Name
|
|
81
83
|
def to_s(style=:short)
|
|
82
84
|
case style
|
|
83
85
|
when :short
|
|
@@ -85,7 +87,7 @@ module RTM::IO
|
|
|
85
87
|
when :long
|
|
86
88
|
r = " #{reifier.to_s(:short)}" if reifier
|
|
87
89
|
i = " iids=#{item_identifiers.to_s}" unless item_identifiers.empty?
|
|
88
|
-
"#<RTM::
|
|
90
|
+
"#<RTM::Name id=#{id}#{i}#{r} type=#{type.to_s(:short)} value=#{value} variants:#{variants.size}>"
|
|
89
91
|
else
|
|
90
92
|
super() # these () are needed, otherwise the own parameters are passed in
|
|
91
93
|
end
|
data/lib/rtm/io/to_xtm1.rb
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
#
|
|
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
|
|
103
|
+
module Name
|
|
102
104
|
def to_xtm1
|
|
103
|
-
warn("TOXTM1: Warning: outputting invalid
|
|
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
|
|
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 }
|
data/lib/rtm/io/to_xtm2.rb
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
#
|
|
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.
|
|
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
|
|
105
|
+
module Name
|
|
104
106
|
def to_xtm2
|
|
105
|
-
warn("TOXTM2: Warning: outputting invalid
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
data/lib/rtm/io/to_yaml.rb
CHANGED
|
@@ -1,130 +1,61 @@
|
|
|
1
|
-
#
|
|
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
|
# YAML Export.
|
|
4
|
-
# Each Topic Maps Construct gets a
|
|
6
|
+
# Each Topic Maps Construct gets a to_yaml method.
|
|
5
7
|
module TOYAML
|
|
6
8
|
|
|
7
9
|
module TopicMap
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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 RTM::TopicMap
|
|
11
|
+
def to_yaml
|
|
12
|
+
to_hash.to_yaml
|
|
20
13
|
end
|
|
21
14
|
end
|
|
22
15
|
|
|
23
16
|
module Topic
|
|
24
|
-
#
|
|
25
|
-
def
|
|
26
|
-
|
|
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}"
|
|
17
|
+
# Returns the YAML representation of this RTM::Topic
|
|
18
|
+
def to_yaml
|
|
19
|
+
to_hash.to_yaml
|
|
48
20
|
end
|
|
49
21
|
end
|
|
50
22
|
|
|
51
23
|
module Association
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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)
|
|
24
|
+
# Returns the YAML representation of this RTM::Association
|
|
25
|
+
def to_yaml
|
|
26
|
+
to_hash.to_yaml
|
|
64
27
|
end
|
|
65
28
|
end
|
|
66
29
|
|
|
67
|
-
module
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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)
|
|
30
|
+
module Name
|
|
31
|
+
# Returns the YAML representation of this RTM::Name
|
|
32
|
+
def to_yaml
|
|
33
|
+
to_hash.to_yaml
|
|
80
34
|
end
|
|
81
35
|
end
|
|
82
36
|
|
|
83
37
|
module Occurrence
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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)
|
|
38
|
+
# Returns the YAML representation of this RTM::Occurrence
|
|
39
|
+
def to_yaml
|
|
40
|
+
to_hash.to_yaml
|
|
96
41
|
end
|
|
97
42
|
end
|
|
98
43
|
|
|
99
|
-
module
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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)
|
|
44
|
+
module Role
|
|
45
|
+
# Returns the YAML representation of this RTM::Role
|
|
46
|
+
def to_yaml
|
|
47
|
+
to_yaml_hash.to_yaml
|
|
110
48
|
end
|
|
111
49
|
end
|
|
112
50
|
|
|
113
51
|
module Variant
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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)
|
|
52
|
+
# Returns the YAML representation of this RTM::Variant
|
|
53
|
+
def to_yaml
|
|
54
|
+
to_yaml_hash.to_yaml
|
|
124
55
|
end
|
|
125
56
|
end
|
|
126
|
-
|
|
57
|
+
|
|
127
58
|
RTM.register_extension( self )
|
|
59
|
+
|
|
128
60
|
end
|
|
129
61
|
end
|
|
130
|
-
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
module RTM::Topic
|
|
24
|
+
include RTM::Navigation::Topic
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
module RTM::Name
|
|
28
|
+
include RTM::Navigation::Name
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
module RTM::Occurrence
|
|
32
|
+
include RTM::Navigation::Occurrence
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
module RTM::Association
|
|
36
|
+
include RTM::Navigation::Association
|
|
37
|
+
end
|
|
@@ -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 or 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 or 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
|