| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ANSISqlDatabasePlatform |
|
| 1.25;1.25 |
| 1 | ||
| 2 | /* | |
| 3 | * Copyright 2005-2009 The Kuali Foundation | |
| 4 | * | |
| 5 | * | |
| 6 | * Licensed under the Educational Community License, Version 2.0 (the "License"); | |
| 7 | * you may not use this file except in compliance with the License. | |
| 8 | * You may obtain a copy of the License at | |
| 9 | * | |
| 10 | * http://www.opensource.org/licenses/ecl2.php | |
| 11 | * | |
| 12 | * Unless required by applicable law or agreed to in writing, software | |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 15 | * See the License for the specific language governing permissions and | |
| 16 | * limitations under the License. | |
| 17 | */ | |
| 18 | package org.kuali.rice.core.database.platform; | |
| 19 | ||
| 20 | ||
| 21 | 0 | public abstract class ANSISqlDatabasePlatform implements DatabasePlatform |
| 22 | { | |
| 23 | /** | |
| 24 | * @see org.kuali.rice.core.database.platform.DatabasePlatform#getTruncateTableSql(String) | |
| 25 | */ | |
| 26 | public String getTruncateTableSql(String tableName) | |
| 27 | { | |
| 28 | 0 | return "truncate table " + tableName; |
| 29 | } | |
| 30 | ||
| 31 | /** | |
| 32 | * @see org.kuali.rice.core.database.platform.DatabasePlatform#getCreateTableFromTableSql(String, String) | |
| 33 | */ | |
| 34 | public String getCreateTableFromTableSql(String tableToCreate, String fromTable) | |
| 35 | { | |
| 36 | 0 | return new StringBuffer("create table ").append(tableToCreate) |
| 37 | .append(" as select * from ").append(fromTable).toString(); | |
| 38 | } | |
| 39 | ||
| 40 | /** | |
| 41 | * @see org.kuali.rice.core.database.platform.DatabasePlatform#getInsertDataFromTableSql(String, String) | |
| 42 | */ | |
| 43 | public String getInsertDataFromTableSql(String restoreTableName, String fromTableName) | |
| 44 | { | |
| 45 | 0 | return new StringBuffer("insert into ").append(restoreTableName) |
| 46 | .append(" select * from ").append(fromTableName).toString(); | |
| 47 | } | |
| 48 | ||
| 49 | /** | |
| 50 | * @see org.kuali.rice.core.database.platform.DatabasePlatform#getDropTableSql(String) | |
| 51 | */ | |
| 52 | public String getDropTableSql(String tableName) { | |
| 53 | 0 | return new StringBuffer("drop table ").append(tableName).toString(); |
| 54 | } | |
| 55 | ||
| 56 | /** | |
| 57 | * Returns an expression equivalent to oracle's NVL statement using the CASE and IS NULL expressions, which should | |
| 58 | * be supported by many database systems | |
| 59 | * | |
| 60 | * @see org.kuali.rice.core.database.platform.DatabasePlatform#getIsNullFunction(java.lang.String, java.lang.String) | |
| 61 | */ | |
| 62 | public String getIsNullFunction(String exprToTest, String exprToReplaceIfTestExprNull) { | |
| 63 | 0 | return new StringBuilder(" case when ").append(exprToTest).append(" is null then ").append(exprToReplaceIfTestExprNull) |
| 64 | .append(" else ").append(exprToTest).append(" end ").toString(); | |
| 65 | } | |
| 66 | ||
| 67 | public String getDateSQL(String date, String time) { | |
| 68 | // SQL 92 date literal syntax: | |
| 69 | // http://www.stanford.du/dept/itss/docs/oracle/9i/java.920/a96654/ref.htm#1005145 | |
| 70 | 0 | String d = date.replace('/', '-'); |
| 71 | 0 | if (time == null) { |
| 72 | 0 | return new StringBuilder("{d '").append(d).append("'}").toString(); |
| 73 | } else { | |
| 74 | 0 | return new StringBuilder("{ts '").append(d).append(" ").append(time).append("'}").toString(); |
| 75 | } | |
| 76 | } | |
| 77 | ||
| 78 | /** | |
| 79 | * @see org.kuali.rice.core.database.platform.DatabasePlatform#getUpperCaseFunction() | |
| 80 | * @return the String "UPPER" | |
| 81 | */ | |
| 82 | //chb: this was copied over from the legacy code, but is it really necessary? | |
| 83 | public String getUpperCaseFunction() { | |
| 84 | 0 | return "UPPER"; |
| 85 | } | |
| 86 | ||
| 87 | public String toString() { | |
| 88 | 0 | return "[ANSISqlDatabasePlatform]"; |
| 89 | } | |
| 90 | ||
| 91 | ||
| 92 | } |