removed DBMS enum

git-svn-id: https://svn.code.sf.net/p/jailer/code/trunk@1220 3dd849cd-670e-4645-a7cd-dd197c8d0e81
This commit is contained in:
rwisser
2017-04-26 05:17:09 +00:00
parent cb646c1bda
commit 97c2c4cfbf
18 changed files with 152 additions and 63 deletions
+8 -8
View File
@@ -14,7 +14,7 @@ available targets:
<property name="TEST_DIR" location="${BUILD_DIR}/test/classes" />
<property name="SRC_DIR" location="src" />
<property name="JAR" location="jailer.jar" />
<property name="JAR-SUBSETTER" location="jailer-subsetter.jar" />
<property name="JAR-ENGINE" location="jailer-engine.jar" />
<property name="TEST_BASE_DIR" location="src/test" />
<property file="src/test/test.properties"/>
@@ -34,10 +34,10 @@ available targets:
<delete dir="${BUILD_DIR}" />
</target>
<target name="compile-subsetter" depends="clean">
<target name="compile-engine" depends="clean">
<delete file="${JAR}" />
<mkdir dir="${COMPILE_DIR}" />
<javac destdir="${COMPILE_DIR}" srcdir="${SRC_DIR}/main/subsetter" debug="on" deprecation="off" encoding="ISO-8859-1">
<javac destdir="${COMPILE_DIR}" srcdir="${SRC_DIR}/main/engine" debug="on" deprecation="off" encoding="ISO-8859-1">
<classpath>
<path refid="default.classpath" />
</classpath>
@@ -45,7 +45,7 @@ available targets:
</javac>
</target>
<target name="compile-gui" depends="compile-subsetter">
<target name="compile-gui" depends="compile-engine">
<delete file="${JAR}" />
<mkdir dir="${COMPILE_DIR}" />
<javac destdir="${COMPILE_DIR}" srcdir="${SRC_DIR}/main/gui" debug="on" deprecation="off" encoding="ISO-8859-1">
@@ -61,8 +61,8 @@ available targets:
</copy>
</target>
<target name="package-subsetter" depends="compile-subsetter">
<jar destfile="${JAR-SUBSETTER}" basedir="${COMPILE_DIR}">
<target name="package-engine" depends="compile-engine">
<jar destfile="${JAR-ENGINE}" basedir="${COMPILE_DIR}">
<manifest>
<attribute name="Main-Class" value="net.sf.jailer.Jailer" />
<attribute name="Class-Path" value="lib/log4j.jar lib/args4j.jar config/" />
@@ -70,7 +70,7 @@ available targets:
</jar>
</target>
<target name="package" depends="package-subsetter,compile-gui">
<target name="package" depends="package-engine,compile-gui">
<jar destfile="${JAR}" basedir="${COMPILE_DIR}">
<manifest>
<attribute name="Main-Class" value="net.sf.jailer.ui.ExtractionModelFrame" />
@@ -79,7 +79,7 @@ available targets:
</jar>
</target>
<target name="compile-test" depends="compile-subsetter">
<target name="compile-test" depends="compile-engine">
<mkdir dir="${TEST_DIR}" />
<javac destdir="${TEST_DIR}" srcdir="${SRC_DIR}/test" debug="on" deprecation="off" encoding="ISO-8859-1">
<classpath>
+1 -1
View File
@@ -12,6 +12,6 @@ set CP=%CP%;%LIB%\junit.jar
set CP=%CP%;%LIB%\log4j.jar
set CP=%CP%;%LIB%\args4j.jar
set CP=%CP%;%LIB%\sdoc-0.5.0-beta.jar
set CP=%CP%;jailer-subsetter.jar
set CP=%CP%;jailer-engine.jar
java -Xmx1024M -cp %CP% net.sf.jailer.Jailer %*
+1 -1
View File
@@ -17,6 +17,6 @@ CP=$CP:$LIB/junit.jar
CP=$CP:$LIB/log4j.jar
CP=$CP:$LIB/args4j.jar
CP=$CP:$LIB/sdoc-0.5.0-beta.jar
CP=$CP:jailer-subsetter.jar
CP=$CP:jailer-engine.jar
java -Xmx1024M -cp $CP net.sf.jailer.Jailer "$@"
@@ -225,7 +225,10 @@ public class DDLCreator {
private DBMS targetDBMS(Session session) {
if (session == null) {
executionContext.getTargetDBMS();
if (executionContext.getTargetDBMS() != null) {
return executionContext.getTargetDBMS();
}
return DBMS.forJdbcUrl(""); // default
}
return DBMS.forSession(session);
}
@@ -709,7 +709,7 @@ public class SubsettingEngine {
}
});
String nullExpression = "null";
if (session.dbms == DBMS.POSTGRESQL && scriptFormat == ScriptFormat.INTRA_DATABASE) {
if (DBMS.POSTGRESQL.equals(session.dbms) && scriptFormat == ScriptFormat.INTRA_DATABASE) {
nullExpression += "::" + column.type;
}
column.setFilter(new Filter(nullExpression, null, false, null));
@@ -62,6 +62,62 @@ public class DBMS {
return Configuration.getInstance().getDBMS().toArray(new DBMS[0]);
}
/**
* Default constructor.
*/
public DBMS() {
}
/**
* Copy constructor.
*/
public DBMS(DBMS other) {
this.id = other.id;
this.displayName = other.displayName;
this.urlPattern = other.urlPattern;
this.testQuery = other.testQuery;
this.statisticRenovator = other.statisticRenovator;
this.typeReplacement = other.typeReplacement;
this.stringLiteralEscapeSequences = other.stringLiteralEscapeSequences;
this.sqlLimitSuffix = other.sqlLimitSuffix;
this.varcharLengthLimit = other.varcharLengthLimit;
this.tableProperties = other.tableProperties;
this.charToEscapeSequence = other.charToEscapeSequence;
this.keysOfCharToEscapeSequence = other.keysOfCharToEscapeSequence;
this.ncharPrefix = other.ncharPrefix;
this.exportBlocks = other.exportBlocks;
this.identityInserts = other.identityInserts;
this.appendNanosToTimestamp = other.appendNanosToTimestamp;
this.appendMillisToTimestamp = other.appendMillisToTimestamp;
this.useToTimestampFunction = other.useToTimestampFunction;
this.timestampFormat = other.timestampFormat;
this.emptyCLOBValue = other.emptyCLOBValue;
this.emptyNCLOBValue = other.emptyNCLOBValue;
this.emptyBLOBValue = other.emptyBLOBValue;
this.toBlob = other.toBlob;
this.toClob = other.toClob;
this.toNClob = other.toNClob;
this.embeddedLobSizeLimit = other.embeddedLobSizeLimit;
this.binaryPattern = other.binaryPattern;
this.avoidLeftJoin = other.avoidLeftJoin;
this.timestampPattern = other.timestampPattern;
this.sqlDialect = other.sqlDialect;
this.rowidName = other.rowidName;
this.supportsSchemasInIndexDefinitions = other.supportsSchemasInIndexDefinitions;
this.useInlineViewsInDataBrowser = other.useInlineViewsInDataBrowser;
this.virtualColumnsQuery = other.virtualColumnsQuery;
this.userDefinedColumnsQuery = other.userDefinedColumnsQuery;
this.importedKeysQuery = other.importedKeysQuery;
this.primaryKeysQuery = other.primaryKeysQuery;
this.indexInfoQuery = other.indexInfoQuery;
this.identifierQuoteString = other.identifierQuoteString;
this.rowidType = other.rowidType;
this.sessionTemporaryTableManager = other.sessionTemporaryTableManager;
this.transactionTemporaryTableManager = other.transactionTemporaryTableManager;
this.jdbcProperties = other.jdbcProperties;
this.nullableContraint = other.nullableContraint;
}
/**
* Gets DBMS specific configuration.
@@ -896,4 +952,37 @@ public class DBMS {
this.displayName = displayName;
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return id == null ? 0 : id.hashCode();
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
DBMS other = (DBMS) obj;
if (id == null) {
if (other.id != null) {
return false;
}
} else if (!id.equals(other.id)) {
return false;
}
return true;
}
}
@@ -36,7 +36,6 @@ import java.util.Set;
import net.sf.jailer.ExecutionContext;
import net.sf.jailer.TransformerFactory;
import net.sf.jailer.configuration.Configuration;
import net.sf.jailer.configuration.DBMS;
import net.sf.jailer.database.Session.AbstractResultSetReader;
import net.sf.jailer.database.Session.ResultSetReader;
@@ -239,7 +238,7 @@ public class DMLTransformer extends AbstractResultSetReader {
this.table = table;
this.scriptFileWriter = scriptFileWriter;
this.currentDialect = targetDBMSConfiguration.getSqlDialect();
this.insertStatementBuilder = new StatementBuilder(currentDialect.isSupportsMultiRowInserts() || targetDBMSConfiguration == DBMS.ORACLE || targetDBMSConfiguration == DBMS.SQLITE? maxBodySize : 1);
this.insertStatementBuilder = new StatementBuilder(currentDialect.isSupportsMultiRowInserts() || DBMS.ORACLE.equals(targetDBMSConfiguration) || DBMS.SQLITE.equals(targetDBMSConfiguration)? maxBodySize : 1);
this.quoting = createQuoting(session);
this.importFilterTransformer = importFilterTransformer;
if (targetDBMSConfiguration != null && targetDBMSConfiguration != DBMS.forSession(session)) {
@@ -281,7 +280,7 @@ public class DMLTransformer extends AbstractResultSetReader {
String mdColumnLabel = quoting.quote(getMetaData(resultSet).getColumnLabel(i));
int mdColumnType = getMetaData(resultSet).getColumnType(i);
if ((mdColumnType == Types.BLOB || mdColumnType == Types.CLOB || mdColumnType == Types.NCLOB || mdColumnType == Types.SQLXML) && targetDBMSConfiguration != DBMS.SQLITE) {
if ((mdColumnType == Types.BLOB || mdColumnType == Types.CLOB || mdColumnType == Types.NCLOB || mdColumnType == Types.SQLXML) && !DBMS.SQLITE.equals(targetDBMSConfiguration)) {
tableHasLobs = true;
isLobColumn[i] = true;
lobColumnIndexes.add(i);
@@ -360,11 +359,11 @@ public class DMLTransformer extends AbstractResultSetReader {
content = null;
}
String cVal = convertToSql(cellContentConverter, resultSet, i, content);
if (targetDBMSConfiguration == DBMS.POSTGRESQL && (content instanceof Date || content instanceof Timestamp)) {
if (DBMS.POSTGRESQL.equals(targetDBMSConfiguration) && (content instanceof Date || content instanceof Timestamp)) {
// explicit cast needed
cVal = "timestamp " + cVal;
}
if (targetDBMSConfiguration == DBMS.POSTGRESQL) {
if (DBMS.POSTGRESQL.equals(targetDBMSConfiguration)) {
// explicit cast needed
int mdColumnType = getMetaData(resultSet).getColumnType(i);
if (mdColumnType == Types.TIME) {
@@ -527,21 +526,21 @@ public class DMLTransformer extends AbstractResultSetReader {
}
}
} else {
if (targetDBMSConfiguration == DBMS.DB2_ZOS && maxBodySize > 1) {
if (DBMS.DB2_ZOS.equals(targetDBMSConfiguration) && maxBodySize > 1) {
String insertSchema = "Insert into " + qualifiedTableName(table) + "(" + labelCSL + ") ";
String item = "\n Select " + valueList + " From sysibm.sysdummy1";
if (!insertStatementBuilder.isAppendable(insertSchema, item)) {
writeToScriptFile(insertStatementBuilder.build(), true);
}
insertStatementBuilder.append(insertSchema, item, " Union all ", ";\n");
} else if (targetDBMSConfiguration == DBMS.ORACLE && maxBodySize > 1) {
} else if (DBMS.ORACLE.equals(targetDBMSConfiguration) && maxBodySize > 1) {
String insertSchema = "Insert into " + qualifiedTableName(table) + "(" + labelCSL + ") ";
String item = "\n Select " + valueList + " From DUAL";
if (!insertStatementBuilder.isAppendable(insertSchema, item)) {
writeToScriptFile(insertStatementBuilder.build(), true);
}
insertStatementBuilder.append(insertSchema, item, " Union all ", ";\n");
} else if (targetDBMSConfiguration == DBMS.SQLITE && maxBodySize > 1) {
} else if (DBMS.SQLITE.equals(targetDBMSConfiguration) && maxBodySize > 1) {
String insertSchema = "Insert into " + qualifiedTableName(table) + "(" + labelCSL + ") ";
String item = "\n Select " + valueList + " ";
if (!insertStatementBuilder.isAppendable(insertSchema, item)) {
@@ -794,7 +793,7 @@ public class DMLTransformer extends AbstractResultSetReader {
identityInsertTable = table;
}
}
if (wrap && targetDBMSConfiguration == DBMS.ORACLE) {
if (wrap && DBMS.ORACLE.equals(targetDBMSConfiguration)) {
scriptFileWriter.write(SqlUtil.splitDMLStatement(content, 2400));
} else {
scriptFileWriter.write(content);
@@ -22,7 +22,6 @@ import java.sql.SQLException;
import net.sf.jailer.ExecutionContext;
import net.sf.jailer.TransformerFactory;
import net.sf.jailer.configuration.Configuration;
import net.sf.jailer.configuration.DBMS;
import net.sf.jailer.database.Session.AbstractResultSetReader;
import net.sf.jailer.database.Session.ResultSetReader;
@@ -159,7 +158,7 @@ public class DeletionTransformer extends AbstractResultSetReader {
final SQLDialect currentDialect = targetDBMSConfiguration.getSqlDialect();
CellContentConverter cellContentConverter = getCellContentConverter(resultSet, session, targetDBMSConfiguration);
if (targetDBMSConfiguration == DBMS.SYBASE || (currentDialect != null && !currentDialect.isSupportsInClauseForDeletes())) {
if (DBMS.SYBASE.equals(targetDBMSConfiguration) || (currentDialect != null && !currentDialect.isSupportsInClauseForDeletes())) {
String deleteHead = "Delete from " + qualifiedTableName(table) + " Where (";
boolean firstTime = true;
String item = "";
@@ -226,7 +225,7 @@ public class DeletionTransformer extends AbstractResultSetReader {
*/
private void writeToScriptFile(String content) throws IOException {
synchronized (scriptFileWriter) {
if (targetDBMSConfiguration == DBMS.ORACLE) {
if (DBMS.ORACLE.equals(targetDBMSConfiguration)) {
scriptFileWriter.write(SqlUtil.splitDMLStatement(content, 2400));
} else {
scriptFileWriter.write(content);
@@ -30,7 +30,6 @@ import java.util.Map;
import java.util.Set;
import net.sf.jailer.ExecutionContext;
import net.sf.jailer.configuration.Configuration;
import net.sf.jailer.configuration.DBMS;
import net.sf.jailer.database.Session.AbstractResultSetReader;
import net.sf.jailer.database.Session.ResultSetReader;
@@ -246,11 +245,11 @@ public class UpdateTransformer extends AbstractResultSetReader {
content = null;
}
String cVal = convertToSql(cellContentConverter, resultSet, i, content);
if (targetDBMSConfiguration == DBMS.POSTGRESQL && (content instanceof Date || content instanceof Timestamp)) {
if (DBMS.POSTGRESQL.equals(targetDBMSConfiguration) && (content instanceof Date || content instanceof Timestamp)) {
// explicit cast needed
cVal = "timestamp " + cVal;
}
if (targetDBMSConfiguration == DBMS.POSTGRESQL) {
if (DBMS.POSTGRESQL.equals(targetDBMSConfiguration)) {
// explicit cast needed
int mdColumnType = getMetaData(resultSet).getColumnType(i);
if (mdColumnType == Types.TIME) {
@@ -432,7 +431,7 @@ public class UpdateTransformer extends AbstractResultSetReader {
*/
private void writeToScriptFile(String content, boolean wrap) throws IOException {
synchronized (scriptFileWriter) {
if (wrap && targetDBMSConfiguration == DBMS.ORACLE) {
if (wrap && DBMS.ORACLE.equals(targetDBMSConfiguration)) {
scriptFileWriter.write(SqlUtil.splitDMLStatement(content, 2400));
} else {
scriptFileWriter.write(content);
@@ -46,8 +46,8 @@ import net.sf.jailer.extractionmodel.ExtractionModel;
import net.sf.jailer.extractionmodel.ExtractionModel.AdditionalSubject;
import net.sf.jailer.restrictionmodel.RestrictionModel;
import net.sf.jailer.util.CsvFile;
import net.sf.jailer.util.LayoutStorage;
import net.sf.jailer.util.CsvFile.LineFilter;
import net.sf.jailer.util.LayoutStorage;
import net.sf.jailer.util.PrintUtil;
import net.sf.jailer.util.SqlUtil;
@@ -230,7 +230,7 @@ public class FlatXMLTransformer extends AbstractResultSetReader {
if (type == null) {
try {
type = getMetaData(resultSet).getColumnType(i);
if (dbms == DBMS.ORACLE) {
if (DBMS.ORACLE.equals(dbms)) {
if (type == Types.DATE) {
type = Types.TIMESTAMP;
}
@@ -140,7 +140,7 @@ public class IntraDatabaseEntityGraph extends RemoteEntityGraph {
private ResultSet getPrimaryKeys(Session session,
DatabaseMetaData metaData, String schema, String table)
throws SQLException {
if (session.dbms == DBMS.MySQL) {
if (DBMS.MySQL.equals(session.dbms)) {
return metaData.getPrimaryKeys(schema, null, table);
}
return metaData.getPrimaryKeys(null, schema, table);
@@ -1231,7 +1231,7 @@ public class LocalEntityGraph extends EntityGraph {
public void markDependentEntitiesAsTraversed(Association association, ResultSet resultSet, ResultSetMetaData resultSetMetaData, Map<String, Integer> typeCache) throws SQLException {
String update;
CellContentConverter cellContentConverter = new CellContentConverter(resultSetMetaData, localSession, DBMS.forSession(localSession));
if (localSession.dbms == DBMS.SYBASE) {
if (DBMS.SYBASE.equals(localSession.dbms)) {
update = "Update " + dmlTableReference(DEPENDENCY, localSession) + " set traversed=1" +
" Where " + pkEqualsEntityID(association.source, resultSet, dmlTableReference(DEPENDENCY, localSession), "FROM_", cellContentConverter) +
" and " + dmlTableReference(DEPENDENCY, localSession) + ".from_type=" + typeName(association.source) + " and assoc=" + association.getId() +
@@ -371,10 +371,10 @@ public class RemoteEntityGraph extends EntityGraph {
}
String insert = "Insert into " + dmlTableReference(ENTITY, session) + " (r_entitygraph, " + upkColumnList(table, null) + ", birthday, type" + (source == null || !explain? "" : ", association, PRE_TYPE, " + upkColumnList(source, "PRE_")) + ") " + select;
if (session.dbms == DBMS.SYBASE) session.execute("set forceplan on ");
if (DBMS.SYBASE.equals(session.dbms)) session.execute("set forceplan on ");
long rc = session.executeUpdate(insert);
totalRowcount += rc;
if (session.dbms == DBMS.SYBASE) session.execute("set forceplan off ");
if (DBMS.SYBASE.equals(session.dbms)) session.execute("set forceplan off ");
return rc;
}
@@ -890,7 +890,7 @@ public class RemoteEntityGraph extends EntityGraph {
public void markDependentEntitiesAsTraversed(Association association, ResultSet resultSet, ResultSetMetaData resultSetMetaData, Map<String, Integer> typeCache) throws SQLException {
String update;
CellContentConverter cellContentConverter = new CellContentConverter(resultSetMetaData, session, DBMS.forSession(session));
if (session.dbms == DBMS.SYBASE) {
if (DBMS.SYBASE.equals(session.dbms)) {
update = "Update " + dmlTableReference(DEPENDENCY, session) + " set traversed=1" +
" Where " + pkEqualsEntityID(association.source, resultSet, dmlTableReference(DEPENDENCY, session), "FROM_", cellContentConverter) +
" and " + dmlTableReference(DEPENDENCY, session) + ".from_type=" + typeName(association.source) + " and assoc=" + association.getId() +
@@ -132,9 +132,9 @@ public class JDBCMetaDataBasedModelElementFinder implements ModelElementFinder {
}
Map<String, Association> fkMap = new HashMap<String, Association>();
while (resultSet.next()) {
Table pkTable = dataModel.getTable(toQualifiedTableName(quoting.quote(defaultSchema), quoting.quote(resultSet.getString(session.dbms == DBMS.MySQL? 1 : 2)), quoting.quote(resultSet.getString(3))));
Table pkTable = dataModel.getTable(toQualifiedTableName(quoting.quote(defaultSchema), quoting.quote(resultSet.getString(DBMS.MySQL.equals(session.dbms)? 1 : 2)), quoting.quote(resultSet.getString(3))));
String pkColumn = quoting.quote(resultSet.getString(4));
Table fkTable = dataModel.getTable(toQualifiedTableName(quoting.quote(defaultSchema), quoting.quote(resultSet.getString(session.dbms == DBMS.MySQL? 5 : 6)), quoting.quote(resultSet.getString(7))));
Table fkTable = dataModel.getTable(toQualifiedTableName(quoting.quote(defaultSchema), quoting.quote(resultSet.getString(DBMS.MySQL.equals(session.dbms)? 5 : 6)), quoting.quote(resultSet.getString(7))));
String fkColumn = quoting.quote(resultSet.getString(8));
String foreignKey = resultSet.getString(12);
if (fkTable != null) {
@@ -171,7 +171,7 @@ public class JDBCMetaDataBasedModelElementFinder implements ModelElementFinder {
if (resultSet != null) {
return resultSet;
}
if (session.dbms == DBMS.MySQL) {
if (DBMS.MySQL.equals(session.dbms)) {
return metaData.getImportedKeys(schema, null, table);
}
return metaData.getImportedKeys(null, schema, table);
@@ -213,7 +213,7 @@ public class JDBCMetaDataBasedModelElementFinder implements ModelElementFinder {
if (isValidName(tableName)) {
tableName = quoting.quote(tableName);
if (executionContext.getQualifyNames()) {
String schemaName = resultSet.getString(session.dbms == DBMS.MySQL? 1 : 2);
String schemaName = resultSet.getString(DBMS.MySQL.equals(session.dbms)? 1 : 2);
if (schemaName != null) {
schemaName = quoting.quote(schemaName.trim());
if (schemaName.length() > 0) {
@@ -244,7 +244,7 @@ public class JDBCMetaDataBasedModelElementFinder implements ModelElementFinder {
while (resultSet.next()) {
hasPK = true;
int keySeq = resultSet.getInt(5);
if (session.dbms == DBMS.SQLITE) {
if (DBMS.SQLITE.equals(session.dbms)) {
// SQlite driver doesn't return the keySeq
keySeq = nextKeySeq++;
}
@@ -347,14 +347,14 @@ public class JDBCMetaDataBasedModelElementFinder implements ModelElementFinder {
if (resultSet != null) {
return resultSet;
}
if (session.dbms == DBMS.MySQL) {
if (DBMS.MySQL.equals(session.dbms)) {
return metaData.getPrimaryKeys(schema, null, table);
}
return metaData.getPrimaryKeys(null, schema, table);
}
private ResultSet getTables(Session session, DatabaseMetaData metaData, String schemaPattern, String tableNamePattern, String[] types) throws SQLException {
if (session.dbms == DBMS.MySQL) {
if (DBMS.MySQL.equals(session.dbms)) {
return metaData.getTables(schemaPattern, null, tableNamePattern, types);
}
return metaData.getTables(null, schemaPattern, tableNamePattern, types);
@@ -464,7 +464,7 @@ public class JDBCMetaDataBasedModelElementFinder implements ModelElementFinder {
if (resultSet != null) {
return resultSet;
}
if (session.dbms == DBMS.MySQL) {
if (DBMS.MySQL.equals(session.dbms)) {
return metaData.getIndexInfo(schema, null, table, unique, approximate);
}
return metaData.getIndexInfo(null, schema, table, unique, approximate);
@@ -484,7 +484,7 @@ public class JDBCMetaDataBasedModelElementFinder implements ModelElementFinder {
if (resultSet != null) {
return resultSet;
}
if (session.dbms == DBMS.MySQL) {
if (DBMS.MySQL.equals(session.dbms)) {
return metaData.getColumns(schemaPattern, null, tableNamePattern, columnNamePattern);
}
try {
@@ -524,11 +524,11 @@ public class JDBCMetaDataBasedModelElementFinder implements ModelElementFinder {
List<String> schemas = new ArrayList<String>();
try {
DatabaseMetaData metaData = session.getMetaData();
ResultSet rs = session.dbms == DBMS.MySQL? metaData.getCatalogs() : metaData.getSchemas();
ResultSet rs = DBMS.MySQL.equals(session.dbms)? metaData.getCatalogs() : metaData.getSchemas();
while (rs.next()) {
String schema = rs.getString(session.dbms == DBMS.MySQL? "TABLE_CAT" : "TABLE_SCHEM").trim();
String schema = rs.getString(DBMS.MySQL.equals(session.dbms)? "TABLE_CAT" : "TABLE_SCHEM").trim();
if (schema != null) {
if (session.dbms == DBMS.POSTGRESQL && schema.startsWith("pg_toast_temp")) {
if (DBMS.POSTGRESQL.equals(session.dbms) && schema.startsWith("pg_toast_temp")) {
continue;
}
schemas.add(schema);
@@ -552,7 +552,7 @@ public class JDBCMetaDataBasedModelElementFinder implements ModelElementFinder {
* @param userName schema with this name may be empty
*/
public static String getDefaultSchema(Session session, String userName) {
if (session.dbms == DBMS.MySQL) {
if (DBMS.MySQL.equals(session.dbms)) {
try {
final String[] database = new String[1];
session.executeQuery("Select DATABASE()", new Session.AbstractResultSetReader() {
@@ -575,9 +575,9 @@ public class JDBCMetaDataBasedModelElementFinder implements ModelElementFinder {
String dbName = metaData.getDatabaseProductName();
boolean isPostgreSQL = dbName != null && dbName.toLowerCase().contains("PostgreSQL".toLowerCase());
boolean isH2Sql = dbName != null && dbName.toLowerCase().startsWith("H2".toLowerCase());
ResultSet rs = session.dbms == DBMS.MySQL? metaData.getCatalogs() : metaData.getSchemas();
ResultSet rs = DBMS.MySQL.equals(session.dbms)? metaData.getCatalogs() : metaData.getSchemas();
while (rs.next()) {
schemas.add(rs.getString(session.dbms == DBMS.MySQL? "TABLE_CAT" : "TABLE_SCHEM"));
schemas.add(rs.getString(DBMS.MySQL.equals(session.dbms)? "TABLE_CAT" : "TABLE_SCHEM"));
}
rs.close();
String userSchema = null;
@@ -730,7 +730,7 @@ public class JDBCMetaDataBasedModelElementFinder implements ModelElementFinder {
*/
private int filterLength(int length, String typeName, int type, DBMS dbms, int origLength) {
if (length > 0) {
if (dbms == DBMS.POSTGRESQL) {
if (DBMS.POSTGRESQL.equals(dbms)) {
if (type == Types.VARCHAR && length >= 10485760) {
length = 0;
} else if (type == Types.NUMERIC && length > 1000) {
@@ -738,11 +738,11 @@ public class JDBCMetaDataBasedModelElementFinder implements ModelElementFinder {
} else if ("bytea".equalsIgnoreCase(typeName)) {
length = 0;
}
} else if (dbms == DBMS.SQLITE) {
} else if (DBMS.SQLITE.equals(dbms)) {
return 0;
}
} else {
if (dbms == DBMS.POSTGRESQL) {
if (DBMS.POSTGRESQL.equals(dbms)) {
if ("bit".equalsIgnoreCase(typeName)) {
length = origLength;
}
@@ -761,7 +761,7 @@ public class JDBCMetaDataBasedModelElementFinder implements ModelElementFinder {
}
sqlType = sqlType.trim();
if (dbms == DBMS.MySQL) {
if (DBMS.MySQL.equals(dbms)) {
if (sqlType.equalsIgnoreCase("SET") || sqlType.equalsIgnoreCase("ENUM")) {
return "VARCHAR";
}
@@ -157,7 +157,7 @@ public class MetaDataCache {
MetaDataCache metaDataCache = new MetaDataCache();
ResultSet rs;
try {
if (session.dbms == DBMS.MySQL) {
if (DBMS.MySQL.equals(session.dbms)) {
rs = metaData.getColumns(schema, null, "%", "%");
} else {
rs = metaData.getColumns(null, schema, "%", "%");
@@ -95,7 +95,7 @@ public class CellContentConverter {
}
if (content instanceof java.sql.Date) {
String suffix = targetConfiguration == DBMS.POSTGRESQL? "::date" : "";
String suffix = DBMS.POSTGRESQL.equals(targetConfiguration)? "::date" : "";
if (targetConfiguration.isUseToTimestampFunction()) {
String format;
synchronized(defaultDateFormat) {
@@ -106,7 +106,7 @@ public class CellContentConverter {
return "'" + content + "'" + suffix;
}
if (content instanceof java.sql.Timestamp) {
String suffix = targetConfiguration == DBMS.POSTGRESQL? "::timestamp" : "";
String suffix = DBMS.POSTGRESQL.equals(targetConfiguration)? "::timestamp" : "";
if (targetConfiguration.isUseToTimestampFunction()) {
String format;
String nanoFormat;
@@ -172,7 +172,7 @@ public class CellContentConverter {
}
}
if (content instanceof UUID) {
if (targetConfiguration == DBMS.POSTGRESQL) {
if (DBMS.POSTGRESQL.equals(targetConfiguration)) {
return "'" + content + "'::uuid";
}
return "'" + content + "'";
@@ -252,12 +252,12 @@ public class CellContentConverter {
if (type == null) {
try {
type = resultSetMetaData.getColumnType(i);
if (configuration == DBMS.ORACLE) {
if (DBMS.ORACLE.equals(configuration)) {
if (type == Types.DATE) {
type = Types.TIMESTAMP;
}
}
if (configuration == DBMS.POSTGRESQL) {
if (DBMS.POSTGRESQL.equals(configuration)) {
String typeName = resultSetMetaData.getColumnTypeName(i);
if ("hstore".equalsIgnoreCase(typeName)) {
type = TYPE_HSTORE;
@@ -295,7 +295,7 @@ public class CellContentConverter {
return resultSet.getTimestamp(i);
}
if (type == Types.DATE) {
if (configuration == DBMS.MySQL) {
if (DBMS.MySQL.equals(configuration)) {
// YEAR
String typeName = resultSetMetaData.getColumnTypeName(i);
if (typeName != null && typeName.toUpperCase().equals("YEAR")) {
@@ -318,7 +318,7 @@ public class CellContentConverter {
object = new NCharWrapper((String) object);
}
}
if (configuration == DBMS.POSTGRESQL) {
if (DBMS.POSTGRESQL.equals(configuration)) {
if (type == TYPE_HSTORE) {
return new HStoreWrapper(resultSet.getString(i));
} else if (object instanceof Boolean) {
@@ -209,7 +209,7 @@ public class XmlRowWriter {
typeCachesForStringKey.put(table, typeCache);
}
type = SqlUtil.getColumnType(resultSet, resultSetMetaData, columnName, typeCache);
if ((type == Types.BLOB || type == Types.CLOB|| type == Types.NCLOB) && session.dbms != DBMS.SQLITE) {
if ((type == Types.BLOB || type == Types.CLOB|| type == Types.NCLOB) && !DBMS.SQLITE.equals(session.dbms)) {
Object object = resultSet.getObject(columnName);
if (returnNull && (object == null || resultSet.wasNull())) {
return null;