1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308
|
-- ----------------------------------------------------------------------------------------
-- Copyright (C) 2004 MySQL AB
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-- ----------------------------------------------------------------------------------------
-- ----------------------------------------------------------------------------------------
-- @file RdbmsInfoMaxdb.lua
-- @brief Module that contains functionality for database management
-- ----------------------------------------------------------------------------------------
-- ----------------------------------------------------------------------------------------
-- @brief Returns the information about this module
--
-- Every Grt module has to implement this function to return information about the
-- module. Note that new functions that should be exposed to the Grt have to be listed
-- here. Function that are not exposed should start with a underscore.
--
-- @return A dict that contains the name and the function names of the module
-- ----------------------------------------------------------------------------------------
function getModuleInfo()
local moduleInfo= {
name= "RdbmsInfoMaxdb",
functions= {
"getRdbmsInfo::"
},
extends= "RdbmsInfo"
}
return moduleInfo
end
-- ----------------------------------------------------------------------------------------
-- @brief Function to get information about MaxDB
--
-- Returns a db.mgmt.Rdbms struct with infos about the rdbms
--
-- @return a new created db.mgmt.Rdbms GRT value struct
-- ----------------------------------------------------------------------------------------
function getRdbmsInfo(args)
local rdbmsMgmt= args[1]
-- create Rdbms object
local rdbms= grtV.newObj("db.mgmt.Rdbms", "MaxDB", "{672A46A8-3CE4-419B-ABFF-AE5B61205C3D}", grtV.toLua(rdbmsMgmt._id))
rdbms.caption= "MaxDB Database Server"
rdbms.databaseObjectPackage= "db.maxdb"
-- create simple datatypes for Rdbms
createSimpleDatatypes(rdbmsMgmt, rdbms)
-- add driver to the Rdbms' list of drivers
grtV.insert(rdbms.drivers, getDriverMaxdbJdbcSid(rdbms))
rdbms.defaultDriver= rdbms.drivers[1]
return grt.success(rdbms)
end
-- ----------------------------------------------------------------------------------------
-- @brief Builds the list of simple datatypes
--
-- Helper function to build the list of simple datatypes
--
-- @param rdbmsMgmt the Grt value of the Rdbms Management
-- @param rdbms the Grt value of the Rdbms
-- ----------------------------------------------------------------------------------------
function createSimpleDatatypes(rdbmsMgmt, rdbms)
local dt
local owner= grtV.toLua(rdbms._id)
local group
-- --------------------------------------------------------------------------------------
-- numeric group
do
group= __RdbmsManagement_lua.getDatatypeGroupByNameLua(rdbmsMgmt, "numeric")
-- SMALLINT
dt= grtV.newObj("db.SimpleDatatype", "SMALLINT", "{F225951E-D381-43B5-BF9C-9218EAC65E1A}", owner)
dt.group= group
dt.numericPrecision= 5
grtV.insert(rdbms.simpleDatatypes, dt)
-- INT[EGER]
dt= grtV.newObj("db.SimpleDatatype", "INTEGER", "{25E3CD6F-124E-49E9-A5AE-E3F44614D05C}", owner)
dt.group= group
dt.numericPrecision= 10
grtV.insert(dt.synonyms, "INT")
grtV.insert(rdbms.simpleDatatypes, dt)
-- FLOAT
dt= grtV.newObj("db.SimpleDatatype", "FLOAT", "{996F49DC-C4BC-4C97-B1A1-68E43C384919}", owner)
dt.group= group
grtV.insert(rdbms.simpleDatatypes, dt)
-- FIXED
dt= grtV.newObj("db.SimpleDatatype", "FIXED", "{B7CFB3A7-1634-4930-B64C-EC5B2FFF5958}", owner)
dt.group= group
dt.numericPrecision= 38
dt.numericScale= 37
grtV.insert(rdbms.simpleDatatypes, dt)
end
-- --------------------------------------------------------------------------------------
-- string group
do
group= __RdbmsManagement_lua.getDatatypeGroupByNameLua(rdbmsMgmt, "string")
-- VARCHAR
dt= grtV.newObj("db.SimpleDatatype", "VARCHAR", "{521413DC-D60D-4EDE-94D3-7915374E3265}", owner)
dt.group= group
dt.characterMaximumLength= 8000
grtV.insert(dt.flags, "ASCII")
grtV.insert(dt.flags, "BYTE")
grtV.insert(dt.flags, "UNICODE")
grtV.insert(rdbms.simpleDatatypes, dt)
-- CHAR[ACTER]
dt= grtV.newObj("db.SimpleDatatype", "CHAR", "{F980C4A0-983B-41D4-8D2F-1C3122F42203}", owner)
dt.group= group
dt.characterMaximumLength= 8000
grtV.insert(dt.synonyms, "CHARACTER")
grtV.insert(dt.flags, "ASCII")
grtV.insert(dt.flags, "BYTE")
grtV.insert(dt.flags, "UNICODE")
grtV.insert(rdbms.simpleDatatypes, dt)
end
-- --------------------------------------------------------------------------------------
-- text group
-- do
-- group= __RdbmsManagement_lua.getDatatypeGroupByNameLua(rdbmsMgmt, "text")
--
-- -- LONG
-- dt= grtV.newObj("db.SimpleDatatype", "LONG", "{0207CD2C-0789-4241-90DB-7C54B3B1B8F3}", owner)
-- dt.group= group
-- dt.characterMaximumLength= -32
-- grtV.insert(dt.flags, "ASCII")
-- grtV.insert(dt.flags, "UNICODE")
-- grtV.insert(rdbms.simpleDatatypes, dt)
--
-- end
-- --------------------------------------------------------------------------------------
-- blob group
do
group= __RdbmsManagement_lua.getDatatypeGroupByNameLua(rdbmsMgmt, "blob")
-- LONG
dt= grtV.newObj("db.SimpleDatatype", "LONG", "{5161C414-9EBE-4FC8-878E-1C48066D665A}", owner)
dt.group= group
dt.characterMaximumLength= -32
grtV.insert(dt.flags, "ASCII")
grtV.insert(dt.flags, "BYTE")
grtV.insert(dt.flags, "UNICODE")
grtV.insert(rdbms.simpleDatatypes, dt)
end
-- --------------------------------------------------------------------------------------
-- datetime group
do
group= __RdbmsManagement_lua.getDatatypeGroupByNameLua(rdbmsMgmt, "datetime")
-- DATE
dt= grtV.newObj("db.SimpleDatatype", "DATE", "{560898D6-776B-477F-901E-201DC5875812}", owner)
dt.group= group
dt.dateTimePrecision= 3
grtV.insert(dt.flags, "EUR")
grtV.insert(dt.flags, "INTERNAL")
grtV.insert(dt.flags, "ISO")
grtV.insert(dt.flags, "JIS")
grtV.insert(dt.flags, "USA")
grtV.insert(rdbms.simpleDatatypes, dt)
-- TIME
dt= grtV.newObj("db.SimpleDatatype", "TIME", "{CED28F00-9B19-47A6-9B2E-012C3F4C2F78}", owner)
dt.group= group
dt.dateTimePrecision= 3
grtV.insert(dt.flags, "EUR")
grtV.insert(dt.flags, "INTERNAL")
grtV.insert(dt.flags, "ISO")
grtV.insert(dt.flags, "JIS")
grtV.insert(dt.flags, "USA")
grtV.insert(rdbms.simpleDatatypes, dt)
-- TIMESTAMP
dt= grtV.newObj("db.SimpleDatatype", "TIMESTAMP", "{E4CDFE32-E9D0-4D7D-98A3-EAEC9E04DAF0}", owner)
dt.group= group
dt.dateTimePrecision= 9
grtV.insert(dt.flags, "EUR")
grtV.insert(dt.flags, "INTERNAL")
grtV.insert(dt.flags, "ISO")
grtV.insert(dt.flags, "JIS")
grtV.insert(dt.flags, "USA")
grtV.insert(rdbms.simpleDatatypes, dt)
end
-- --------------------------------------------------------------------------------------
end
-- ----------------------------------------------------------------------------------------
-- @brief Function to get the MaxDB driver using Sid
--
-- Helper function to return infos about the Jdbc driver
--
-- @param owner the Grt value of the Rdbms
--
-- @return a new created GRT value of struct "db.mgmt.Driver" containing the driver infos
-- ----------------------------------------------------------------------------------------
function getDriverMaxdbJdbcSid(owner)
-- create driver object
local driver= grtV.newObj("db.mgmt.JdbcDriver", "MaxDB JDBC",
"{9FAE1CD7-8B0E-47E5-81E9-6A311AA89896}", grtV.toLua(owner._id))
-- set driver values
driver.caption= "MaxDB JDBC Driver"
driver.description= "MaxDB JDBC Driver to connect to MaxDB 7.5 and newer."
driver.filesTarget= "./java/lib/"
grtV.insert(driver.files, "sapdbc-7_6_00_12_4339.jar")
driver.downloadUrl= "http://www.mysql.com/products/maxdb/"
-- Jdbc specific settings
driver.className= "com.sap.dbtech.jdbc.DriverSapDB"
driver.connectionStringTemplate= "jdbc:sapdb://%host%:%port%/%instance%?user=%username%&password=%password%&sqlmode=%sqlmode%&cachelimit=%cachelimit%&timeout=%timeout%&isolation=%isolation%&autocommit=%autocommit%&reconnect=%reconnect%&cache=%cache%"
-- add driver parameters
grtV.insert(driver.parameters, __RdbmsInfo_lua.getDriverParameter(owner, "instance", "Instance:",
"MaxDB Instance", "string", 1, 218, "", 0, 1))
__RdbmsInfo_lua.addDriverParamDefaults(driver, driver.parameters, 2, "7210")
-- advanced parameters
-- TODO: check which of these are actually needed
grtV.insert(driver.parameters, __RdbmsInfo_lua.getDriverParameter(owner, "sqlmode", "SQL mode",
"SQL mode. Possible values are ORACLE | INTERNAL.", "string", -1, 218, "INTERNAL", 1, 0))
grtV.insert(driver.parameters, __RdbmsInfo_lua.getDriverParameter(owner, "cachelimit", "Cache limit",
"Cache limit of the connection.", "int", -1, 218, "32", 1, 0))
grtV.insert(driver.parameters, __RdbmsInfo_lua.getDriverParameter(owner, "timeout", "Command timeout",
"Command timeout of the connection in seconds.", "int", -1, 218, "0", 1, 0))
grtV.insert(driver.parameters, __RdbmsInfo_lua.getDriverParameter(owner, "isolation", "Isolation level",
"Isolation level of the connection. One of: TRANSACTION_READ_UNCOMMITTED, TRANSACTION_READ_COMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE.", "string", -1, 218, "TRANSACTION_SERIALIZABLE", 1, 0))
grtV.insert(driver.parameters, __RdbmsInfo_lua.getDriverParameter(owner, "autocommit", "Autocommit mode",
"Possible values are: on, off. on: A COMMIT is performed after every command. off: Transactions must be controlled with the methods commit() and rollback().", "string", -1, 218, "on", 1, 0))
grtV.insert(driver.parameters, __RdbmsInfo_lua.getDriverParameter(owner, "reconnect", "Reconnect mode",
"Possible values are: on, off. on: The system automatically reconnects to the database instance after a command timeout. off: There is no automatic new connection.,", "string", -1, 218, "on", 1, 0))
-- grtV.insert(driver.parameters, __RdbmsInfo_lua.getDriverParameter(owner, "trace", "Trace file",
-- "Name and location of a debug trace file", "string", -1, 218, "", 1, 0))
-- grtV.insert(driver.parameters, __RdbmsInfo_lua.getDriverParameter(owner, "tracesize", "Trace size limit",
-- "Maximum number of lines in the file for the debug output. If this number is exceeded, the content of the file is overwritten cyclically", "int", -1, 218, "", 1, 0))
grtV.insert(driver.parameters, __RdbmsInfo_lua.getDriverParameter(owner, "cache", "Cache size",
"Enables caching of some prepared statement informations. Possible value: all or a combinations of s,i,u and d.", "string", -1, 218, "all", 1, 0))
grtV.insert(driver.parameters, __RdbmsInfo_lua.getDriverParameter(owner, "cachelimit", "Cache limit",
"Cache limit of the connection", "int", -1, 218, "32", 1, 0))
-- TODO: unicode flag missing
driver.defaultModules=
{
ReverseEngineeringModule= "ReverseEngineeringMaxdb",
MigrationModule= "MigrationMaxdb",
TransformationModule= ""
}
if grt.moduleExists("BaseJava") then
driver.isInstalled= grt.getRes(BaseJava:javaClassExists(driver.className))
else
driver.isInstalled= false
end
return driver
end
|