Module: RTM::Ontopia::Rdbms::Properties

Defined in:
lib/rtm/ontopia/rdbms/properties.rb

Defined Under Namespace

Modules: DatabaseDefaults

Class Method Summary collapse

Class Method Details

.rails2ontopia(config) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rtm/ontopia/rdbms/properties.rb', line 4

def self.rails2ontopia(config)
  ontopia_properties = {}
  ontopia_prefix = "net.ontopia.topicmaps."
  ontopia_properties["#{ontopia_prefix}store"] = config[:store] || "rdbms"
  ontopia_rdbms_prefix = "#{ontopia_prefix}impl.rdbms."

  adapter = config[:adapter].sub(/^jdbc/, '')

  adapter_config = "#{adapter}_config".to_s
  config = DatabaseDefaults.send(adapter_config, config) if DatabaseDefaults.respond_to?(adapter_config)

  ontopia_properties["#{ontopia_rdbms_prefix}Database"] = adapter
  ontopia_properties["#{ontopia_rdbms_prefix}DriverClass"] = config[:driver]
  ontopia_properties["#{ontopia_rdbms_prefix}ConnectionString"] = config[:url]
  ontopia_properties["#{ontopia_rdbms_prefix}UserName"] = config[:username] || "sa"
  ontopia_properties["#{ontopia_rdbms_prefix}Password"] = config[:password] || ""
  ontopia_properties["#{ontopia_rdbms_prefix}ConnectionPool"] = config[:connection_pool] == nil ? false : config[:connection_pool]
  ontopia_properties["#{ontopia_rdbms_prefix}BatchUpdates"] =  config[:batch_updates] == nil ? true : config[:batch_updates]
  ontopia_properties["#{ontopia_rdbms_prefix}StorePool.MinimumSize"] = 2

  ontopia_properties
end