diff --git a/symmetric/symmetric-assemble/src/docbook/configuration.xml b/symmetric/symmetric-assemble/src/docbook/configuration.xml
index 6f70595777..d5f329fdab 100644
--- a/symmetric/symmetric-assemble/src/docbook/configuration.xml
+++ b/symmetric/symmetric-assemble/src/docbook/configuration.xml
@@ -1106,8 +1106,10 @@ insert into sym_trigger_router (TRIGGER_ID,ROUTER_ID,INITIAL_LOAD_ORDER,
Additive Transform ('additive'): This transformation type is used for numeric data. It computes the change between the old and new values on the source
- and then adds (or subtracts) the value from the existing value in the target column. For example, if the source column changed from a 2 to a 4, and the target
- column is currently 10, the effect of the transform will be to change the target column to a value of 12 ( 10+(4-2) => 12 ).
+ and then adds the change to the existing value in the target column. That is, target = target + multiplier (source_new - source_old), where multiplier
+ is a constant found in the transform_expression (default is 1 if not specified). For example, if the source column changed from a 2 to a 4, the target
+ column is currently 10, and the multiplier is 3, the effect of the transform will be to change the target column to a value of 16 ( 10+3*(4-2) => 16 ). Note that,
+ in the case of deletes, the new column value is considered 0 for the purposes of the calculation.
Substring Transform ('substr'): This transformation computes a substring of the source column data and uses the substring as the target column value. The transform_expression can
diff --git a/symmetric/symmetric-io/src/main/java/org/jumpmind/symmetric/io/data/transform/AdditiveColumnTransform.java b/symmetric/symmetric-io/src/main/java/org/jumpmind/symmetric/io/data/transform/AdditiveColumnTransform.java
index aa6fc7b766..1acacbee85 100644
--- a/symmetric/symmetric-io/src/main/java/org/jumpmind/symmetric/io/data/transform/AdditiveColumnTransform.java
+++ b/symmetric/symmetric-io/src/main/java/org/jumpmind/symmetric/io/data/transform/AdditiveColumnTransform.java
@@ -42,49 +42,63 @@ public String getFullyQualifiedTableName(IDatabasePlatform platform, String sche
public String transform(IDatabasePlatform platform, DataContext context,
TransformColumn column, TransformedData data, Map sourceValues, String newValue, String oldValue) throws IgnoreColumnException,
IgnoreRowException {
- if (StringUtils.isNotBlank(newValue)) {
- BigDecimal numericValue = new BigDecimal(newValue);
- Table table = platform.getTableFromCache(data.getCatalogName(), data.getSchemaName(),
- data.getTableName(), false);
- if (table != null) {
- if (StringUtils.isNotBlank(oldValue)) {
- numericValue = numericValue.subtract(new BigDecimal(oldValue));
- newValue = numericValue.toString();
- }
-
- String quote = platform.getDdlBuilder().isDelimitedIdentifierModeOn() ? platform
- .getDatabaseInfo().getDelimiterToken() : "";
- StringBuilder sql = new StringBuilder(String.format("update %s set %s=%s+%s where ",
- getFullyQualifiedTableName(platform, data.getSchemaName(), data.getCatalogName(), data.getTableName()),
- quote + column.getTargetColumnName() + quote,
- quote + column.getTargetColumnName() + quote,
- newValue));
+
+ BigDecimal multiplier = new BigDecimal(1.00);
+
+ if (StringUtils.isNotBlank(column.getTransformExpression())) {
+ multiplier = new BigDecimal(column.getTransformExpression());
+ }
+
+ BigDecimal delta = new BigDecimal(newValue);
+
+ Table table = platform.getTableFromCache(data.getCatalogName(), data.getSchemaName(),
+ data.getTableName(), false);
+ if (table != null) {
+ if (!StringUtils.isNotBlank(newValue)) {
+ newValue="0.00";
+ }
+
+ if (!StringUtils.isNotBlank(oldValue)) {
+ oldValue="0.00";
+ }
+
+ delta = delta.subtract(new BigDecimal(oldValue));
+ delta = delta.multiply(multiplier);
+ newValue = delta.toString();
+
+ String quote = platform.getDdlBuilder().isDelimitedIdentifierModeOn() ? platform
+ .getDatabaseInfo().getDelimiterToken() : "";
+ StringBuilder sql = new StringBuilder(String.format("update %s set %s=%s+(%s) where ",
+ getFullyQualifiedTableName(platform, data.getSchemaName(), data.getCatalogName(), data.getTableName()),
+ quote + column.getTargetColumnName() + quote,
+ quote + column.getTargetColumnName() + quote,
+ newValue));
- String[] keyNames = data.getKeyNames();
- Column[] columns = new Column[keyNames.length];
- for (int i = 0; i < keyNames.length; i++) {
- if (i > 0) {
- sql.append("and ");
- }
- columns[i] = table.getColumnWithName(keyNames[i]);
- if (columns[i] == null) {
- throw new NullPointerException("Could not find a column named: " + keyNames[i] + " on the target table: " + table.getName());
- }
- sql.append(quote);
- sql.append(keyNames[i]);
- sql.append(quote);
- sql.append("=? ");
+ String[] keyNames = data.getKeyNames();
+ Column[] columns = new Column[keyNames.length];
+ for (int i = 0; i < keyNames.length; i++) {
+ if (i > 0) {
+ sql.append("and ");
}
-
- if (0 < platform.getSqlTemplate().update(
- sql.toString(),
- platform.getObjectValues(context.getBatch().getBinaryEncoding(),
- data.getKeyValues(), columns))) {
- throw new IgnoreColumnException();
+ columns[i] = table.getColumnWithName(keyNames[i]);
+ if (columns[i] == null) {
+ throw new NullPointerException("Could not find a column named: " + keyNames[i] + " on the target table: " + table.getName());
}
+ sql.append(quote);
+ sql.append(keyNames[i]);
+ sql.append(quote);
+ sql.append("=? ");
+ }
+ if (0 < platform.getSqlTemplate().update(
+ sql.toString(),
+ platform.getObjectValues(context.getBatch().getBinaryEncoding(),
+ data.getKeyValues(), columns))) {
+ throw new IgnoreColumnException();
}
+
}
+
return newValue;
}