Skip to content

Commit

Permalink
Merge pull request #5 from NiasSt90/3.7
Browse files Browse the repository at this point in the history
Merge issues
  • Loading branch information
chenson42 committed Sep 24, 2015
2 parents cc653dc + e77d506 commit 860bdca
Show file tree
Hide file tree
Showing 22 changed files with 446 additions and 148 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
@@ -0,0 +1,2 @@
*.csv text eol=lf

21 changes: 0 additions & 21 deletions symmetric-assemble/pom.xml
Expand Up @@ -102,27 +102,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.db.torque</groupId>
<artifactId>torque-maven-plugin</artifactId>
<version>3.3-RC2</version>
<configuration>
<outputFormat>docbook</outputFormat>
<targetDatabase>symmetric</targetDatabase>
<outputDir>${docbook.build}</outputDir>
<schemaDir>${basedir}/../symmetric-core/src/main/resources</schemaDir>
<templatePath>${basedir}/src/torque</templatePath>
<useClasspath>false</useClasspath>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>documentation</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
Expand Down
Expand Up @@ -29,15 +29,15 @@ Handle Error Script:: A script to execute if data cannot be processed.
.Variables available within scripts
[cols="3,^1,^1,5"]
|===
|Variable|BSH|JAVA|Description

|engine|X||The Symmetric engine object.
|COLUMN_NAME|X||The source values for the row being inserted, updated or deleted.
|OLD_COLUMN_NAME|X||The old values for the row being inserted, updated or deleted.
|context|X|X|The data context object for the data being inserted, updated or deleted. .
|table|X|X|The table object for the table being inserted, updated or deleted.
|data|X|X|The `CsvData` object for the data change.
|error|X|X|`java.lang.Exception`
|Variable|BSH|SQL|JAVA|Description

|engine|X|||The Symmetric engine object.
|COLUMN_NAME|X|X||The source values for the row being inserted, updated or deleted.
|OLD_COLUMN_NAME|X|X||The old values for the row being inserted, updated or deleted.
|context|X||X|The data context object for the data being inserted, updated or deleted. .
|table|X||X|The table object for the table being inserted, updated or deleted.
|data|X||X|The `CsvData` object for the data change.
|error|X||X|`java.lang.Exception`

|===

Expand Down
Expand Up @@ -112,7 +112,7 @@ ifndef::pro[]
----
insert into SYM_TRANSFORM_TABLE (
transform_id, source_node_group_id, target_node_group_id, transform_point, source_table_name,
target_table_name, delete_action, transform_order, column_policy, update_first,
target_table_name, update_action, delete_action, transform_order, column_policy, update_first,
last_update_by, last_update_time, create_time
) values (
'itemSellingPriceTransform', 'store', 'corp', 'EXTRACT', 'ITEM_SELLING_PRICE',
Expand Down
Expand Up @@ -26,7 +26,7 @@ ifndef::pro[]
----
insert into SYM_TRANSFORM_TABLE (
transform_id, source_node_group_id, target_node_group_id, transform_point, source_table_name,
target_table_name, delete_action, transform_order, column_policy, update_first,
target_table_name, update_action, delete_action, transform_order, column_policy, update_first,
last_update_time, create_time
) values (
'update-first', 'store', 'corp', 'EXTRACT', 'ITEM_SELLING_PRICE',
Expand All @@ -48,7 +48,7 @@ ifndef::pro[]
----
insert into SYM_TRANSFORM_TABLE (
transform_id, source_node_group_id, target_node_group_id, transform_point, source_table_name,
target_table_name, delete_action, transform_order, column_policy, update_first,
target_table_name, update_action, delete_action, transform_order, column_policy, update_first,
last_update_time, create_time
) values (
'delete-action-update-col', 'store', 'corp', 'EXTRACT', 'ITEM_SELLING_PRICE',
Expand Down
Expand Up @@ -198,6 +198,8 @@ This transform copies the left most number of bytes specified.
This transformation determines the target column value by using a query, contained in transform expression
to lookup the value in another table. The query must return a single row, and the first column of the query
is used as the value. Your query references source column names by prefixing with a colon (e.g., :MY_COLUMN).
Additional you can reference old values with :OLD_COLUMN and previously transformed columns (see transform order) with
:TRM_COLUMN.

ifndef::pro[]
[source, SQL]
Expand Down
Expand Up @@ -22,7 +22,7 @@ ifndef::pro[]
----
insert into SYM_TRANSFORM_TABLE (
transform_id, source_node_group_id, target_node_group_id, transform_point, source_table_name,
target_table_name, delete_action, transform_order, column_policy, update_first,
target_table_name, update_action, delete_action, transform_order, column_policy, update_first,
last_update_by, last_update_time, create_time
) values (
'extractStoreItemSellingPriceTransform', 'store', 'corp', 'EXTRACT', 'ITEM_SELLING_PRICE',
Expand All @@ -35,7 +35,7 @@ insert into SYM_TRANSFORM_TABLE (
----
insert into SYM_TRANSFORM_TABLE (
transform_id, source_node_group_id, target_node_group_id, transform_point, source_table_name,
target_table_name, delete_action, transform_order, column_policy, update_first,
target_table_name, update_action, delete_action, transform_order, column_policy, update_first,
last_update_by, last_update_time, create_time
) values (
'loadCorpItemSellingPriceTransform', 'corp', 'store', 'LOAD', 'ITEM_SELLING_PRICE',
Expand Down
21 changes: 21 additions & 0 deletions symmetric-assemble/src/docbook/configuration.xml
Expand Up @@ -1242,6 +1242,27 @@ column.</listitem>
</itemizedlist>
</listitem>

<listitem>
update_action: When a source operation of Update takes place, there are
three possible ways to handle the transformation at the target. The
options include:
<itemizedlist>
<listitem>NONE - The update results in no target changes.</listitem>

<listitem>DEL_ROW - The update results in a delete of the row
as specified by the pk columns defined in the transformation
configuration.</listitem>

<listitem>UPDATE_COL - The update results in an Update
operation on the target which updates the specific rows and columns
based on the defined transformation.</listitem>

<listitem>BeanShell Script Transform ('bsh'):
script code which returns one of the above items.
you can use COLUMN variables inside the script.</listitem>
</itemizedlist>
</listitem>

<listitem>
delete_action: When a source operation of Delete takes place, there are
three possible ways to handle the transformation at the target. The
Expand Down
7 changes: 7 additions & 0 deletions symmetric-client/pom.xml
Expand Up @@ -135,11 +135,18 @@
<artifactId>postgresql</artifactId>
<scope>provided</scope>
</dependency>
<!--
<dependency>
<groupId>org.jumpmind.symmetric.jdbc</groupId>
<artifactId>ojdbc</artifactId>
<scope>provided</scope>
</dependency>
-->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
Expand Down
Expand Up @@ -69,12 +69,21 @@ public String transform(IDatabasePlatform platform, DataContext context,
if (StringUtils.isNotBlank(sql)) {
ISqlTransaction transaction = context.findTransaction();
List<String> values = null;
LinkedCaseInsensitiveMap<Object> namedParams = new LinkedCaseInsensitiveMap<Object>(sourceValues);
if (data.getOldSourceValues() != null && sql.contains(":OLD_")) {
for (Map.Entry<String, String> oldColumn : data.getOldSourceValues().entrySet()) {
namedParams.put("OLD_" + oldColumn.getKey().toUpperCase(), oldColumn.getValue());
}
}
if (data.getTargetValues() != null && sql.contains(":TRM_")) {
for (Map.Entry<String, String> transformedCol : data.getTargetValues().entrySet()) {
namedParams.put("TRM_" + transformedCol.getKey().toUpperCase(), transformedCol.getValue());
}
}
if (transaction != null) {
values = transaction.query(sql, lookupColumnRowMapper, new LinkedCaseInsensitiveMap<Object>(
sourceValues));
values = transaction.query(sql, lookupColumnRowMapper, namedParams);
} else {
values = platform.getSqlTemplate().query(sql, lookupColumnRowMapper,
new LinkedCaseInsensitiveMap<Object>(sourceValues));
values = platform.getSqlTemplate().query(sql, lookupColumnRowMapper, namedParams);
}

int rowCount = values.size();
Expand Down
Expand Up @@ -77,6 +77,8 @@ public static List<DynamicDatabaseWriterFilter> getDatabaseWriterFilters(ISymmet
databaseWriterFilters.add(new BshDatabaseWriterFilter(engine, entry.getValue()));
} else if (entry.getKey().equals(LoadFilterType.JAVA)) {
databaseWriterFilters.add(new JavaDatabaseWriterFilter(engine, entry.getValue()));
} else if (entry.getKey().equals(LoadFilterType.SQL)) {
databaseWriterFilters.add(new SQLDatabaseWriterFilter(engine, entry.getValue()));
}
}
}
Expand Down Expand Up @@ -123,28 +125,21 @@ protected boolean processLoadFilters(DataContext context, Table table, CsvData d
foundFilters = lookupFilters(foundFilters,
table.getCatalog(), FormatUtils.WILDCARD, FormatUtils.WILDCARD);

foundFilters = lookupFilters(foundFilters,
foundFilters = lookupFilters(foundFilters,
FormatUtils.WILDCARD, FormatUtils.WILDCARD, FormatUtils.WILDCARD);
}

String tableName = null;
if (isIgnoreCase()) {
tableName = table.getName().toUpperCase();
} else {
tableName = table.getName();
}
foundFilters = lookupFilters(foundFilters,
FormatUtils.WILDCARD, FormatUtils.WILDCARD, table.getName());

foundFilters = lookupFilters(foundFilters,
FormatUtils.WILDCARD, FormatUtils.WILDCARD, tableName);

foundFilters = lookupFilters(foundFilters,
FormatUtils.WILDCARD, table.getSchema(), tableName);
FormatUtils.WILDCARD, table.getSchema(), table.getName());

foundFilters = lookupFilters(foundFilters,
table.getCatalog(), FormatUtils.WILDCARD, tableName);
table.getCatalog(), FormatUtils.WILDCARD, table.getName());

foundFilters = lookupFilters(foundFilters,
table.getCatalog(), table.getSchema(), tableName);
table.getCatalog(), table.getSchema(), table.getName());

if (foundFilters != null) {
for (LoadFilter filter : foundFilters) {
Expand All @@ -159,8 +154,12 @@ protected boolean processLoadFilters(DataContext context, Table table, CsvData d
}

private List<LoadFilter> lookupFilters(List<LoadFilter> foundFilters, String catalogName, String schemaName, String tableName) {
List<LoadFilter> filters = loadFilters.get(Table.getFullyQualifiedTableName(catalogName,
schemaName, tableName));
String fullyQualifiedTableName = Table.getFullyQualifiedTableName(catalogName, schemaName, tableName);
if (isIgnoreCase()) {
fullyQualifiedTableName = fullyQualifiedTableName.toUpperCase();
}
List<LoadFilter> filters = loadFilters.get(
fullyQualifiedTableName);
if (filters != null) {
if (foundFilters == null) {
foundFilters = new ArrayList<LoadFilter>();
Expand Down

0 comments on commit 860bdca

Please sign in to comment.