# Path: tmapi/exceptions.py
# class IdentityConstraintException (ModelConstraintException):
# 
#     """This exception is used to report identity constraint
#     violations. Assigning an item identifier, a subject identifier, or
#     a subject locator to different objects causes an
#     `IdentityConstraintException` to be raised."""
# 
#     def __init__ (self, reporter, existing, locator, message):
#         """Creates a new `IdentityConstraintException` with the
#         specified message.
# 
#         :param reporter: the construct to which the identity should
#           have been assigned
#         :type reporter: `Construct`
#         :param existing: the construct that has the same identity
#         :type existing: `Construct`
#         :param locator: the locator representing the identity
#         :type locator: `Locator`
#         :param message: the detail message
#         :type message: string
# 
#         """
#         super(IdentityConstraintException, self).__init__(reporter, message)
#         self._existing = existing
#         self._locator = locator
# 
#     def get_existing (self):
#         """Returns the `Construct` which already has the identity
#         represented by the locator get_locator().
# 
#         :rtype: `Construct`
# 
#         """
#         return self._existing
# 
#     def get_locator (self):
#         """Returns the `Locator` representing the identity that caused
#         the exception.
# 
#         :rtype: `Locator`
# 
#         """
#         return self._locator
# 
# class ModelConstraintException (TMAPIRuntimeException):
# 
#     """This exception is used to report Topic Maps - Data Model
#     constraint violations."""
# 
#     def __init__ (self, reporter, message):
#         """Creates a new ModelConstraintException with the specified
#         message.
# 
#         :param reporter: the construct which has thrown this exception
#         :type reporter: `Construct`
#         :param message: the detail message
#         :type message: string
# 
#         """
#         self._reporter = reporter
#         self._message = message
#     
#     def get_reporter (self):
#         """Return the `Construct` which has thrown the exception.
# 
#         :rtype: `Construct`
# 
#         """
#         return self._reporter


from tmapi.exceptions import IdentityConstraintException, \
    ModelConstraintException
from item_identifier import ItemIdentifier
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.




class Construct (object):

    # Properly item_identifier and topic_map fields should be defined
    # here. However, due to inheritance, this causes Django problems,
    # and so they are defined separately in ConstructFields and the
    # specific models inherit from that class directly.
    
    def add_item_identifier (self, item_identifier):
        """Adds an item identifier.

        It is not allowed to have two `Construct`s in the same
        `TopicMap` with the same item identifier. If the two objects
        are `Topic`s, then they must be merged. If at least one of the
        two objects is not a `Topic`, an `IdentityConstraintException`
        must be reported.

        :param item_identifier: the item identifier to be added
        :type item_identifier: `Locator`
        :raises `IdentityConstraintException`: if another construct
          has an item identifier which is equal to `item_identifier`
        
        """
        if item_identifier is None:

# Path: tmapi/exceptions.py
# class IdentityConstraintException (ModelConstraintException):
# 
#     """This exception is used to report identity constraint
#     violations. Assigning an item identifier, a subject identifier, or
#     a subject locator to different objects causes an
#     `IdentityConstraintException` to be raised."""
# 
#     def __init__ (self, reporter, existing, locator, message):
#         """Creates a new `IdentityConstraintException` with the
#         specified message.
# 
#         :param reporter: the construct to which the identity should
#           have been assigned
#         :type reporter: `Construct`
#         :param existing: the construct that has the same identity
#         :type existing: `Construct`
#         :param locator: the locator representing the identity
#         :type locator: `Locator`
#         :param message: the detail message
#         :type message: string
# 
#         """
#         super(IdentityConstraintException, self).__init__(reporter, message)
#         self._existing = existing
#         self._locator = locator
# 
#     def get_existing (self):
#         """Returns the `Construct` which already has the identity
#         represented by the locator get_locator().
# 
#         :rtype: `Construct`
# 
#         """
#         return self._existing
# 
#     def get_locator (self):
#         """Returns the `Locator` representing the identity that caused
#         the exception.
# 
#         :rtype: `Locator`
# 
#         """
#         return self._locator
# 
# class ModelConstraintException (TMAPIRuntimeException):
# 
#     """This exception is used to report Topic Maps - Data Model
#     constraint violations."""
# 
#     def __init__ (self, reporter, message):
#         """Creates a new ModelConstraintException with the specified
#         message.
# 
#         :param reporter: the construct which has thrown this exception
#         :type reporter: `Construct`
#         :param message: the detail message
#         :type message: string
# 
#         """
#         self._reporter = reporter
#         self._message = message
#     
#     def get_reporter (self):
#         """Return the `Construct` which has thrown the exception.
# 
#         :rtype: `Construct`
# 
#         """
#         return self._reporter


# Path: tmapi/models/construct.py
from tmapi.exceptions import IdentityConstraintException, \
    ModelConstraintException
from item_identifier import ItemIdentifier

# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.




class Construct (object):

    # Properly item_identifier and topic_map fields should be defined
    # here. However, due to inheritance, this causes Django problems,
    # and so they are defined separately in ConstructFields and the
    # specific models inherit from that class directly.
    
    def add_item_identifier (self, item_identifier):
        """Adds an item identifier.

        It is not allowed to have two `Construct`s in the same
        `TopicMap` with the same item identifier. If the two objects
        are `Topic`s, then they must be merged. If at least one of the
        two objects is not a `Topic`, an `IdentityConstraintException`
        must be reported.

        :param item_identifier: the item identifier to be added
        :type item_identifier: `Locator`
        :raises `IdentityConstraintException`: if another construct
          has an item identifier which is equal to `item_identifier`
        
        """
        if item_identifier is None:

            raise ModelConstraintException(