fun.mike.flapjack.pipeline.lab.GenericTransform Maven / Gradle / Ivy
package fun.mike.flapjack.pipeline.lab;
import java.util.List;
import java.util.Optional;
import fun.mike.record.alpha.Record;
public class GenericTransform implements Transform {
private final List operations;
private final List compiledOperations;
public GenericTransform(List operations) {
this.operations = operations;
this.compiledOperations = Operations.compile(operations);
}
public TransformResult run(Record record) {
Record outputRecord = record;
String operationId = null;
Long operationNumber = 1L;
for (CompiledOperation compiledOperation : compiledOperations) {
try {
Optional result = compiledOperation.getOperation().run(outputRecord);
if (!result.isPresent()) {
return TransformResult.empty(outputRecord, record, compiledOperation.getInfo());
}
outputRecord = result.get();
operationNumber++;
} catch (Exception ex) {
return TransformResult.error(outputRecord, record, compiledOperation.getInfo(), ex);
}
}
return TransformResult.ok(outputRecord, record);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy