Skip to content

Commit

Permalink
dev checkin. remove unused method from dialect. SYMMETRICDS-587. fix …
Browse files Browse the repository at this point in the history
…unit test.
  • Loading branch information
chenson42 committed Feb 26, 2012
1 parent 24f8df1 commit 5323020
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 56 deletions.
1 change: 1 addition & 0 deletions symmetric/symmetric-assemble/TODO.txt
Expand Up @@ -21,6 +21,7 @@ DONE = +
* unit test

* Integrate Eric's SecurityService changes
* Purge stats

* Get rid of IOException in service apis in favor of IoException
* Can BatchInfo go away?
Expand Down
Expand Up @@ -21,7 +21,6 @@
package org.jumpmind.symmetric.db;

import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -358,12 +357,6 @@ public String getCreateTableXML(TriggerRouter triggerRouter) {
return xml;
}

public void createTables(String xml) {
StringReader reader = new StringReader(xml);
Database db = new DatabaseIO().read(reader);
platform.createDatabase(db, true, true);
}

protected void prefixConfigDatabase(Database targetTables) {
try {
String prefix = parameterService.getTablePrefix()
Expand Down
Expand Up @@ -131,8 +131,6 @@ public void removeTrigger(StringBuilder sqlBuffer, String catalogName, String sc
*/
public boolean isTransactionIdOverrideSupported();

public void createTables(String xml);

public Table getTable(Trigger trigger, boolean useCache);

public long insertWithGeneratedKey(final String sql, final SequenceIdentifier sequenceId);
Expand Down
Expand Up @@ -538,18 +538,11 @@ protected IncomingBatch.Status findIncomingBatchStatus(int batchId, String nodeI
public void testAutoRegisteredExtensionPoint() {
TestDataWriterFilter registeredFilter = getSymmetricEngine().getExtensionPointManager()
.getExtensionPoint("registeredDataFilter");
TestDataWriterFilter unRegisteredFilter = getSymmetricEngine().getExtensionPointManager()
.getExtensionPoint("unRegisteredDataFilter");
assertTrue(registeredFilter.getNumberOfTimesCalled() > 0);
assertTrue(unRegisteredFilter.getNumberOfTimesCalled() == 0);

NodeGroupTestDataWriterFilter registeredNodeGroupFilter = getSymmetricEngine()
.getExtensionPointManager().getExtensionPoint("registeredNodeGroupTestDataFilter");
NodeGroupTestDataWriterFilter unRegisteredNodeGroupFilter = getSymmetricEngine()
.getExtensionPointManager()
.getExtensionPoint("unRegisteredNodeGroupTestDataFilter");
assertTrue(registeredNodeGroupFilter.getNumberOfTimesCalled() > 0);
assertTrue(unRegisteredNodeGroupFilter.getNumberOfTimesCalled() == 0);
}

protected CsvWriter getWriter(OutputStream out) {
Expand Down
Expand Up @@ -109,7 +109,7 @@ protected InputSource getBetwixtMapping()
*
* @return The reader
*/
protected BeanReader getReader() throws IntrospectionException, SAXException, IOException
public BeanReader getReader() throws IntrospectionException, SAXException, IOException
{
BeanReader reader = new BeanReader();

Expand Down
Expand Up @@ -14,6 +14,7 @@
import org.jumpmind.db.io.DatabaseIO;
import org.jumpmind.db.model.Column;
import org.jumpmind.db.model.Database;
import org.jumpmind.db.model.ModelException;
import org.jumpmind.db.model.Table;
import org.jumpmind.db.platform.IDatabasePlatform;
import org.jumpmind.db.sql.DmlStatement;
Expand Down Expand Up @@ -88,7 +89,7 @@ public DatabaseWriter(IDatabasePlatform platform, DatabaseWriterSettings default
public DatabaseWriter(IDatabasePlatform platform,
IDatabaseWriterConflictResolver conflictResolver,
DatabaseWriterSettings defaultSettings,
Map<String, DatabaseWriterSettings> channelSpecificSettings,
Map<String, DatabaseWriterSettings> channelSpecificSettings,
IDatabaseWriterFilter... filters) {
this.platform = platform;
this.conflictResolver = conflictResolver == null ? new DefaultDatabaseWriterConflictResolver()
Expand Down Expand Up @@ -138,30 +139,30 @@ public void write(CsvData data) {
if (filterBefore(data)) {
boolean success = false;
switch (data.getDataEventType()) {
case UPDATE:
statistics.get(batch).increment(DataWriterStatisticConstants.STATEMENTCOUNT);
success = update(data);
break;
case INSERT:
statistics.get(batch).increment(DataWriterStatisticConstants.STATEMENTCOUNT);
success = insert(data);
break;
case DELETE:
statistics.get(batch).increment(DataWriterStatisticConstants.STATEMENTCOUNT);
success = delete(data);
break;
case BSH:
success = script(data);
break;
case SQL:
success = sql(data);
break;
case CREATE:
success = create(data);
break;
default:
success = true;
break;
case UPDATE:
statistics.get(batch).increment(DataWriterStatisticConstants.STATEMENTCOUNT);
success = update(data);
break;
case INSERT:
statistics.get(batch).increment(DataWriterStatisticConstants.STATEMENTCOUNT);
success = insert(data);
break;
case DELETE:
statistics.get(batch).increment(DataWriterStatisticConstants.STATEMENTCOUNT);
success = delete(data);
break;
case BSH:
success = script(data);
break;
case SQL:
success = sql(data);
break;
case CREATE:
success = create(data);
break;
default:
success = true;
break;
}

if (!success) {
Expand Down Expand Up @@ -317,8 +318,7 @@ protected boolean insert(CsvData data) {
transaction.prepare(this.currentDmlStatement.getSql());
}
try {
String[] values = (String[]) ArrayUtils.addAll(
getRowData(data), getPkData(data));
String[] values = (String[]) ArrayUtils.addAll(getRowData(data), getPkData(data));
long count = execute(data, values);
statistics.get(batch).increment(DataWriterStatisticConstants.INSERTCOUNT, count);
return count > 0;
Expand All @@ -333,7 +333,7 @@ protected boolean insert(CsvData data) {
statistics.get(batch).stopTimer(DataWriterStatisticConstants.DATABASEMILLIS);
}
}

protected String[] getRowData(CsvData data) {
String[] targetValues = new String[targetTable.getColumnCount()];
String[] originalValues = data.getParsedData(CsvData.ROW_DATA);
Expand Down Expand Up @@ -446,17 +446,22 @@ protected boolean script(CsvData data) {

protected boolean create(CsvData data) {
try {
statistics.get(batch).startTimer(DataWriterStatisticConstants.DATABASEMILLIS);
String xml = data.getCsvData(CsvData.ROW_DATA);
if (log.isDebugEnabled()) {
log.debug("About to create table using the following definition: ", xml);
try {
statistics.get(batch).startTimer(DataWriterStatisticConstants.DATABASEMILLIS);
String xml = data.getCsvData(CsvData.ROW_DATA);
if (log.isDebugEnabled()) {
log.debug("About to create table using the following definition: ", xml);
}
StringReader reader = new StringReader(xml);
Database db = (Database) new DatabaseIO().getReader().parse(reader);
platform.alterTables(false, db.getTables());
platform.resetCachedTableModel();
statistics.get(batch).increment(DataWriterStatisticConstants.CREATECOUNT);
return true;
} catch (Exception e) {
throw new ModelException(e);
}
StringReader reader = new StringReader(xml);
Database db = new DatabaseIO().read(reader);
platform.alterTables(false, db.getTables());
platform.resetCachedTableModel();
statistics.get(batch).increment(DataWriterStatisticConstants.CREATECOUNT);
return true;

} finally {
statistics.get(batch).stopTimer(DataWriterStatisticConstants.DATABASEMILLIS);
}
Expand All @@ -472,7 +477,8 @@ protected boolean sql(CsvData data) {
long count = transaction.prepareAndExecute(sql);
log.info("{} rows updated when running: {}", count, sql);
statistics.get(batch).increment(DataWriterStatisticConstants.SQLCOUNT);
statistics.get(batch).increment(DataWriterStatisticConstants.SQLROWSAFFECTEDCOUNT, count);
statistics.get(batch).increment(DataWriterStatisticConstants.SQLROWSAFFECTEDCOUNT,
count);
return true;
} finally {
statistics.get(batch).stopTimer(DataWriterStatisticConstants.DATABASEMILLIS);
Expand Down

0 comments on commit 5323020

Please sign in to comment.