Class: RTM::MaJorToM

Inherits:
JavaTMAPI
  • Object
show all
Defined in:
lib/rtm/majortom.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ MaJorToM

Returns a new instance of MaJorToM.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rtm/majortom.rb', line 19

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