lib/rtm/javatmapi/core/construct.rb in rtm-javatmapi-0.2.0 vs lib/rtm/javatmapi/core/construct.rb in rtm-javatmapi-0.2.1
- old
+ new
@@ -1,43 +1,67 @@
# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
# License: Apache License, Version 2.0
module Java::OrgTmapiCore::Construct
+ include RTM::Construct
extend Superiseable
- #include RTM::Construct
# Returns the TopicMap instance this Construct belongs to.
#
# :call-seq:
# topic_map -> TopicMap
#
def topic_map
getTopicMap
end
+ # Returns the parent construct this construct belongs to.
+ #
+ # :call-seq:
+ # parent -> a construct (TopicMap, Topic, Association or Name)
+ #
+ def parent
+ getParent
+ end
+
# Returns true if the construct fulfills all constraints defined in the TMDM
def valid?
# 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.
true
end unless self.method_defined?(:valid?)
+
+ # Returns the item identifiers assigned to the current construct.
+ #
+ # :call-seq:
+ # item_identifiers -> Set of Locators
+ #
+ def item_identifiers
+ getItemIdentifiers
+ end
+
superised
# Adds an item identifier to this construct.
# Identifier may be a String or Locator.
#
# :call-seq:
# item_identifiers=(identifier)
#
def add_item_identifier(identifier)
# TODO Spec
- if identifier.is_a? Java::OrgTmapiCore::Locator
- addItemIdentifier(identifier)
- else
- addItemIdentifier(topic_map.create_locator(identifier))
+ begin
+ if identifier.is_a? Java::OrgTmapiCore::Locator
+ addItemIdentifier(identifier)
+ else
+ addItemIdentifier(topic_map.create_locator(identifier))
+ end
+ rescue org.tmapi.core.IdentityConstraintException => ice
+ # TODO add condition to switch off automerge
+ self.mergeIn(self.topic_map.get(identifier))
end
end
- alias :item_identifiers= :add_item_identifier
+ alias :item_identifiers= :add_item_identifier # FIXME ii= is not add! it's set.
superised
# Removes an item identifer from this construct,
# if present.