// only for debug
// if( getShowTotals() || getShowGrandTotal()){
// algorithm.addMainStep(new FlatReportTotalsOutputStep());
// }
private Algorithm configIntermedAlgo(final boolean hasBeenPreviouslySorted) {
        AbstractMultiStepAlgo algorithm = null; 
        Map<StepIOKeys, AlgoIOKeys> stepToAlgoKeysMapping = new StepAlgoKeyMapBuilder()
                                        .add(INTERMEDIATE_DISTINCT_VALUES_HOLDER, DISTINCT_VALUES_HOLDER)
                                        .add(INTERMEDIATE_SERIALIZED_FILE, INTERMEDIATE_OUTPUT_FILE)
                                        .build();
        if(hasBeenPreviouslySorted){
            algorithm = new MultipleSortedFilesInputAlgo("Intermediate Algorithm", stepToAlgoKeysMapping); 
        }else{
            algorithm = new LoopThroughTableInputAlgo("Intermediate Algorithm", stepToAlgoKeysMapping); 
        }
        // initial steps
        // algorithm.addInitStep(new ConfigIntermedColsInitStep());
        algorithm.addInitStep(new ConstrIntermedDataColsInitStep());
        algorithm.addInitStep(new ConstrIntermedGrpColsInitStep());
        // if(!needsProgramaticSorting){
        // algorithm.addInitStep(new ConfigIntermedIOInitStep());
        // }else{
        // algorithm.addInitStep(new
        // ConfigMultiExternalFilesInputForIntermReportInitStep());
        // }
        algorithm.addInitStep(new ConfigIntermedReportOutputInitStep());
        algorithm.addInitStep(stepInput -> {
            ((IntermediateCrosstabOutput) stepInput.getContextParam(INTERMEDIATE_CROSSTAB_OUTPUT)).open();
            return NO_RESULT;
        });
        // TODO: only when totals add the step below
        algorithm.addInitStep(new IntermedReportExtractTotalsDataInitStep());
        // only for debug
        // algorithm.addInitStep(new ColumnHeaderOutputInitStep("Intermediate report"));
        // main steps
        algorithm.addMainStep(new DistinctValuesDetectorStep());
        algorithm.addMainStep(new IntermedGroupLevelDetectorStep());
        // only for debug
        // if( getShowTotals() || getShowGrandTotal()){
        // algorithm.addMainStep(new FlatReportTotalsOutputStep());
        // }
        algorithm.addMainStep(new IntermedRowMangerStep());
        if (getShowTotals() || getShowGrandTotal()) {
            algorithm.addMainStep(new IntermedTotalsCalculatorStep());
        }
        // only for debug
        // algorithm.addMainStep(new DataRowsOutputStep());
        // if( intermediateGroupCols.size() > 0){
        algorithm.addMainStep(new IntermedPreviousRowManagerStep());
        // }
        algorithm.addExitStep(stepInput -> {
                ((IntermediateCrosstabOutput) stepInput.getContextParam(INTERMEDIATE_CROSSTAB_OUTPUT)).close();
                return NO_RESULT;
        });
        algorithm.addExitStep(new IntermedSetResultsExitStep());
        return algorithm;
    }
// TODO: only when totals add the step below
algorithm.addInitStep(new IntermedReportExtractTotalsDataInitStep());
// only for debug
// algorithm.addInitStep(new ColumnHeaderOutputInitStep("Intermediate report"));
// main steps
algorithm.addMainStep(new DistinctValuesDetectorStep());
algorithm.addMainStep(new IntermedGroupLevelDetectorStep());
// only for debug
// algorithm.addInitStep(new
// ConfigMultiExternalFilesInputForIntermReportInitStep());
// }
algorithm.addInitStep(new ConfigIntermedReportOutputInitStep());
algorithm.addInitStep(stepInput -> {
((IntermediateCrosstabOutput) stepInput.getContextParam(INTERMEDIATE_CROSSTAB_OUTPUT)).open();
return NO_RESULT;
});
// TODO: only when totals add the step below
algorithm.addInitStep(new IntermedReportExtractTotalsDataInitStep());
// only for debug
// algorithm.addInitStep(new ColumnHeaderOutputInitStep("Intermediate report"));
// main steps
algorithm.addMainStep(new DistinctValuesDetectorStep());
algorithm.addMainStep(new IntermedGroupLevelDetectorStep());
// only for debug
// if( getShowTotals() || getShowGrandTotal()){
// algorithm.addMainStep(new FlatReportTotalsOutputStep());
// }
algorithm.addMainStep(new IntermedRowMangerStep());
if (getShowTotals() || getShowGrandTotal()) {
algorithm.addMainStep(new IntermedTotalsCalculatorStep());
}
// only for debug
}else{
algorithm = new LoopThroughTableInputAlgo("Intermediate Algorithm", stepToAlgoKeysMapping);
}
// initial steps
// algorithm.addInitStep(new ConfigIntermedColsInitStep());
algorithm.addInitStep(new ConstrIntermedDataColsInitStep());
algorithm.addInitStep(new ConstrIntermedGrpColsInitStep());
// if(!needsProgramaticSorting){
// algorithm.addInitStep(new ConfigIntermedIOInitStep());
// }else{
// algorithm.addInitStep(new
// ConfigMultiExternalFilesInputForIntermReportInitStep());
// }
algorithm.addInitStep(new ConfigIntermedReportOutputInitStep());
algorithm.addInitStep(stepInput -> {
((IntermediateCrosstabOutput) stepInput.getContextParam(INTERMEDIATE_CROSSTAB_OUTPUT)).open();
return NO_RESULT;
});
// TODO: only when totals add the step below
algorithm.addInitStep(new IntermedReportExtractTotalsDataInitStep());
// only for debug
// algorithm.addInitStep(new ColumnHeaderOutputInitStep("Intermediate report"));
// main steps
algorithm.addMainStep(new DistinctValuesDetectorStep());
algorithm.addMainStep(new IntermedGroupLevelDetectorStep());
// only for debug
// if( getShowTotals() || getShowGrandTotal()){
// algorithm.addMainStep(new FlatReportTotalsOutputStep());
// }
algorithm.addMainStep(new IntermedRowMangerStep());
if (getShowTotals() || getShowGrandTotal()) {
algorithm.addMainStep(new IntermedTotalsCalculatorStep());
}
// only for debug
// algorithm.addMainStep(new DataRowsOutputStep());
// if( intermediateGroupCols.size() > 0){
algorithm.addMainStep(new IntermedPreviousRowManagerStep());
// }
algorithm.addExitStep(stepInput -> {
((IntermediateCrosstabOutput) stepInput.getContextParam(INTERMEDIATE_CROSSTAB_OUTPUT)).close();
return NO_RESULT;
});
algorithm.addExitStep(new IntermedSetResultsExitStep());
return algorithm;