rtm 0.1.6 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,154 @@
|
|
1
|
+
# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
|
2
|
+
# License: Apache License, Version 2.0
|
3
|
+
|
4
|
+
module RTM::IO
|
5
|
+
# Hash Export.
|
6
|
+
# Each Topic Maps Construct gets a to_hash method.
|
7
|
+
module ToHash
|
8
|
+
|
9
|
+
module TopicMap
|
10
|
+
# Returns the Hash representation of this topic map.
|
11
|
+
#
|
12
|
+
# The returned Hash holds information about the :reifier,
|
13
|
+
# the :item_identifiers, the :topics and :associations.
|
14
|
+
#
|
15
|
+
# :call-seq:
|
16
|
+
# to_hash -> Hash
|
17
|
+
#
|
18
|
+
def to_hash
|
19
|
+
h={}
|
20
|
+
h[:reifier] = reifier.reference if reifier
|
21
|
+
h[:item_identifiers] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
|
22
|
+
h[:topics] = topics.map{|i| i.to_hash} unless topics.empty?
|
23
|
+
h[:associations] = associations.map{|i| i.to_hash} unless associations.empty?
|
24
|
+
h
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
module Topic
|
29
|
+
# Returns the Hash representation of this topic.
|
30
|
+
#
|
31
|
+
# The returned Hash holds information about the :subject_identifiers,
|
32
|
+
# the :item_identifiers, the :subject_locators, the :names and the
|
33
|
+
# :occurrences.
|
34
|
+
#
|
35
|
+
# :call-seq:
|
36
|
+
# to_hash -> Hash
|
37
|
+
#
|
38
|
+
def to_hash
|
39
|
+
h = {}
|
40
|
+
h[:item_identifiers] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
|
41
|
+
h[:subject_identifiers] = subject_identifiers.map{|i| i.reference} unless subject_identifiers.empty?
|
42
|
+
h[:subject_locators] = subject_locators.map{|i| i.reference} unless subject_locators.empty?
|
43
|
+
h[:names] = names.map{|i| i.to_hash} unless names.empty?
|
44
|
+
h[:occurrences] = occurrences.map{|i| i.to_hash} unless occurrences.empty?
|
45
|
+
h
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
module Name
|
50
|
+
# Returns the Hash representation of this name.
|
51
|
+
#
|
52
|
+
# The returned Hash holds information about the :reifier,
|
53
|
+
# the :item_identifiers, the :value, the :type, the :scope and the
|
54
|
+
# :variants.
|
55
|
+
#
|
56
|
+
# :call-seq:
|
57
|
+
# to_hash -> Hash
|
58
|
+
#
|
59
|
+
def to_hash
|
60
|
+
h={}
|
61
|
+
h[:reifier] = reifier.reference if reifier
|
62
|
+
h[:item_identifiers] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
|
63
|
+
h[:value] = value if value
|
64
|
+
h[:type] = type.reference if type
|
65
|
+
h[:scope] = scope.map{|i| i.reference} unless scope.empty?
|
66
|
+
h[:variants] = variants.map{|i| i.to_hash} unless variants.empty?
|
67
|
+
h
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
module Association
|
72
|
+
# Returns the Hash representation of this association.
|
73
|
+
#
|
74
|
+
# The returned Hash holds information about the :reifier,
|
75
|
+
# the :item_identifiers, the :type, the :scope and the :roles.
|
76
|
+
#
|
77
|
+
# :call-seq:
|
78
|
+
# to_hash -> Hash
|
79
|
+
#
|
80
|
+
def to_hash
|
81
|
+
h={}
|
82
|
+
h[:reifier] = reifier.reference if reifier
|
83
|
+
h[:item_identifiers] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
|
84
|
+
h[:type] = type.reference if type
|
85
|
+
h[:scope] = scope.map{|i| i.reference} unless scope.empty?
|
86
|
+
h[:roles] = roles.map{|i| i.to_hash} unless roles.empty?
|
87
|
+
h
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
module Occurrence
|
92
|
+
# Returns the Hash representation of this occurrence.
|
93
|
+
#
|
94
|
+
# The returned Hash holds information about the :reifier,
|
95
|
+
# the :item_identifiers, the :value, the :datatype, the :type
|
96
|
+
# and the :scope.
|
97
|
+
#
|
98
|
+
# :call-seq:
|
99
|
+
# to_hash -> Hash
|
100
|
+
#
|
101
|
+
def to_hash
|
102
|
+
h={}
|
103
|
+
h[:reifier] = reifier.reference if reifier
|
104
|
+
h[:item_identifiers] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
|
105
|
+
h[:value] = value if value
|
106
|
+
h[:datatype] = datatype.reference if datatype
|
107
|
+
h[:type] = type.reference if type
|
108
|
+
h[:scope] = scope.map{|i| i.reference} unless scope.empty?
|
109
|
+
h
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
module Role
|
114
|
+
# Returns the Hash representation of this role.
|
115
|
+
#
|
116
|
+
# The returned Hash holds information about the :reifier,
|
117
|
+
# the :item_identifiers, the :player, and the :type.
|
118
|
+
#
|
119
|
+
# :call-seq:
|
120
|
+
# to_hash -> Hash
|
121
|
+
#
|
122
|
+
def to_hash
|
123
|
+
h={}
|
124
|
+
h[:reifier] = reifier.reference if reifier
|
125
|
+
h[:item_identifiers] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
|
126
|
+
h[:player] = player.reference if player
|
127
|
+
h[:type] = type.reference if type
|
128
|
+
h
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
module Variant
|
133
|
+
# Returns the Hash representation of this variant.
|
134
|
+
#
|
135
|
+
# The returned Hash holds information about the :reifier,
|
136
|
+
# the :item_identifiers, the :value and the :scope.
|
137
|
+
#
|
138
|
+
# :call-seq:
|
139
|
+
# to_hash -> Hash
|
140
|
+
#
|
141
|
+
def to_hash
|
142
|
+
h={}
|
143
|
+
h[:reifier] = reifier.reference if reifier
|
144
|
+
h[:item_identifiers] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
|
145
|
+
h[:value] = value if value
|
146
|
+
h[:scope] = scope.map{|i| i.reference} unless scope.empty?
|
147
|
+
h
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
RTM.register_extension self
|
152
|
+
|
153
|
+
end
|
154
|
+
end
|
data/lib/rtm/io/to_jtm.rb
CHANGED
@@ -1,144 +1,94 @@
|
|
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
|
# JTM Export.
|
4
6
|
# Each Topic Maps Construct gets a to_jtm method.
|
5
|
-
|
7
|
+
module TOJTM
|
6
8
|
begin
|
7
9
|
require 'json/ext'
|
8
10
|
rescue LoadError
|
9
11
|
require 'json/pure'
|
10
|
-
end
|
12
|
+
end unless Object.const_defined?(:JSON)
|
11
13
|
|
12
14
|
module TopicMap
|
13
|
-
#
|
14
|
-
def
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
j['topics'] = topics.map{|i| i.to_jtm_hash} unless topics.empty?
|
20
|
-
j['associations'] = associations.map{|i| i.to_jtm_hash} unless associations.empty?
|
21
|
-
j
|
15
|
+
# Returns the JTM representation of this RTM::TopicMap
|
16
|
+
def to_jtm_str # only for export with no file and base_iri otherwise TMAPIX
|
17
|
+
h = to_hash
|
18
|
+
h[:version] = "1.0"
|
19
|
+
h[:item_type] = "topicmap"
|
20
|
+
h.to_json
|
22
21
|
end
|
23
|
-
|
24
|
-
to_jtm_hash.to_json(*a)
|
25
|
-
end
|
26
|
-
alias :to_json :to_jtm
|
22
|
+
# alias :to_json :to_jtm_str
|
27
23
|
end
|
28
24
|
|
29
25
|
module Topic
|
30
|
-
#
|
31
|
-
def
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
j['item_identifiers'] = [to_jtm_ref]
|
37
|
-
end
|
38
|
-
j['subject_locators'] = subject_locators.map{|i| i.reference} unless subject_locators.empty?
|
39
|
-
j['names'] = names.map{|i| i.to_jtm_hash} unless names.empty?
|
40
|
-
j['occurrences'] = occurrences.map{|i| i.to_jtm_hash} unless occurrences.empty?
|
41
|
-
j
|
42
|
-
end
|
43
|
-
def to_jtm(*a)
|
44
|
-
to_jtm_hash.to_json(*a)
|
26
|
+
# Returns the JTM representation of this RTM::Topic
|
27
|
+
def to_jtm
|
28
|
+
h = to_hash
|
29
|
+
h[:version] = "1.0"
|
30
|
+
h[:item_type] = "topic"
|
31
|
+
h.to_json
|
45
32
|
end
|
46
33
|
alias :to_json :to_jtm
|
47
|
-
|
48
|
-
def to_jtm_ref
|
49
|
-
if subject_identifiers.first
|
50
|
-
return subject_identifiers.first.reference
|
51
|
-
end
|
52
|
-
if item_identifiers.first
|
53
|
-
return item_identifiers.first.reference
|
54
|
-
end
|
55
|
-
"t#{id}"
|
56
|
-
end
|
57
34
|
end
|
58
35
|
|
59
36
|
module Association
|
60
|
-
#
|
61
|
-
def
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
j['scope'] = scope.map{|i| i.to_jtm_hash} unless scope.empty?
|
67
|
-
j['roles'] = roles.map{|i| i.to_jtm_hash} unless roles.empty?
|
68
|
-
j
|
69
|
-
end
|
70
|
-
def to_jtm(*a)
|
71
|
-
to_jtm_hash.to_json(*a)
|
37
|
+
# Returns the JTM representation of this RTM::Association
|
38
|
+
def to_jtm
|
39
|
+
h = to_hash
|
40
|
+
h[:version] = "1.0"
|
41
|
+
h[:item_type] = "association"
|
42
|
+
h.to_json
|
72
43
|
end
|
73
44
|
alias :to_json :to_jtm
|
74
|
-
|
75
45
|
end
|
76
46
|
|
77
|
-
module
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
j['scope'] = scope.map{|i| i.to_jtm_hash} unless scope.empty?
|
85
|
-
j['variants'] = variants.map{|i| i.to_jtm_hash} unless variants.empty?
|
86
|
-
j
|
87
|
-
end
|
88
|
-
def to_jtm(*a)
|
89
|
-
to_jtm_hash.to_json(*a)
|
47
|
+
module Name
|
48
|
+
# Returns the JTM representation of this RTM::Name
|
49
|
+
def to_jtm
|
50
|
+
h = to_hash
|
51
|
+
h[:version] = "1.0"
|
52
|
+
h[:item_type] = "name"
|
53
|
+
h.to_json
|
90
54
|
end
|
91
55
|
alias :to_json :to_jtm
|
92
56
|
end
|
93
57
|
|
94
58
|
module Occurrence
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
j['type'] = type.to_jtm_ref if type
|
102
|
-
j['scope'] = scope.map{|i| i.to_jtm_hash} unless scope.empty?
|
103
|
-
j
|
104
|
-
end
|
105
|
-
def to_jtm(*a)
|
106
|
-
to_jtm_hash.to_json(*a)
|
59
|
+
# Returns the JTM representation of this RTM::Occurrence
|
60
|
+
def to_jtm
|
61
|
+
h = to_hash
|
62
|
+
h[:version] = "1.0"
|
63
|
+
h[:item_type] = "occurrence"
|
64
|
+
h.to_json
|
107
65
|
end
|
108
66
|
alias :to_json :to_jtm
|
109
67
|
end
|
110
68
|
|
111
|
-
module
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
j
|
119
|
-
end
|
120
|
-
def to_jtm(*a)
|
121
|
-
to_jtm_hash.to_json(*a)
|
69
|
+
module Role
|
70
|
+
# Returns the JTM representation of this RTM::Role
|
71
|
+
def to_jtm
|
72
|
+
h = to_hash
|
73
|
+
h[:version] = "1.0"
|
74
|
+
h[:item_type] = "role"
|
75
|
+
h.to_json
|
122
76
|
end
|
123
77
|
alias :to_json :to_jtm
|
124
78
|
end
|
125
79
|
|
126
80
|
module Variant
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
j
|
134
|
-
end
|
135
|
-
def to_jtm(*a)
|
136
|
-
to_jtm_hash.to_json(*a)
|
81
|
+
# Returns the JTM representation of this RTM::Variant
|
82
|
+
def to_jtm
|
83
|
+
h = to_hash
|
84
|
+
h[:version] = "1.0"
|
85
|
+
h[:item_type] = "variant"
|
86
|
+
h.to_json
|
137
87
|
end
|
138
88
|
alias :to_json :to_jtm
|
139
89
|
end
|
140
|
-
|
141
|
-
RTM.register_extension
|
90
|
+
|
91
|
+
RTM.register_extension self
|
92
|
+
|
142
93
|
end
|
143
94
|
end
|
144
|
-
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
|
2
|
+
# License: Apache License, Version 2.0
|
3
|
+
|
4
|
+
module RTM::IO
|
5
|
+
|
6
|
+
# RDF Export.
|
7
|
+
# RTM::TopicMap gets a to_rdf method.
|
8
|
+
module ToRDF
|
9
|
+
module TopicMap
|
10
|
+
|
11
|
+
# If this topic map is an Ontopia tmapi2 topic map to_rdf_ontopia is
|
12
|
+
# called and the RDF reprensentation is returned.
|
13
|
+
#
|
14
|
+
# Else, a "Not supported" error is raised.
|
15
|
+
#
|
16
|
+
# :call-seq:
|
17
|
+
# to_rdf -> String
|
18
|
+
#
|
19
|
+
def to_rdf
|
20
|
+
case self
|
21
|
+
when net.ontopia.topicmaps.impl.tmapi2.TopicMapImpl then to_rdf_ontopia
|
22
|
+
else raise "Not supported for #{self}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns the RDF representation according to RDF2TM
|
27
|
+
# of this topic map as String.
|
28
|
+
#
|
29
|
+
# @see http://www.ontopia.net/topicmaps/materials/rdf2tm.html
|
30
|
+
#
|
31
|
+
# :call-seq:
|
32
|
+
# to_rdf_ontopia -> String
|
33
|
+
#
|
34
|
+
def to_rdf_ontopia
|
35
|
+
@out = java.io.StringWriter.new
|
36
|
+
w=Java::NetOntopiaTopicmapsUtilsRdf::RDFTopicMapWriter.new @out
|
37
|
+
w.write self.getWrapped
|
38
|
+
@out.to_s
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
RTM.register_extension self
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
data/lib/rtm/io/to_string.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
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
|
-
module
|
6
|
+
module ToString
|
5
7
|
|
6
8
|
module TopicMap
|
7
9
|
# Returns different String representations. Try :short (default), :long, :super (original)
|
@@ -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
|
@@ -121,7 +123,18 @@ module RTM::IO
|
|
121
123
|
end
|
122
124
|
end
|
123
125
|
end
|
124
|
-
|
126
|
+
|
127
|
+
module Locator
|
128
|
+
def to_s(style=:short)
|
129
|
+
case style
|
130
|
+
when :short
|
131
|
+
value
|
132
|
+
when :long
|
133
|
+
value
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
125
138
|
RTM.register_extension( self )
|
126
139
|
end
|
127
140
|
end
|