rtm-javatmapi 0.3.1-java
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 +15 -0
- data/LICENSE +201 -0
- data/README +4 -0
- data/lib/rtm-javatmapi.rb +4 -0
- data/lib/rtm/javatmapi.rb +229 -0
- data/lib/rtm/javatmapi/aliases.rb +43 -0
- data/lib/rtm/javatmapi/core.rb +16 -0
- data/lib/rtm/javatmapi/core/association.rb +71 -0
- data/lib/rtm/javatmapi/core/construct.rb +92 -0
- data/lib/rtm/javatmapi/core/datatype_aware.rb +60 -0
- data/lib/rtm/javatmapi/core/locator.rb +20 -0
- data/lib/rtm/javatmapi/core/name.rb +127 -0
- data/lib/rtm/javatmapi/core/occurrence.rb +32 -0
- data/lib/rtm/javatmapi/core/reifiable.rb +38 -0
- data/lib/rtm/javatmapi/core/role.rb +49 -0
- data/lib/rtm/javatmapi/core/scoped.rb +93 -0
- data/lib/rtm/javatmapi/core/topic.rb +504 -0
- data/lib/rtm/javatmapi/core/topic_map.rb +677 -0
- data/lib/rtm/javatmapi/core/typed.rb +31 -0
- data/lib/rtm/javatmapi/core/variant.rb +19 -0
- data/lib/rtm/javatmapi/ext.rb +4 -0
- data/lib/rtm/javatmapi/ext/java_util_set.rb +10 -0
- data/lib/rtm/javatmapi/javalibs/aduna-commons-collections-2.5.0.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/aduna-commons-concurrent-2.4.0.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/aduna-commons-i18n-1.1.0.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/aduna-commons-io-2.6.0.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/aduna-commons-iteration-2.5.0.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/aduna-commons-lang-2.6.0.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/aduna-commons-net-2.4.0.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/aduna-commons-text-2.4.0.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/aduna-commons-xml-2.4.0.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/commons-collections-3.2.1.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/ctm-writer-1.0.8-SNAPSHOT.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/java-tools-0.0.3-SNAPSHOT.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/jcl-over-slf4j-1.6.1.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/mio-syntaxpack-nodeps-0.1.1.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/sesame-model-2.3-pr1.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/sesame-query-2.3-pr1.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/sesame-queryalgebra-evaluation-2.3-pr1.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/sesame-queryalgebra-model-2.3-pr1.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/sesame-queryparser-api-2.3-pr1.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/sesame-queryparser-sparql-2.3-pr1.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/sesame-queryresultio-api-2.3-pr1.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/sesame-queryresultio-sparqlxml-2.3-pr1.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/sesame-repository-api-2.3-pr1.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/sesame-repository-sail-2.3-pr1.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/sesame-rio-api-2.3-pr1.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/sesame-rio-n3-2.3-pr1.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/sesame-rio-rdfxml-2.2.4.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/sesame-rio-turtle-2.3-pr1.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/sesame-sail-api-2.3-pr1.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/sesame-sail-inferencer-2.3-pr1.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/sesame-sail-memory-2.3-pr1.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/slf4j-api-1.6.1.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/slf4j-nop-1.6.1.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/tmapi-2.0.3-SNAPSHOT.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/tmapix-core-0.2.0-SNAPSHOT.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/tmapix-io-1.0.0.jar +0 -0
- data/lib/rtm/javatmapi/javalibs/trove-2.0.4.jar +0 -0
- data/lib/rtm/javatmapi/superiseable.rb +33 -0
- metadata +137 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
|
|
2
|
+
# License: Apache License, Version 2.0
|
|
3
|
+
|
|
4
|
+
#do not use alias in (J)RTM code
|
|
5
|
+
|
|
6
|
+
module Java::OrgTmapiCore
|
|
7
|
+
module TopicMap
|
|
8
|
+
alias :tii :type_instance_index
|
|
9
|
+
alias :li :literal_index
|
|
10
|
+
alias :si :scoped_index
|
|
11
|
+
|
|
12
|
+
alias :by_ii :get_construct_by_item_identifier
|
|
13
|
+
alias :by_si :get_topic_by_subject_identifier
|
|
14
|
+
alias :by_sl :get_topic_by_subject_locator
|
|
15
|
+
|
|
16
|
+
alias :t :topics
|
|
17
|
+
alias :a :associations
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
module Topic
|
|
21
|
+
alias :o :occurrences
|
|
22
|
+
alias :n :names
|
|
23
|
+
|
|
24
|
+
alias :si :subject_identifiers
|
|
25
|
+
alias :add_si :add_subject_identifier
|
|
26
|
+
alias :remove_si :remove_subject_identifier
|
|
27
|
+
|
|
28
|
+
alias :sl :subject_locators
|
|
29
|
+
alias :add_sl :add_subject_locator
|
|
30
|
+
alias :remove_sl :remove_subject_locator
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
module Construct
|
|
34
|
+
alias :p :parent
|
|
35
|
+
alias :ii :item_identifiers
|
|
36
|
+
alias :add_ii :add_item_identifier
|
|
37
|
+
alias :remove_ii :remove_item_identifier
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
module Association
|
|
41
|
+
alias :r :roles
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
|
|
2
|
+
# License: Apache License, Version 2.0
|
|
3
|
+
|
|
4
|
+
require 'rtm/javatmapi/core/construct'
|
|
5
|
+
require 'rtm/javatmapi/core/reifiable'
|
|
6
|
+
require 'rtm/javatmapi/core/topic_map'
|
|
7
|
+
require 'rtm/javatmapi/core/topic'
|
|
8
|
+
require 'rtm/javatmapi/core/name'
|
|
9
|
+
require 'rtm/javatmapi/core/occurrence'
|
|
10
|
+
require 'rtm/javatmapi/core/association'
|
|
11
|
+
require 'rtm/javatmapi/core/role'
|
|
12
|
+
require 'rtm/javatmapi/core/scoped'
|
|
13
|
+
require 'rtm/javatmapi/core/locator'
|
|
14
|
+
require 'rtm/javatmapi/core/variant'
|
|
15
|
+
require 'rtm/javatmapi/core/typed'
|
|
16
|
+
require 'rtm/javatmapi/core/datatype_aware'
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
|
|
2
|
+
# License: Apache License, Version 2.0
|
|
3
|
+
|
|
4
|
+
module Java::OrgTmapiCore::Association
|
|
5
|
+
|
|
6
|
+
include RTM::Association
|
|
7
|
+
extend Superiseable
|
|
8
|
+
|
|
9
|
+
superised
|
|
10
|
+
# Returns the topic map this association belongs to.
|
|
11
|
+
#
|
|
12
|
+
# :call-seq:
|
|
13
|
+
# parent -> TopicMap
|
|
14
|
+
#
|
|
15
|
+
def parent
|
|
16
|
+
getParent
|
|
17
|
+
end
|
|
18
|
+
alias :topic_map :parent
|
|
19
|
+
alias :reverse_children :parent
|
|
20
|
+
|
|
21
|
+
# Returns all roles parented by this association.
|
|
22
|
+
#
|
|
23
|
+
# :call-seq:
|
|
24
|
+
# children -> Set of Roles
|
|
25
|
+
#
|
|
26
|
+
def children
|
|
27
|
+
getRoles
|
|
28
|
+
end
|
|
29
|
+
alias :reverse_parent :children
|
|
30
|
+
|
|
31
|
+
superised
|
|
32
|
+
# Creates a new role in this association. The optional argument 'type'
|
|
33
|
+
# specifies the role type and
|
|
34
|
+
# 'player' specifies the role player.
|
|
35
|
+
#
|
|
36
|
+
# Type and player may each be topic references.
|
|
37
|
+
#
|
|
38
|
+
# :call-seq:
|
|
39
|
+
# create_role(type, player) -> Role
|
|
40
|
+
#
|
|
41
|
+
def create_role(type, player)
|
|
42
|
+
createRole(topic_map.get!(type),topic_map.get!(player))
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
superised
|
|
46
|
+
# Returns the Roles participating in this Association.
|
|
47
|
+
# The optional identifier specifies the type of
|
|
48
|
+
# the returned Roles.
|
|
49
|
+
#
|
|
50
|
+
# Identifier may be a topic reference.
|
|
51
|
+
#
|
|
52
|
+
# The result may be empty.
|
|
53
|
+
#
|
|
54
|
+
# :call-seq:
|
|
55
|
+
# roles -> Set of Roles
|
|
56
|
+
# roles(identifier) -> Set of Roles
|
|
57
|
+
#
|
|
58
|
+
def roles(type = :any)
|
|
59
|
+
return getRoles if type == :any
|
|
60
|
+
return java.util.HashSet.new if type == nil
|
|
61
|
+
_topic = topic_map.get(type)
|
|
62
|
+
if _topic.is_a?(Java::OrgTmapiCore::Topic)
|
|
63
|
+
return getRoles(_topic)
|
|
64
|
+
else
|
|
65
|
+
return java.util.HashSet.new
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
end
|
|
71
|
+
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
|
|
2
|
+
# License: Apache License, Version 2.0
|
|
3
|
+
|
|
4
|
+
module Java::OrgTmapiCore::Construct
|
|
5
|
+
|
|
6
|
+
include RTM::Construct
|
|
7
|
+
extend Superiseable
|
|
8
|
+
|
|
9
|
+
# Returns the TopicMap instance this Construct belongs to.
|
|
10
|
+
#
|
|
11
|
+
# :call-seq:
|
|
12
|
+
# topic_map -> TopicMap
|
|
13
|
+
#
|
|
14
|
+
def topic_map
|
|
15
|
+
getTopicMap
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Returns the parent construct this construct belongs to.
|
|
19
|
+
#
|
|
20
|
+
# :call-seq:
|
|
21
|
+
# parent -> a construct (TopicMap, Topic, Association or Name)
|
|
22
|
+
#
|
|
23
|
+
def parent
|
|
24
|
+
getParent
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Returns true if the construct fulfills all constraints defined in the TMDM
|
|
28
|
+
def valid?
|
|
29
|
+
# This is defined in RTM::AR and we test it. I guess from the API perspective, in TMAPI the validness of an object is guaranteed.
|
|
30
|
+
true
|
|
31
|
+
end unless self.method_defined?(:valid?)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
# Returns the item identifiers assigned to the current construct.
|
|
35
|
+
#
|
|
36
|
+
# :call-seq:
|
|
37
|
+
# item_identifiers -> Set of Locators
|
|
38
|
+
#
|
|
39
|
+
def item_identifiers
|
|
40
|
+
getItemIdentifiers
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
superised
|
|
44
|
+
# Adds an item identifier to this construct.
|
|
45
|
+
# Identifier may be a String or Locator.
|
|
46
|
+
#
|
|
47
|
+
# :call-seq:
|
|
48
|
+
# item_identifiers=(identifier)
|
|
49
|
+
#
|
|
50
|
+
def add_item_identifier(identifier)
|
|
51
|
+
# TODO Spec
|
|
52
|
+
begin
|
|
53
|
+
if identifier.is_a? Java::OrgTmapiCore::Locator
|
|
54
|
+
addItemIdentifier(identifier)
|
|
55
|
+
else
|
|
56
|
+
addItemIdentifier(topic_map.create_locator(identifier))
|
|
57
|
+
end
|
|
58
|
+
rescue Java::OrgTmapiCore::IdentityConstraintException => ice
|
|
59
|
+
# TODO add condition to switch off automerge
|
|
60
|
+
self.mergeIn(self.topic_map.get(identifier))
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
alias :item_identifiers= :add_item_identifier # FIXME ii= is not add! it's set.
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
superised
|
|
67
|
+
# Removes an item identifer from this construct,
|
|
68
|
+
# if present.
|
|
69
|
+
#
|
|
70
|
+
# Identifier may be a String or Locator.
|
|
71
|
+
#
|
|
72
|
+
# :call-seq:
|
|
73
|
+
# remove_item_identifier(identifier)
|
|
74
|
+
#
|
|
75
|
+
def remove_item_identifier(identifier)
|
|
76
|
+
identifier = topic_map.create_locator(identifier) if identifier.is_a? String
|
|
77
|
+
removeItemIdentifier(identifier) if identifier.is_a? Java::OrgTmapiCore::Locator
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Returns the identifier of this construct.
|
|
81
|
+
# This property has no representation in the Topic Maps - Data Model.
|
|
82
|
+
# The ID can be anything, so long as no other Construct in the
|
|
83
|
+
# same topic map has the same ID.
|
|
84
|
+
#
|
|
85
|
+
# :call_spec:
|
|
86
|
+
# id -> String
|
|
87
|
+
#
|
|
88
|
+
def id
|
|
89
|
+
getId
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
|
|
2
|
+
# License: Apache License, Version 2.0
|
|
3
|
+
|
|
4
|
+
module Java::OrgTmapiCore::DatatypeAware
|
|
5
|
+
|
|
6
|
+
include RTM::DatatypeAware
|
|
7
|
+
extend Superiseable
|
|
8
|
+
|
|
9
|
+
superised
|
|
10
|
+
# Changes the value (and if given, the datatype) of this Occurrence.
|
|
11
|
+
#
|
|
12
|
+
# The datatype must be a String or Locator.
|
|
13
|
+
#
|
|
14
|
+
# If value is a String, this methods sets the string value and
|
|
15
|
+
# the datatype implicitly to xsd:string.
|
|
16
|
+
#
|
|
17
|
+
# If argument is a Locator, this method sets the IRI value and
|
|
18
|
+
# the datatype implicitly to xsd:anyURI.
|
|
19
|
+
#
|
|
20
|
+
# If argument is a Float, this method sets the Float value and
|
|
21
|
+
# the datatype implicitly to xsd:float.
|
|
22
|
+
#
|
|
23
|
+
# If argument is a Fixnum, this method sets Fixnum value and
|
|
24
|
+
# the datatype implicitly to xsd:long.
|
|
25
|
+
#
|
|
26
|
+
# If argument is a Bignum, this method sets Bignum value and
|
|
27
|
+
# the datatype implicitly to xsd:integer.
|
|
28
|
+
#
|
|
29
|
+
# :call-seq:
|
|
30
|
+
# value = value
|
|
31
|
+
# value = value, datatype
|
|
32
|
+
#
|
|
33
|
+
def value=(args)
|
|
34
|
+
if args.is_a?(Array)
|
|
35
|
+
raise("value=(value) or value=(value,datatype)") unless args.size == 2
|
|
36
|
+
datatype = topic_map.create_locator(args.last)
|
|
37
|
+
value = args.first.to_s
|
|
38
|
+
if datatype.reference == RTM::PSI[:IRI]
|
|
39
|
+
setValue(topic_map.create_locator(value))
|
|
40
|
+
else
|
|
41
|
+
setValue(value, datatype)
|
|
42
|
+
end
|
|
43
|
+
else
|
|
44
|
+
setValue(args)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Sets the datatype of this occurrence without changing its value.
|
|
49
|
+
#
|
|
50
|
+
# The datatype must be a String or Locator.
|
|
51
|
+
#
|
|
52
|
+
# :call-seq:
|
|
53
|
+
# datatype = datatype
|
|
54
|
+
#
|
|
55
|
+
def datatype=(datatype)
|
|
56
|
+
self.value = self.value, datatype
|
|
57
|
+
end
|
|
58
|
+
alias :set_datatype :datatype=
|
|
59
|
+
|
|
60
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
|
|
2
|
+
# License: Apache License, Version 2.0
|
|
3
|
+
|
|
4
|
+
module Java::OrgTmapiCore::Locator
|
|
5
|
+
|
|
6
|
+
include RTM::Locator
|
|
7
|
+
extend Superiseable
|
|
8
|
+
|
|
9
|
+
# Returns the external form of the IRI.
|
|
10
|
+
# Any special character will be escaped using the escaping conventions
|
|
11
|
+
# of RFC 3987.
|
|
12
|
+
#
|
|
13
|
+
# :call-seq:
|
|
14
|
+
# value -> String
|
|
15
|
+
#
|
|
16
|
+
def value
|
|
17
|
+
toExternalForm
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
|
|
2
|
+
# License: Apache License, Version 2.0
|
|
3
|
+
|
|
4
|
+
module Java::OrgTmapiCore::Name
|
|
5
|
+
|
|
6
|
+
include RTM::Name
|
|
7
|
+
extend Superiseable
|
|
8
|
+
|
|
9
|
+
# Returns the Topic this Name belongs to.
|
|
10
|
+
#
|
|
11
|
+
# :call-seq:
|
|
12
|
+
# parent -> Topic
|
|
13
|
+
#
|
|
14
|
+
def parent
|
|
15
|
+
getParent
|
|
16
|
+
end
|
|
17
|
+
alias :reverse_children :parent
|
|
18
|
+
|
|
19
|
+
# Returns all Variants defined for this Name.
|
|
20
|
+
#
|
|
21
|
+
# :call-seq:
|
|
22
|
+
# children -> Array of Variants
|
|
23
|
+
#
|
|
24
|
+
def children
|
|
25
|
+
getVariants.to_a
|
|
26
|
+
end
|
|
27
|
+
alias :reverse_parent :children
|
|
28
|
+
|
|
29
|
+
superised
|
|
30
|
+
# Returns the value of this Name.
|
|
31
|
+
#
|
|
32
|
+
# :call-seq:
|
|
33
|
+
# value -> String
|
|
34
|
+
#
|
|
35
|
+
def value
|
|
36
|
+
getValue
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Sets the value of this name. The previous value is overridden.
|
|
40
|
+
#
|
|
41
|
+
# Argument is a String.
|
|
42
|
+
#
|
|
43
|
+
# :call-seq:
|
|
44
|
+
# value=(argument)
|
|
45
|
+
#
|
|
46
|
+
def value=(argument)
|
|
47
|
+
setValue(argument)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
superised
|
|
51
|
+
# Creates a Variant given the value and scope, if value is a Locator or
|
|
52
|
+
# given value, datatype and scope, if the value is a String.
|
|
53
|
+
#
|
|
54
|
+
# Scope may be an Array of topic references and must not be empty.
|
|
55
|
+
#
|
|
56
|
+
# Datatype may be a String or Locator.
|
|
57
|
+
#
|
|
58
|
+
# :call-seq:
|
|
59
|
+
# create_variant(value, scope) -> Variant
|
|
60
|
+
# create_variant(value, datatype, scope) -> Variant
|
|
61
|
+
#
|
|
62
|
+
def create_variant(value, *args)
|
|
63
|
+
# reading scope and datatype, if given
|
|
64
|
+
if args.length == 1
|
|
65
|
+
if args.first.is_a?(Hash)
|
|
66
|
+
# TODO
|
|
67
|
+
else
|
|
68
|
+
# scope given
|
|
69
|
+
scope = args.first
|
|
70
|
+
raise("create_variant(value, scope): scope must be an Array") unless scope.is_a?(Array)
|
|
71
|
+
end
|
|
72
|
+
elsif args.length == 2
|
|
73
|
+
# datatype and scope given
|
|
74
|
+
datatype = args.first
|
|
75
|
+
scope = args.last
|
|
76
|
+
raise("create_variant(value, datatype, scope): scope must be an Array") unless scope.is_a?(Array)
|
|
77
|
+
else
|
|
78
|
+
raise("create_variant: arguments don't match - no scope given.")
|
|
79
|
+
end
|
|
80
|
+
# reading the value and setting the datatype dynamicaly if not set before
|
|
81
|
+
unless datatype
|
|
82
|
+
if value.is_a?(Java::OrgTmapiCore::Locator)
|
|
83
|
+
datatype ||= RTM::PSI[:IRI]
|
|
84
|
+
elsif value.is_a?(String)
|
|
85
|
+
datatype ||= RTM::PSI[:String]
|
|
86
|
+
elsif value.is_a?(Float)
|
|
87
|
+
datatype ||= RTM::PSI[:Float]
|
|
88
|
+
elsif value.is_a?(Fixnum)
|
|
89
|
+
datatype ||= RTM::PSI[:Long]
|
|
90
|
+
elsif value.is_a?(Bignum)
|
|
91
|
+
datatype ||= RTM::PSI[:Integer]
|
|
92
|
+
elsif value.is_a?(DateTime) #DateTime is a Time and a Date
|
|
93
|
+
datatype ||= RTM::PSI[:DateTime]
|
|
94
|
+
elsif value.is_a?(Time)
|
|
95
|
+
datatype ||= RTM::PSI[:Time]
|
|
96
|
+
elsif value.is_a?(Date)
|
|
97
|
+
datatype ||= RTM::PSI[:Date]
|
|
98
|
+
else
|
|
99
|
+
raise NoDatatypeHandlerAvailableException.new(value)
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
# creating locator for datatype
|
|
103
|
+
datatype = topic_map.create_locator(datatype)
|
|
104
|
+
# value must be a String
|
|
105
|
+
value = value.to_s
|
|
106
|
+
# if datatype is xsd:anyURI -> resolve value against base_iri
|
|
107
|
+
if datatype.reference == RTM::PSI[:IRI]
|
|
108
|
+
value = topic_map.create_locator(value).reference
|
|
109
|
+
end
|
|
110
|
+
# creating an array of topics for the scope
|
|
111
|
+
scope = topic_map.get!(scope).to_java(Java::OrgTmapiCore::Topic)
|
|
112
|
+
|
|
113
|
+
begin
|
|
114
|
+
createVariant(value, datatype, scope)
|
|
115
|
+
rescue java.lang.IllegalArgumentException => iae
|
|
116
|
+
raise(iae.message)
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
private
|
|
121
|
+
class NoDatatypeHandlerAvailableException < Exception
|
|
122
|
+
def initialize(value)
|
|
123
|
+
super "Cannot map #{value} to a variant value+datatype. Maybe you need to add a handler for your Ruby object type."
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
|
|
2
|
+
# License: Apache License, Version 2.0
|
|
3
|
+
|
|
4
|
+
module Java::OrgTmapiCore::Occurrence
|
|
5
|
+
|
|
6
|
+
include RTM::Occurrence
|
|
7
|
+
extend Superiseable
|
|
8
|
+
|
|
9
|
+
# Returns the Topic this Occurrence belongs to.
|
|
10
|
+
#
|
|
11
|
+
# :call-seq:
|
|
12
|
+
# parent -> Topic
|
|
13
|
+
#
|
|
14
|
+
def parent
|
|
15
|
+
getParent
|
|
16
|
+
end
|
|
17
|
+
alias :reverse_children :parent
|
|
18
|
+
|
|
19
|
+
# Returns the lexical representation of the value of the Occurrence.
|
|
20
|
+
#
|
|
21
|
+
# For the datatype String the string itself is returned
|
|
22
|
+
# For the datatype anyURI the Locator.getReference -> String is returned.
|
|
23
|
+
#
|
|
24
|
+
# :call-seq:
|
|
25
|
+
# value -> String
|
|
26
|
+
#
|
|
27
|
+
def value
|
|
28
|
+
getValue
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
|