| 1 |
|
package org.apache.torque.engine.platform; |
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
| 22 |
|
import java.sql.Connection; |
| 23 |
|
import java.sql.DatabaseMetaData; |
| 24 |
|
import java.sql.ResultSet; |
| 25 |
|
import java.sql.SQLException; |
| 26 |
|
import java.util.ArrayList; |
| 27 |
|
import java.util.HashMap; |
| 28 |
|
import java.util.Iterator; |
| 29 |
|
import java.util.List; |
| 30 |
|
import java.util.Map; |
| 31 |
|
|
| 32 |
|
import org.apache.commons.lang.StringUtils; |
| 33 |
|
import org.apache.torque.engine.database.model.Domain; |
| 34 |
|
import org.apache.torque.engine.database.model.SchemaType; |
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
@author |
| 40 |
|
@version |
| 41 |
|
|
|
|
|
| 0% |
Uncovered Elements: 80 (80) |
Complexity: 26 |
Complexity Density: 0.55 |
|
| 42 |
|
public class PlatformDefaultImpl implements Platform { |
| 43 |
|
private Map<SchemaType, Domain> schemaDomainMap; |
| 44 |
|
|
| 45 |
|
|
| 46 |
|
|
| 47 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 48 |
0
|
public PlatformDefaultImpl() {... |
| 49 |
0
|
initialize(); |
| 50 |
|
} |
| 51 |
|
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
| 52 |
0
|
private void initialize() {... |
| 53 |
0
|
schemaDomainMap = new HashMap<SchemaType, Domain>(30); |
| 54 |
0
|
Iterator<SchemaType> iter = SchemaType.iterator(); |
| 55 |
0
|
while (iter.hasNext()) { |
| 56 |
0
|
SchemaType type = iter.next(); |
| 57 |
0
|
schemaDomainMap.put(type, new Domain(type)); |
| 58 |
|
} |
| 59 |
0
|
schemaDomainMap.put(SchemaType.BOOLEANCHAR, new Domain(SchemaType.BOOLEANCHAR, "CHAR")); |
| 60 |
0
|
schemaDomainMap.put(SchemaType.BOOLEANINT, new Domain(SchemaType.BOOLEANINT, "INTEGER")); |
| 61 |
|
} |
| 62 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 63 |
0
|
protected void setSchemaDomainMapping(Domain domain) {... |
| 64 |
0
|
schemaDomainMap.put(domain.getType(), domain); |
| 65 |
|
} |
| 66 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 67 |
0
|
public String getServerUrl(String url) {... |
| 68 |
|
|
| 69 |
0
|
return url; |
| 70 |
|
} |
| 71 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 72 |
0
|
public String getSchemaName(String artifactId) {... |
| 73 |
0
|
String suffix = "-db"; |
| 74 |
0
|
if (artifactId.endsWith(suffix)) { |
| 75 |
0
|
int length = artifactId.length(); |
| 76 |
0
|
artifactId = artifactId.substring(0, length - suffix.length()); |
| 77 |
|
} |
| 78 |
0
|
return StringUtils.remove(artifactId, "-"); |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
|
| 82 |
|
@see |
| 83 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 84 |
0
|
public int getMaxColumnNameLength() {... |
| 85 |
0
|
return 64; |
| 86 |
|
} |
| 87 |
|
|
| 88 |
|
|
| 89 |
|
@see |
| 90 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 91 |
0
|
public String getNativeIdMethod() {... |
| 92 |
0
|
return Platform.IDENTITY; |
| 93 |
|
} |
| 94 |
|
|
| 95 |
|
|
| 96 |
|
@see |
| 97 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 98 |
0
|
public Domain getDomainForSchemaType(SchemaType jdbcType) {... |
| 99 |
0
|
return schemaDomainMap.get(jdbcType); |
| 100 |
|
} |
| 101 |
|
|
| 102 |
|
|
| 103 |
|
@return |
| 104 |
|
@see |
| 105 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 106 |
0
|
public String getNullString(boolean notNull) {... |
| 107 |
|
|
| 108 |
|
|
| 109 |
0
|
return (notNull ? "NOT NULL" : ""); |
| 110 |
|
} |
| 111 |
|
|
| 112 |
|
|
| 113 |
|
@see |
| 114 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 115 |
0
|
public String getAutoIncrement() {... |
| 116 |
0
|
return "IDENTITY"; |
| 117 |
|
} |
| 118 |
|
|
| 119 |
|
|
| 120 |
|
@see |
| 121 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 122 |
0
|
public boolean hasScale(String sqlType) {... |
| 123 |
0
|
return true; |
| 124 |
|
} |
| 125 |
|
|
| 126 |
|
|
| 127 |
|
@see |
| 128 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 129 |
0
|
public boolean hasSize(String sqlType) {... |
| 130 |
0
|
return true; |
| 131 |
|
} |
| 132 |
|
|
| 133 |
|
|
| 134 |
|
@see |
| 135 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 136 |
0
|
public boolean createNotNullBeforeAutoincrement() {... |
| 137 |
0
|
return true; |
| 138 |
|
} |
| 139 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 140 |
0
|
public String filterInvalidDefaultValues(String defaultValue) {... |
| 141 |
0
|
return defaultValue; |
| 142 |
|
} |
| 143 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 144 |
0
|
public boolean isSpecialDefault(String defaultValue) {... |
| 145 |
0
|
return false; |
| 146 |
|
} |
| 147 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 148 |
0
|
public Long getSequenceNextVal(Connection con, String schema, String sequenceName) {... |
| 149 |
0
|
throw new UnsupportedOperationException("getSequenceDefinition"); |
| 150 |
|
} |
| 151 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 152 |
0
|
public String getViewDefinition(Connection con, String schema, String viewName) {... |
| 153 |
0
|
throw new UnsupportedOperationException("getViewDefinition"); |
| 154 |
|
} |
| 155 |
|
|
| 156 |
|
|
| 157 |
|
|
| 158 |
|
|
| 159 |
|
@param |
| 160 |
|
|
| 161 |
|
@param |
| 162 |
|
|
| 163 |
|
@return |
| 164 |
|
@throws |
| 165 |
|
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
| 166 |
0
|
public List<String> getPrimaryKeys(DatabaseMetaData dbMeta, String dbSchema, String tableName) throws SQLException {... |
| 167 |
0
|
List<String> pk = new ArrayList<String>(); |
| 168 |
0
|
ResultSet parts = null; |
| 169 |
0
|
try { |
| 170 |
0
|
parts = dbMeta.getPrimaryKeys(null, dbSchema, tableName); |
| 171 |
0
|
while (parts.next()) { |
| 172 |
0
|
pk.add(parts.getString(4)); |
| 173 |
|
} |
| 174 |
|
} finally { |
| 175 |
0
|
if (parts != null) { |
| 176 |
0
|
parts.close(); |
| 177 |
|
} |
| 178 |
|
} |
| 179 |
0
|
return pk; |
| 180 |
|
} |
| 181 |
|
|
| 182 |
|
|
| 183 |
|
|
| 184 |
|
|
| 185 |
|
@param |
| 186 |
|
|
| 187 |
|
@return |
| 188 |
|
@throws |
| 189 |
|
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 3 |
Complexity Density: 0.27 |
|
| 190 |
0
|
public List<String> getTableNames(DatabaseMetaData dbMeta, String databaseSchema) throws SQLException {... |
| 191 |
|
|
| 192 |
0
|
List<String> tables = new ArrayList<String>(); |
| 193 |
0
|
ResultSet tableNames = null; |
| 194 |
|
|
| 195 |
0
|
String[] types = { "TABLE" }; |
| 196 |
0
|
try { |
| 197 |
0
|
tableNames = dbMeta.getTables(null, databaseSchema, null, types); |
| 198 |
0
|
while (tableNames.next()) { |
| 199 |
0
|
String name = tableNames.getString(3); |
| 200 |
0
|
tables.add(name); |
| 201 |
|
} |
| 202 |
|
} finally { |
| 203 |
0
|
if (tableNames != null) { |
| 204 |
0
|
tableNames.close(); |
| 205 |
|
} |
| 206 |
|
} |
| 207 |
|
|
| 208 |
0
|
return tables; |
| 209 |
|
} |
| 210 |
|
} |