Search in sources :

Example 6 with TransformTable

use of org.jumpmind.symmetric.io.data.transform.TransformTable in project symmetric-ds by JumpMind.

the class DataExtractorService method createTransformDataWriter.

protected TransformWriter createTransformDataWriter(Node identity, Node targetNode, IDataWriter extractWriter) {
    List<TransformTableNodeGroupLink> transformsList = null;
    if (targetNode != null) {
        transformsList = transformService.findTransformsFor(new NodeGroupLink(identity.getNodeGroupId(), targetNode.getNodeGroupId()), TransformPoint.EXTRACT);
    }
    TransformTable[] transforms = transformsList != null ? transformsList.toArray(new TransformTable[transformsList.size()]) : null;
    TransformWriter transformExtractWriter = new TransformWriter(symmetricDialect.getPlatform(), TransformPoint.EXTRACT, extractWriter, transformService.getColumnTransforms(), transforms);
    return transformExtractWriter;
}
Also used : TransformTable(org.jumpmind.symmetric.io.data.transform.TransformTable) TransformTableNodeGroupLink(org.jumpmind.symmetric.service.impl.TransformService.TransformTableNodeGroupLink) NodeGroupLink(org.jumpmind.symmetric.model.NodeGroupLink) TransformWriter(org.jumpmind.symmetric.io.data.writer.TransformWriter) TransformTableNodeGroupLink(org.jumpmind.symmetric.service.impl.TransformService.TransformTableNodeGroupLink)

Example 7 with TransformTable

use of org.jumpmind.symmetric.io.data.transform.TransformTable in project symmetric-ds by JumpMind.

the class JavaColumnTransformTest method testInnerClass.

@Test
public void testInnerClass() throws Exception {
    String javaCode = "final DataContext ctx = context;" + "HashMap namedParams = new HashMap();" + "context.findTransaction().query(\"sql\", new ISqlRowMapper<Object>() {" + "        public Object mapRow(Row row) {" + "            ctx.put(\"a\", row.getString(\"b\"));" + "            return null;" + "        }" + "}, namedParams);" + "return \"transValue\";";
    TransformColumn column = new TransformColumn("sColumn", "tColumn", false, "java", javaCode);
    TransformTable table = new TransformTable("sTable", "tTable", TransformPoint.LOAD, column);
    Map<String, String> sourceKeyValues = new HashMap<String, String>();
    Map<String, String> sourceValues = new HashMap<String, String>();
    sourceValues.put("sColumn", "aNewValue");
    Map<String, String> oldSourceValues = new HashMap<String, String>();
    oldSourceValues.put("sColumn", "anOldValue");
    TransformedData data = new TransformedData(table, DataEventType.INSERT, sourceKeyValues, oldSourceValues, sourceValues);
    JavaColumnTransform transform = new JavaColumnTransform(extensionService);
    String out = transform.transform(platform, context, column, data, sourceValues, "aNewValue", "anOldValue");
    assertEquals("transValue", out);
}
Also used : JavaColumnTransform(org.jumpmind.symmetric.io.data.transform.JavaColumnTransform) HashMap(java.util.HashMap) TransformedData(org.jumpmind.symmetric.io.data.transform.TransformedData) TransformTable(org.jumpmind.symmetric.io.data.transform.TransformTable) TransformColumn(org.jumpmind.symmetric.io.data.transform.TransformColumn) Test(org.junit.Test)

Aggregations

TransformTable (org.jumpmind.symmetric.io.data.transform.TransformTable)7 HashMap (java.util.HashMap)4 ArrayList (java.util.ArrayList)3 TransformedData (org.jumpmind.symmetric.io.data.transform.TransformedData)3 JavaColumnTransform (org.jumpmind.symmetric.io.data.transform.JavaColumnTransform)2 TransformColumn (org.jumpmind.symmetric.io.data.transform.TransformColumn)2 TransformWriter (org.jumpmind.symmetric.io.data.writer.TransformWriter)2 NodeGroupLink (org.jumpmind.symmetric.model.NodeGroupLink)2 TransformTableNodeGroupLink (org.jumpmind.symmetric.service.impl.TransformService.TransformTableNodeGroupLink)2 Test (org.junit.Test)2 List (java.util.List)1 Map (java.util.Map)1 Table (org.jumpmind.db.model.Table)1 CsvData (org.jumpmind.symmetric.io.data.CsvData)1 DataEventType (org.jumpmind.symmetric.io.data.DataEventType)1 IDataWriter (org.jumpmind.symmetric.io.data.IDataWriter)1 IDatabaseWriterErrorHandler (org.jumpmind.symmetric.io.data.writer.IDatabaseWriterErrorHandler)1 IDatabaseWriterFilter (org.jumpmind.symmetric.io.data.writer.IDatabaseWriterFilter)1 ResolvedData (org.jumpmind.symmetric.io.data.writer.ResolvedData)1 DynamicDatabaseWriterFilter (org.jumpmind.symmetric.load.DynamicDatabaseWriterFilter)1