use of com.airhacks.enhydrator.in.ScriptableSource in project enhydrator by AdamBien.
the class FromJsonToCSVTest method fromJSONToCSV.
@Test
public void fromJSONToCSV() throws FileNotFoundException {
Source source = new ScriptableSource(INPUT + "languages.json", INPUT + "converter.js", "UTF-8");
final CSVFileSink csvFileSink = new CSVFileSink("*", getFileName(), ";", true, false);
Pump pump = new Pump.Engine().from(source).to(new LogSink()).to(csvFileSink).build();
pump.start();
}
use of com.airhacks.enhydrator.in.ScriptableSource in project enhydrator by AdamBien.
the class JSONImportTest method getSource.
VirtualSinkSource getSource(final String fileName) throws FileNotFoundException {
final Path pathToContent = Paths.get(fileName);
Reader script = new FileReader("./src/test/files/converter.js");
Source source = new ScriptableSource(pathToContent, script, "UTF-8");
VirtualSinkSource vss = new VirtualSinkSource();
Pump pump = new Pump.Engine().from(source).to(vss).to(new LogSink()).build();
pump.start();
return vss;
}
use of com.airhacks.enhydrator.in.ScriptableSource in project enhydrator by AdamBien.
the class PipelineTest method getJSONPipeline.
public static Pipeline getJSONPipeline() {
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 VirtualSinkSource();
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;
}
use of com.airhacks.enhydrator.in.ScriptableSource 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;
}
Aggregations