01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License"); you may not use this file except in
05: * compliance with the License. You may obtain a copy of the License at
06: *
07: * http://www.opensource.org/licenses/ecl1.php
08: *
09: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS
10: * IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
11: * language governing permissions and limitations under the License.
12: */
13: package org.kuali.core.dao.jdbc;
14:
15: import org.kuali.core.dbplatform.KualiDBPlatform;
16: import org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport;
17:
18: /**
19: * This class is responsible for low level DB operations that are currently commonly implementable for the DB platforms Kuali
20: * supports.
21: */
22: public abstract class KualiDBPlatformBase extends SimpleJdbcDaoSupport
23: implements KualiDBPlatform {
24: public String getCreateTableFromTableSql(String createTableName,
25: String fromTableName) {
26: return new StringBuffer("create table ")
27: .append(createTableName).append(" as select * from ")
28: .append(fromTableName).toString();
29: }
30:
31: public String getTruncateTableSql(String tableName) {
32: return "truncate table " + tableName;
33: }
34:
35: public String getInsertDataFromTableSql(String restoreTableName,
36: String fromTableName) {
37: return new StringBuffer("insert into ")
38: .append(restoreTableName).append(" select * from ")
39: .append(fromTableName).toString();
40: }
41:
42: public String getDropTableSql(String tableName) {
43: return new StringBuffer("drop table ").append(tableName)
44: .toString();
45: }
46:
47: /**
48: * Returns an expression equivalent to oracle's NVL statement using the CASE and IS NULL expressions, which should
49: * be supported by many database systems
50: *
51: * @see org.kuali.core.dbplatform.KualiDBPlatform#getIsNullFunction(java.lang.String, java.lang.String)
52: */
53: public String getIsNullFunction(String exprToTest,
54: String exprToReplaceIfTestExprNull) {
55: return new StringBuilder(" case when ").append(exprToTest)
56: .append(" is null then ").append(
57: exprToReplaceIfTestExprNull).append(" else ")
58: .append(exprToTest).append(" end ").toString();
59: }
60: }
|