Skip to content

Commit

Permalink
development check in
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed May 13, 2011
1 parent 35e159b commit e7c4067
Show file tree
Hide file tree
Showing 30 changed files with 413 additions and 165 deletions.
Expand Up @@ -70,7 +70,7 @@
import org.jumpmind.symmetric.core.model.Reference;
import org.jumpmind.symmetric.core.model.Table;
import org.jumpmind.symmetric.core.model.TypeMap;
import org.jumpmind.symmetric.core.sql.DbException;
import org.jumpmind.symmetric.core.sql.SqlException;

/**
* This class is a collection of Strategy methods for creating the DDL required
Expand Down Expand Up @@ -722,7 +722,7 @@ protected void processTableStructureChanges(Database currentModel, Database desi
try {
copyOfCurrentModel = (Database) currentModel.clone();
} catch (CloneNotSupportedException ex) {
throw new DbException(ex);
throw new SqlException(ex);
}

for (Iterator<Map.Entry<String, List<TableChange>>> tableChangeIt = changesPerTable
Expand Down Expand Up @@ -970,7 +970,7 @@ protected Table getTemporaryTableFor(Database targetModel, Table targetTable) {
try {
table.addColumn((Column) targetTable.getColumn(idx).clone());
} catch (CloneNotSupportedException ex) {
throw new DbException(ex);
throw new SqlException(ex);
}
}

Expand Down Expand Up @@ -1029,7 +1029,7 @@ protected Table getRealTargetTableFor(Database targetModel, Table sourceTable, T
try {
table.addColumn((Column) targetTable.getColumn(idx).clone());
} catch (CloneNotSupportedException ex) {
throw new DbException(ex);
throw new SqlException(ex);
}
}

Expand Down Expand Up @@ -1764,7 +1764,7 @@ && getPlatformInfo().hasNullDefault(column.getTypeCode())) {
}
if (column.isAutoIncrement() && !getPlatformInfo().isDefaultValueUsedForIdentitySpec()) {
if (!getPlatformInfo().isNonPKIdentityColumnsSupported() && !column.isPrimaryKey()) {
throw new DbException(
throw new SqlException(
"Column "
+ column.getName()
+ " in table "
Expand Down Expand Up @@ -1906,7 +1906,7 @@ protected void writeColumnDefaultValueStmt(Table table, Column column) {
if (parsedDefault != null) {
if (!getPlatformInfo().isDefaultValuesForLongTypesSupported()
&& ((column.getTypeCode() == Types.LONGVARBINARY) || (column.getTypeCode() == Types.LONGVARCHAR))) {
throw new DbException(
throw new SqlException(
"The platform does not support default values for LONGVARCHAR or LONGVARBINARY columns");
}
// we write empty default value strings only if the type is not a
Expand Down Expand Up @@ -2199,7 +2199,7 @@ protected void writeExternalIndicesCreateStmt(Table table) {
Index index = table.getIndex(idx);

if (!index.isUnique() && !getPlatformInfo().isIndicesSupported()) {
throw new DbException("Platform does not support non-unique indices");
throw new SqlException("Platform does not support non-unique indices");
}
writeExternalIndexCreateStmt(table, index);
}
Expand Down Expand Up @@ -2250,7 +2250,7 @@ protected void writeExternalIndexCreateStmt(Table table, Index index) {
if (col == null) {
// would get null pointer on next line anyway, so throw
// exception
throw new DbException("Invalid column '" + idxColumn.getName()
throw new SqlException("Invalid column '" + idxColumn.getName()
+ "' on index " + index.getName() + " for table "
+ table.getTableName());
}
Expand Down Expand Up @@ -2293,7 +2293,7 @@ protected void writeEmbeddedIndexCreateStmt(Table table, Index index) {
if (col == null) {
// would get null pointer on next line anyway, so throw
// exception
throw new DbException("Invalid column '" + idxColumn.getName() + "' on index "
throw new SqlException("Invalid column '" + idxColumn.getName() + "' on index "
+ index.getName() + " for table " + table.getTableName());
}
if (idx > 0) {
Expand Down
@@ -0,0 +1,22 @@
package org.jumpmind.symmetric.core.db;

import org.jumpmind.symmetric.core.model.Table;
import org.jumpmind.symmetric.core.sql.SqlException;

public class TableNotFoundException extends SqlException {

private static final long serialVersionUID = 1L;

public TableNotFoundException(String tableName) {
this(new Table(tableName));
}

public TableNotFoundException(String catalogName, String schemaName, String tableName) {
this(new Table(catalogName, schemaName, tableName));
}

public TableNotFoundException(Table table) {
super(table.getFullyQualifiedTableName());
}

}
Expand Up @@ -22,7 +22,7 @@
import org.jumpmind.symmetric.core.model.Column;
import org.jumpmind.symmetric.core.model.Database;
import org.jumpmind.symmetric.core.model.Table;
import org.jumpmind.symmetric.core.sql.DbException;
import org.jumpmind.symmetric.core.sql.SqlException;

/**
* Represents the addition of a column to a table.
Expand Down Expand Up @@ -115,7 +115,7 @@ public void apply(Database database, boolean caseSensitive) {
try {
newColumn = (Column) _newColumn.clone();
} catch (CloneNotSupportedException ex) {
throw new DbException(ex);
throw new SqlException(ex);
}

Table table = database.findTable(getChangedTable().getTableName(), caseSensitive);
Expand Down
Expand Up @@ -22,7 +22,7 @@
import org.jumpmind.symmetric.core.model.Database;
import org.jumpmind.symmetric.core.model.ForeignKey;
import org.jumpmind.symmetric.core.model.Table;
import org.jumpmind.symmetric.core.sql.DbException;
import org.jumpmind.symmetric.core.sql.SqlException;

/**
* Represents the addition of a foreign key to a table. Note that for simplicity
Expand Down Expand Up @@ -68,7 +68,7 @@ public void apply(Database database, boolean caseSensitive) {
newFK.setForeignTable(database.findTable(_newForeignKey.getForeignTableName(),
caseSensitive));
} catch (CloneNotSupportedException ex) {
throw new DbException(ex);
throw new SqlException(ex);
}
database.findTable(getChangedTable().getTableName()).addForeignKey(newFK);
}
Expand Down
Expand Up @@ -22,7 +22,7 @@
import org.jumpmind.symmetric.core.model.Database;
import org.jumpmind.symmetric.core.model.Index;
import org.jumpmind.symmetric.core.model.Table;
import org.jumpmind.symmetric.core.sql.DbException;
import org.jumpmind.symmetric.core.sql.SqlException;

/**
* Represents the addition of an index to a table.
Expand Down Expand Up @@ -64,7 +64,7 @@ public void apply(Database database, boolean caseSensitive) {
try {
newIndex = (Index) _newIndex.clone();
} catch (CloneNotSupportedException ex) {
throw new DbException(ex);
throw new SqlException(ex);
}
database.findTable(getChangedTable().getTableName(), caseSensitive).addIndex(newIndex);
}
Expand Down
Expand Up @@ -46,7 +46,7 @@
import org.jumpmind.symmetric.core.model.Index;
import org.jumpmind.symmetric.core.model.Table;
import org.jumpmind.symmetric.core.model.TypeMap;
import org.jumpmind.symmetric.core.sql.DbException;
import org.jumpmind.symmetric.core.sql.SqlException;


/**
Expand Down Expand Up @@ -246,7 +246,7 @@ protected void writeColumnDefaultValueStmt(Table table, Column column) {
if (parsedDefault != null) {
if (!getPlatformInfo().isDefaultValuesForLongTypesSupported()
&& ((column.getTypeCode() == Types.LONGVARBINARY) || (column.getTypeCode() == Types.LONGVARCHAR))) {
throw new DbException(
throw new SqlException(
"The platform does not support default values for LONGVARCHAR or LONGVARBINARY columns");
}
// we write empty default value strings only if the type is not a
Expand Down
Expand Up @@ -53,7 +53,7 @@ protected String getWrappedBlobColumnTemplate() {

@Override
protected String getInitialLoadSql() {
return "select $(columns) as ROW_DATA from $(schemaName)$(tableName) t where $(whereClause)";
return "select $(columns) as ROW_DATA, 'I' as EVENT_TYPE from $(schemaName)$(tableName) t where $(whereClause)";
}

@Override
Expand Down
Expand Up @@ -30,7 +30,7 @@

import org.jumpmind.symmetric.core.common.EqualsBuilder;
import org.jumpmind.symmetric.core.common.HashCodeBuilder;
import org.jumpmind.symmetric.core.sql.DbException;
import org.jumpmind.symmetric.core.sql.SqlException;

/**
* Represents the database model, ie. the tables in the database. It also
Expand Down Expand Up @@ -59,14 +59,14 @@ public class Database implements Serializable, Cloneable {
* @param otherDb
* The other database model
*/
public void mergeWith(Database otherDb) throws DbException {
public void mergeWith(Database otherDb) throws SqlException {
for (Iterator<Table> it = otherDb._tables.iterator(); it.hasNext();) {
Table table = it.next();

if (findTable(table.getTableName()) != null) {
// TODO: It might make more sense to log a warning and overwrite
// the table (or merge them) ?
throw new DbException("Cannot merge the models because table " + table.getTableName()
throw new SqlException("Cannot merge the models because table " + table.getTableName()
+ " already defined in this model");
}
addTable(table.copy());
Expand Down Expand Up @@ -242,7 +242,7 @@ public void removeTable(int idx) {
* elements are valid (table and columns have a name, foreign keys rference
* existing tables etc.)
*/
public void initialize() throws DbException {
public void initialize() throws SqlException {
// we have to setup
// * target tables in foreign keys
// * columns in foreign key references
Expand All @@ -255,17 +255,17 @@ public void initialize() throws DbException {
int tableIdx = 0;

if ((getName() == null) || (getName().length() == 0)) {
throw new DbException("The database model has no name");
throw new SqlException("The database model has no name");
}

for (Iterator<Table> tableIt = _tables.iterator(); tableIt.hasNext(); tableIdx++) {
Table curTable = tableIt.next();

if ((curTable.getTableName() == null) || (curTable.getTableName().length() == 0)) {
throw new DbException("The table nr. " + tableIdx + " has no name");
throw new SqlException("The table nr. " + tableIdx + " has no name");
}
if (namesOfProcessedTables.contains(curTable.getTableName())) {
throw new DbException("There are multiple tables with the name "
throw new SqlException("There are multiple tables with the name "
+ curTable.getTableName());
}
namesOfProcessedTables.add(curTable.getTableName());
Expand All @@ -278,22 +278,22 @@ public void initialize() throws DbException {
Column column = curTable.getColumn(idx);

if ((column.getName() == null) || (column.getName().length() == 0)) {
throw new DbException("The column nr. " + idx + " in table "
throw new SqlException("The column nr. " + idx + " in table "
+ curTable.getTableName() + " has no name");
}
if (namesOfProcessedColumns.contains(column.getName())) {
throw new DbException("There are multiple column with the name "
throw new SqlException("There are multiple column with the name "
+ column.getName() + " in the table " + curTable.getTableName());
}
namesOfProcessedColumns.add(column.getName());

if ((column.getType() == null) || (column.getType().length() == 0)) {
throw new DbException("The column nr. " + idx + " in table "
throw new SqlException("The column nr. " + idx + " in table "
+ curTable.getTableName() + " has no type");
}
if ((column.getTypeCode() == Types.OTHER)
&& !"OTHER".equalsIgnoreCase(column.getType())) {
throw new DbException("The column nr. " + idx + " in table "
throw new SqlException("The column nr. " + idx + " in table "
+ curTable.getTableName() + " has an unknown type " + column.getType());
}
namesOfProcessedColumns.add(column.getName());
Expand All @@ -306,7 +306,7 @@ public void initialize() throws DbException {

if (fkName.length() > 0) {
if (namesOfProcessedFks.contains(fkName)) {
throw new DbException("There are multiple foreign keys in table "
throw new SqlException("There are multiple foreign keys in table "
+ curTable.getTableName() + " with the name " + fkName);
}
namesOfProcessedFks.add(fkName);
Expand All @@ -316,7 +316,7 @@ public void initialize() throws DbException {
Table targetTable = findTable(fk.getForeignTableName(), true);

if (targetTable == null) {
throw new DbException("The foreignkey " + fkDesc + " in table "
throw new SqlException("The foreignkey " + fkDesc + " in table "
+ curTable.getTableName() + " references the undefined table "
+ fk.getForeignTableName());
} else {
Expand All @@ -330,7 +330,7 @@ public void initialize() throws DbException {
Column localColumn = curTable.findColumn(ref.getLocalColumnName(), true);

if (localColumn == null) {
throw new DbException("The foreignkey " + fkDesc + " in table "
throw new SqlException("The foreignkey " + fkDesc + " in table "
+ curTable.getTableName()
+ " references the undefined local column "
+ ref.getLocalColumnName());
Expand All @@ -343,7 +343,7 @@ public void initialize() throws DbException {
ref.getForeignColumnName(), true);

if (foreignColumn == null) {
throw new DbException("The foreignkey " + fkDesc + " in table "
throw new SqlException("The foreignkey " + fkDesc + " in table "
+ curTable.getTableName()
+ " references the undefined local column "
+ ref.getForeignColumnName() + " in table "
Expand All @@ -361,7 +361,7 @@ public void initialize() throws DbException {

if (indexName.length() > 0) {
if (namesOfProcessedIndices.contains(indexName)) {
throw new DbException("There are multiple indices in table "
throw new SqlException("There are multiple indices in table "
+ curTable.getTableName() + " with the name " + indexName);
}
namesOfProcessedIndices.add(indexName);
Expand Down
Expand Up @@ -8,6 +8,18 @@
public class Parameters extends HashMap<String, String> {

private static final long serialVersionUID = 1L;

public final static String LOADER_MAX_ROWS_BEFORE_COMMIT = "dataloader.max.rows.before.commit";

public final static String LOADER_MAX_ROWS_BEFORE_BATCH_FLUSH = "dataloader.max.rows.before.batch.flush";

public final static String LOADER_USE_BATCHING = "dataloader.use.batching";

public final static String LOADER_ENABLE_FALLBACK_UPDATE = "dataloader.enable.fallback.update";

public final static String LOADER_ENABLE_FALLBACK_INSERT = "dataloader.enable.fallback.insert";

public final static String LOADER_ALLOW_MISSING_DELETES = "dataloader.allow.missing.delete";

public final static String DB_METADATA_IGNORE_CASE = "db.metadata.ignore.case";

Expand Down
Expand Up @@ -49,8 +49,14 @@ public Table() {

}

public Table(String name) {
this.setTableName(name);
public Table(String catalogName, String schemaName, String tableName) {
this.setCatalogName(catalogName);
this.setSchemaName(schemaName);
this.setTableName(tableName);
}

public Table(String tableName) {
this.setTableName(tableName);
}

public Table(String name, Column... columns) {
Expand Down
Expand Up @@ -11,7 +11,7 @@ public class DataContext {

protected Batch batch;

protected Table sourceTable;
protected Table table;

protected BinaryEncoding binaryEncoding = BinaryEncoding.NONE;

Expand All @@ -33,12 +33,12 @@ public void setContext(Map<String, Object> context) {
this.context = context;
}

public void setSourceTable(Table table) {
this.sourceTable = table;
public void setTable(Table table) {
this.table = table;
}

public Table getSourceTable() {
return sourceTable;
public Table getTable() {
return table;
}

public void setBinaryEncoding(BinaryEncoding binaryEncoding) {
Expand Down

0 comments on commit e7c4067

Please sign in to comment.