# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig. # License: Apache License, Version 2.0 module RTM::Revision Type = Java::DeTopicmapslabMajortomModelEvent::TopicMapEventType def self.specify_event(type) return ( case type when Type::ASSOCIATION_ADDED :creation when Type::ASSOCIATION_REMOVED :deletion when Type::DATATYPE_SET :update when Type::ID_MODIFIED :update when Type::ITEM_IDENTIFIER_ADDED :update when Type::ITEM_IDENTIFIER_REMOVED :update when Type::MERGE :update when Type::NAME_ADDED :update when Type::NAME_REMOVED :update when Type::OCCURRENCE_ADDED :update when Type::OCCURRENCE_REMOVED :update when Type::PLAYER_MODIFIED :update when Type::REIFIER_SET :update when Type::REMOVE_DUPLICATES :update when Type::ROLE_ADDED :update when Type::ROLE_REMOVED :update when Type::SCOPE_MODIFIED :update when Type::SUBJECT_IDENTIFIER_ADDED :update when Type::SUBJECT_IDENTIFIER_REMOVED :update when Type::SUBJECT_LOCATOR_ADDED :update when Type::SUBJECT_LOCATOR_REMOVED :update when Type::TOPIC_ADDED :creation when Type::TOPIC_REMOVED :deletion when Type::TYPE_ADDED :update when Type::TYPE_REMOVED :update when Type::TYPE_SET :update when Type::VALUE_MODIFIED :update when Type::VARIANT_ADDED :update when Type::VARIANT_REMOVED :update else nil end ) end def self.topic_or_association_context(revision) # TODO not finished yet, test it also in the history_spec type = revision.changeset_type changeset = revision.changeset case type when Type::ASSOCIATION_ADDED context = changeset.first.new_value # association when Type::ASSOCIATION_REMOVED context = changeset.last.old_value # association when Type::DATATYPE_SET datatype_aware = changeset.first.context if datatype_aware.is_a?(RTM::Occurrence) context = datatype_aware.parent # topic else context = datatype_aware.parent.parent # topic end when Type::ID_MODIFIED return nil when Type::ITEM_IDENTIFIER_ADDED context = changeset.first.context # topic when Type::ITEM_IDENTIFIER_REMOVED context = changeset.first.context # topic when Type::MERGE return nil when Type::NAME_ADDED context = changeset.first.context # topic when Type::NAME_REMOVED context = changeset.last.context # topic when Type::OCCURRENCE_ADDED context = changeset.first.context # topic when Type::OCCURRENCE_REMOVED context = changeset.last.context # topic when Type::PLAYER_MODIFIED context = changeset.first.context.parent # association when Type::REIFIER_SET return nil when Type::REMOVE_DUPLICATES return nil when Type::ROLE_ADDED context = changeset.first.context # association when Type::ROLE_REMOVED context = changeset.last.context # association when Type::SCOPE_MODIFIED typed = changeset.first.context if typed.is_a?(RTM::Variant) context = typed.parent.parent # topic elsif typed.is_a?(RTM::Occurrence) context = typed.parent # topic elsif typed.is_a?(RTM::Name) context = typed.parent # topic else context = typed # association end when Type::SUBJECT_IDENTIFIER_ADDED context = changeset.first.context # topic when Type::SUBJECT_IDENTIFIER_REMOVED context = changeset.first.context # topic when Type::SUBJECT_LOCATOR_ADDED context = changeset.first.context # topic when Type::SUBJECT_LOCATOR_REMOVED context = changeset.first.context # topic when Type::TOPIC_ADDED context = changeset.first.new_value # topic when Type::TOPIC_REMOVED context = changeset.last.old_value # topic when Type::TYPE_ADDED context = changeset.first.context # topic when Type::TYPE_REMOVED context = changeset.first.context # topic when Type::TYPE_SET typed = changeset.first.context if typed.is_a?(RTM::Role) context = typed.parent # association elsif typed.is_a?(RTM::Association) context = typed # association else context = typed.parent # topic end when Type::VALUE_MODIFIED valued = changeset.first.context if valued.is_a?(RTM::Variant) context = valued.parent.parent #topic else context = valued.parent # topic end when Type::VARIANT_ADDED context = changeset.first.context.parent # topic when Type::VARIANT_REMOVED context = changeset.last.context.parent # topic else return nil end return context end end