Skip to content

Commit

Permalink
SYMMETRICDS-462 - refactor transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Jun 28, 2011
1 parent da0b515 commit 71a25c8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Expand Up @@ -68,9 +68,9 @@ protected boolean transform(DmlType dmlType, IDataLoaderContext context, String[
protected boolean perform(TransformedData data, TransformTable transformation,
Map<String, String> originalValues) {
boolean persistData = false;
if (data.getDmlType() != DmlType.DELETE) {
if (data.getDmlType() == DmlType.INSERT && transformation.isUpdateFirst()) {
data.setDmlType(DmlType.UPDATE);
if (data.getTargetDmlType() != DmlType.DELETE) {
if (data.getTargetDmlType() == DmlType.INSERT && transformation.isUpdateFirst()) {
data.setTargetDmlType(DmlType.UPDATE);
}
for (String columnName : originalValues.keySet()) {
List<TransformColumn> transformColumns = transformation.getTransformColumnFor(columnName);
Expand All @@ -87,11 +87,11 @@ protected boolean perform(TransformedData data, TransformTable transformation,
case NONE:
break;
case DEL_ROW:
data.setDmlType(DmlType.DELETE);
data.setTargetDmlType(DmlType.DELETE);
persistData = true;
break;
case NULL_COL:
data.setDmlType(DmlType.UPDATE);
data.setTargetDmlType(DmlType.UPDATE);
persistData = true;
break;
}
Expand Down Expand Up @@ -129,7 +129,7 @@ public void apply(IDataLoaderContext context, TransformedData data) {
tableTemplate.setKeyNames(data.getKeyNames());
// TODO Need more advanced fallback logic? Support typical
// symmetric fallback/recovery settings?
switch (data.getDmlType()) {
switch (data.getTargetDmlType()) {
case INSERT:
try {
tableTemplate.insert(context, data.getColumnValues());
Expand Down
Expand Up @@ -11,7 +11,7 @@

public class TransformedData {

protected DmlType dmlType;
protected DmlType targetDmlType;

protected DmlType originalDmlType;

Expand All @@ -23,16 +23,16 @@ public class TransformedData {

public TransformedData(TransformTable transformation, DmlType dmlType) {
this.transformation = transformation;
this.dmlType = dmlType;
this.targetDmlType = dmlType;
this.originalDmlType = dmlType;
}

public DmlType getDmlType() {
return dmlType;
public DmlType getTargetDmlType() {
return targetDmlType;
}

public void setDmlType(DmlType dmlType) {
this.dmlType = dmlType;
public void setTargetDmlType(DmlType dmlType) {
this.targetDmlType = dmlType;
}

public String getTableName() {
Expand Down Expand Up @@ -86,9 +86,9 @@ protected List<String> retrieve(
}

IncludeOnType type = IncludeOnType.DELETE;
if (dmlType == DmlType.UPDATE && originalDmlType != DmlType.DELETE) {
if (targetDmlType == DmlType.UPDATE && originalDmlType != DmlType.DELETE) {
type = IncludeOnType.UPDATE;
} else if (dmlType == DmlType.INSERT) {
} else if (targetDmlType == DmlType.INSERT) {
type = IncludeOnType.INSERT;
}

Expand Down

0 comments on commit 71a25c8

Please sign in to comment.