# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig. # License: Apache License, Version 2.0 unless Object.const_defined?("Gem") && rtmgem = Gem.loaded_specs["rtm-majortom"] javatmapi_path = File.expand_path(File.join(File.dirname(__FILE__), "../../../rtm-javatmapi/lib")) $LOAD_PATH.unshift javatmapi_path if File.directory?(javatmapi_path) end require 'rtm/javatmapi' Dir[File.join(File.dirname(__FILE__), 'majortom/javalibs/*.jar')].each {|file| require file } require File.join(File.dirname(__FILE__), '/majortom/core') require File.join(File.dirname(__FILE__), '/majortom/sugar') module RTM class MaJorToM < JavaTMAPI identifier :majortom def initialize(*args) super # someone wants :backend as symbol @params[:backend] = @params[:backend].to_sym if @params[:backend] @params[:store] = @params[:store].to_sym if @params[:store] @params[:properties] ||= {} @params[:features] ||= {} @params[:features].merge!("de.topicmapslab.majortom.topicmapstore.history" => true) #unless @params[:history] == false @params[:features].merge!("http://tmapi.org/features/type-instance-associations" => false) if @params[:store] == :in_memory || @params[:store].nil? # DEFAULT for :implementation => :majortom @params[:properties].merge!("de.topicmapslab.majortom.topicmapstore.class" => "de.topicmapslab.majortom.inmemory.store.InMemoryTopicMapStore") elsif @params[:store] == :db _params = {} _params["de.topicmapslab.majortom.topicmapstore.class"] = "de.topicmapslab.majortom.database.store.JdbcTopicMapStore" _params["de.topicmapslab.majortom.jdbc.database"] = @params[:database] if @params[:database] _params["de.topicmapslab.majortom.jdbc.user"] = @params[:user] if @params[:user] _params["de.topicmapslab.majortom.jdbc.password"] = @params[:password] if @params[:password] _params["de.topicmapslab.majortom.jdbc.host"] = @params[:host] if @params[:host] _params["de.topicmapslab.majortom.jdbc.dialect"] = @params[:dialect] if @params[:dialect] @params[:properties].merge!(_params) end raise("Implementation class of topic map store not set.") unless @params[:properties]["de.topicmapslab.majortom.topicmapstore.class"] tmsf = Java::DeTopicmapslabMajortomCore::TopicMapSystemFactoryImpl.new set_tmsf(tmsf) set_properties(@params[:properties]) set_features(@params[:features]) create_system end end end class Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyTopic def read_only? return true end end class Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyTopic def read_only? return true end end module Java::OrgTmapiCore::TopicMap register_java_implementation Java::DeTopicmapslabMajortomCore::TopicMapImpl end module Java::OrgTmapiCore::Topic register_java_implementation Java::DeTopicmapslabMajortomCore::TopicImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyTopic register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyTopic end module Java::OrgTmapiCore::Association register_java_implementation Java::DeTopicmapslabMajortomCore::AssociationImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyAssociation register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyAssociation end module Java::OrgTmapiCore::Name register_java_implementation Java::DeTopicmapslabMajortomCore::NameImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyName register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyName end module Java::OrgTmapiCore::Occurrence register_java_implementation Java::DeTopicmapslabMajortomCore::OccurrenceImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyOccurrence register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyOccurrence end module Java::OrgTmapiCore::Variant register_java_implementation Java::DeTopicmapslabMajortomCore::VariantImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyVariant register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyVariant end module Java::OrgTmapiCore::Role register_java_implementation Java::DeTopicmapslabMajortomCore::AssociationRoleImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyAssociationRole register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyAssociationRole end module Java::OrgTmapiCore::Scoped register_java_implementation Java::DeTopicmapslabMajortomCore::ScopeableImpl register_java_implementation Java::DeTopicmapslabMajortomCore::NameImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyName register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyName register_java_implementation Java::DeTopicmapslabMajortomCore::OccurrenceImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyOccurrence register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyOccurrence register_java_implementation Java::DeTopicmapslabMajortomCore::VariantImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyVariant register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyVariant register_java_implementation Java::DeTopicmapslabMajortomCore::AssociationImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyAssociation register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyAssociation end module Java::OrgTmapiCore::Typed register_java_implementation Java::DeTopicmapslabMajortomCore::AssociationImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyAssociation register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyAssociation register_java_implementation Java::DeTopicmapslabMajortomCore::NameImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyName register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyName register_java_implementation Java::DeTopicmapslabMajortomCore::OccurrenceImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyOccurrence register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyOccurrence register_java_implementation Java::DeTopicmapslabMajortomCore::AssociationRoleImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyAssociationRole register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyAssociationRole end module Java::OrgTmapiCore::Construct register_java_implementation Java::DeTopicmapslabMajortomCore::ConstructImpl register_java_implementation Java::DeTopicmapslabMajortomCore::TopicMapImpl register_java_implementation Java::DeTopicmapslabMajortomCore::TopicImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyTopic register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyTopic register_java_implementation Java::DeTopicmapslabMajortomCore::AssociationImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyAssociation register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyAssociation register_java_implementation Java::DeTopicmapslabMajortomCore::NameImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyName register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyName register_java_implementation Java::DeTopicmapslabMajortomCore::OccurrenceImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyOccurrence register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyOccurrence register_java_implementation Java::DeTopicmapslabMajortomCore::VariantImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyVariant register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyVariant register_java_implementation Java::DeTopicmapslabMajortomCore::AssociationRoleImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyAssociationRole register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyAssociationRole end module Java::OrgTmapiCore::Reifiable register_java_implementation Java::DeTopicmapslabMajortomCore::ReifiableImpl register_java_implementation Java::DeTopicmapslabMajortomCore::TopicMapImpl #register_java_implementation Java::DeTopicmapslabMajortomCore::TopicImpl #register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyTopic register_java_implementation Java::DeTopicmapslabMajortomCore::AssociationImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyAssociation register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyAssociation register_java_implementation Java::DeTopicmapslabMajortomCore::NameImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyName register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyName register_java_implementation Java::DeTopicmapslabMajortomCore::OccurrenceImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyOccurrence register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyOccurrence register_java_implementation Java::DeTopicmapslabMajortomCore::VariantImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyVariant register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyVariant register_java_implementation Java::DeTopicmapslabMajortomCore::AssociationRoleImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyAssociationRole register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyAssociationRole end module Java::OrgTmapiCore::Locator register_java_implementation Java::DeTopicmapslabMajortomCore::LocatorImpl end module Java::OrgTmapiCore::DatatypeAware register_java_implementation Java::DeTopicmapslabMajortomCore::DataTypeAwareImpl register_java_implementation Java::DeTopicmapslabMajortomCore::OccurrenceImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyOccurrence register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyOccurrence register_java_implementation Java::DeTopicmapslabMajortomCore::VariantImpl register_java_implementation Java::DeTopicmapslabMajortomInmemoryStoreRevisionReadonly::InMemoryReadOnlyVariant register_java_implementation Java::DeTopicmapslabMajortomDatabaseReadonly::JdbcReadOnlyVariant end