Skip to content

Commit

Permalink
move getCommaDeliminatedColumns
Browse files Browse the repository at this point in the history
  • Loading branch information
erilong committed Mar 21, 2012
1 parent 936a38c commit 14fceee
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
Expand Up @@ -24,7 +24,6 @@
import java.io.Serializable;
import java.util.Date;

import org.jumpmind.db.model.Column;
import org.jumpmind.db.model.Table;
import org.jumpmind.symmetric.io.data.DataEventType;

Expand Down Expand Up @@ -109,11 +108,11 @@ public TriggerHistory(Table table, Trigger trigger, TriggerReBuildReason reason)
this();
this.lastTriggerBuildReason = reason;
this.sourceTableName = trigger.getSourceTableName();
this.columnNames = getCommaDeliminatedColumns(trigger.orderColumnsForTable(table));
this.columnNames = Table.getCommaDeliminatedColumns(trigger.orderColumnsForTable(table));
this.sourceSchemaName = trigger.getSourceSchemaName();
this.sourceCatalogName = trigger.getSourceCatalogName();
this.triggerId = trigger.getTriggerId();
this.pkColumnNames = getCommaDeliminatedColumns(table.getPrimaryKeyColumns());
this.pkColumnNames = Table.getCommaDeliminatedColumns(table.getPrimaryKeyColumns());
this.triggerRowHash = trigger.toHashedValue();
tableHash = table.calculateTableHashcode();
}
Expand All @@ -125,20 +124,6 @@ public TriggerHistory(Trigger trigger) {
this.triggerId = trigger.getTriggerId();
}

private String getCommaDeliminatedColumns(Column[] cols) {
StringBuilder columns = new StringBuilder();
if (cols != null && cols.length > 0) {
for (Column column : cols) {
columns.append(column.getName());
columns.append(",");
}
columns.replace(columns.length() - 1, columns.length(), "");
return columns.toString();
} else {
return " ";
}
}

public String getTriggerNameForDmlType(DataEventType type) {
switch (type) {
case INSERT:
Expand Down
Expand Up @@ -36,6 +36,7 @@
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.jumpmind.db.model.Table;
import org.jumpmind.db.sql.ISqlRowMapper;
import org.jumpmind.db.sql.ISqlTransaction;
import org.jumpmind.db.sql.Row;
Expand Down Expand Up @@ -740,6 +741,7 @@ public void batchInError(DataContext context, Exception ex) {
IncomingError error = new IncomingError();
error.setBatchId(this.currentBatch.getBatchId());
error.setNodeId(this.currentBatch.getNodeId());
error.setColumnNames(Table.getCommaDeliminatedColumns(context.getTable().getColumns()));
error.setCsvData(context.getData());
error.setEventType(context.getData().getDataEventType());
error.setFailedLineNumber(this.currentBatch.getFailedLineNumber());
Expand Down
Expand Up @@ -1074,4 +1074,18 @@ public static Table buildTable(String tableName, String[] keyNames, String[] col
return table;
}

public static String getCommaDeliminatedColumns(Column[] cols) {
StringBuilder columns = new StringBuilder();
if (cols != null && cols.length > 0) {
for (Column column : cols) {
columns.append(column.getName());
columns.append(",");
}
columns.replace(columns.length() - 1, columns.length(), "");
return columns.toString();
} else {
return " ";
}
}

}

0 comments on commit 14fceee

Please sign in to comment.