# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig. # License: Apache License, Version 2.0 module RTM::Majortom::Sugar module TopicMap def latest_revision_id raise("not supported") if self.read_only? return 0 unless last_revision = revision_index.last_revision last_revision.getId end # Returns all revisions in the revision_index starting with the last one def all_revisions all_revisions = [] revision = self.revision_index.last_revision if revision all_revisions << revision while revision = revision.past all_revisions << revision end end return all_revisions end # Calls and loads the RevisionIndex managed by MaJorToM. def revision_index index = getIndex(Java::DeTopicmapslabMajortomModelIndex::IRevisionIndex.java_class) index.open unless index.is_open return index end # Calls and loads the SupertypeSubtypeIndex managed by MaJorToM. def supertype_subtype_index index = getIndex(Java::DeTopicmapslabMajortomModelIndex::ISupertypeSubtypeIndex.java_class) index.open unless index.is_open return index end # Calls and loads the TransitiveTypeInstanceIndex managed by MaJorToM. def transitive_type_instance_index index = getIndex(Java::DeTopicmapslabMajortomModelIndex::ITransitiveTypeInstanceIndex.java_class) index.open unless index.is_open return index end def register_tmql_environment_map(topic_map) raise("topic_map must be a topic map") unless topic_map.is_a?(RTM::TopicMap) if self.store.is_read_only self.store.registerTMQLEnvironmentMap(topic_map) else raise("Method only working on read-only topic maps.") end end alias :registerTMQLEnvironmentMap :register_tmql_environment_map def tmql_environment_map if self.store.is_read_only self.store.getTMQLEnvironmentMap else raise("Method only working on read-only topic maps.") end end alias :getTMQLEnvironmentMap :tmql_environment_map def enable_revision_management self.store.enable_revision_management(true) end def disable_revision_management self.store.enable_revision_management(false) end end end