Search in sources :

Example 1 with ScriptableSink

use of com.airhacks.enhydrator.out.ScriptableSink in project enhydrator by AdamBien.

the class PipelineTest method getJSONToNashornPipeline.

public static Pipeline getJSONToNashornPipeline() {
    DestinationMapper targetMapper = new DestinationMapper();
    targetMapper.addMapping(0, new TargetMapping("*", "*"));
    DatatypeIndexMapper datatypeMapper = new DatatypeIndexMapper();
    datatypeMapper.addMapping(1, Datatype.INTEGER);
    Source source = new ScriptableSource("./src/test/files/languages.json", "./src/test/files/converter.js", "UTF-8");
    NamedSink logSink = new LogSink();
    NamedSink virtualSink = new ScriptableSink("./src/test/scripts/sink.js");
    Pipeline origin = new Pipeline("json", "src/test/scripts", null, source);
    origin.addSink(logSink);
    origin.addSink(virtualSink);
    origin.addPreRowTransformation(targetMapper);
    origin.addPreRowTransformation(datatypeMapper);
    origin.addPreRowTransformation(new NashornRowTransformer("src/test/scripts", "encrypt"));
    origin.addPostRowTransformation(new NashornRowTransformer("src/test/scripts", "compress"));
    origin.addFilter("true");
    origin.addExpression("print($ROW); $ROW");
    return origin;
}
Also used : DestinationMapper(com.airhacks.enhydrator.transform.DestinationMapper) LogSink(com.airhacks.enhydrator.out.LogSink) TargetMapping(com.airhacks.enhydrator.transform.TargetMapping) NashornRowTransformer(com.airhacks.enhydrator.transform.NashornRowTransformer) NamedSink(com.airhacks.enhydrator.out.NamedSink) DatatypeIndexMapper(com.airhacks.enhydrator.transform.DatatypeIndexMapper) CSVFileSource(com.airhacks.enhydrator.in.CSVFileSource) Source(com.airhacks.enhydrator.in.Source) ScriptableSource(com.airhacks.enhydrator.in.ScriptableSource) JDBCSource(com.airhacks.enhydrator.in.JDBCSource) VirtualSinkSource(com.airhacks.enhydrator.in.VirtualSinkSource) ScriptableSource(com.airhacks.enhydrator.in.ScriptableSource) ScriptableSink(com.airhacks.enhydrator.out.ScriptableSink)

Aggregations

CSVFileSource (com.airhacks.enhydrator.in.CSVFileSource)1 JDBCSource (com.airhacks.enhydrator.in.JDBCSource)1 ScriptableSource (com.airhacks.enhydrator.in.ScriptableSource)1 Source (com.airhacks.enhydrator.in.Source)1 VirtualSinkSource (com.airhacks.enhydrator.in.VirtualSinkSource)1 LogSink (com.airhacks.enhydrator.out.LogSink)1 NamedSink (com.airhacks.enhydrator.out.NamedSink)1 ScriptableSink (com.airhacks.enhydrator.out.ScriptableSink)1 DatatypeIndexMapper (com.airhacks.enhydrator.transform.DatatypeIndexMapper)1 DestinationMapper (com.airhacks.enhydrator.transform.DestinationMapper)1 NashornRowTransformer (com.airhacks.enhydrator.transform.NashornRowTransformer)1 TargetMapping (com.airhacks.enhydrator.transform.TargetMapping)1