Skip to content

Commit

Permalink
0002144: When transformed data is retransformed it should only try to…
Browse files Browse the repository at this point in the history
… match the key values if more than one transformed data is returned
  • Loading branch information
chenson42 committed Jan 18, 2015
1 parent b193c64 commit 636ae17
Showing 1 changed file with 14 additions and 1 deletion.
Expand Up @@ -22,6 +22,7 @@

import java.util.List;

import org.apache.commons.lang.ArrayUtils;
import org.jumpmind.db.model.Table;
import org.jumpmind.symmetric.io.data.CsvData;
import org.jumpmind.symmetric.io.data.DataEventType;
Expand All @@ -44,8 +45,14 @@ protected void performFallbackToInsert(AbstractDatabaseWriter writer, CsvData da
transformedData.getSourceKeyValues(), transformedData.getOldSourceValues(),
transformedData.getSourceValues());
for (TransformedData newlyTransformedData : newlyTransformedDatas) {
if (newlyTransformedData.hasSameKeyValues(transformedData.getKeyValues())
/* If there is only one transform, then process it. Otherwise, we
* need to attempt to match the key values to choose the correct transform.
*/
boolean foundTransform = false;
if (newlyTransformedDatas.size() == 1
|| newlyTransformedData.hasSameKeyValues(transformedData.getKeyValues())
|| newlyTransformedData.isGeneratedIdentityNeeded()) {
foundTransform = true;
Table table = newlyTransformedData.buildTargetTable();
CsvData newData = newlyTransformedData.buildTargetCsvData();
if (newlyTransformedData.isGeneratedIdentityNeeded()) {
Expand All @@ -62,6 +69,12 @@ protected void performFallbackToInsert(AbstractDatabaseWriter writer, CsvData da
writer.write(newData, true);
writer.end(table);
}

if (!foundTransform) {
log.warn("The attempt to retransform resulted in more than one transform. We tried to choose one "
+ "by matching on the ordered key values, but could not find a match. The original key values "
+ "that we tried to match on were: {}" + ArrayUtils.toString(transformedData.getKeyValues()) );
}
}
} else {
super.performFallbackToInsert(writer, data, conflict, retransform);
Expand Down

0 comments on commit 636ae17

Please sign in to comment.