
org.easybatch.tools.reporting.DefaultJobReportMerger Maven / Gradle / Ivy
/*
* The MIT License
*
* Copyright (c) 2015, Mahmoud Ben Hassine ([email protected])
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.easybatch.tools.reporting;
import org.easybatch.core.job.JobReport;
import org.easybatch.core.job.JobResult;
import org.easybatch.core.job.JobStatus;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static org.easybatch.core.util.Utils.LINE_SEPARATOR;
/**
* A report merger that generates a merged report defined as follows:
*
* - The start time is the minimum of start times
* - The end time is the maximum of end times
* - The total records is the sum of total records
* - The total skipped records is the sum of total skipped records
* - The total filtered records is the sum of total filtered records
* - The total error records is the sum of total error records
* - The total success records is the sum of total success records
* - The final job result is a list of all job results
* - The final data source name is the concatenation (one per line) of data sources names
* - The final status is {@link JobStatus#COMPLETED} (if all partials are completed)
* or {@link JobStatus#ABORTED} (if one of partials has been aborted) or {@link JobStatus#FAILED} (if one of partials has failed).
*
*
* @author Mahmoud Ben Hassine ([email protected])
*/
public class DefaultJobReportMerger implements JobReportMerger {
/**
* Merge multiple reports into a consolidated one.
*
* @param jobReports reports to merge
* @return a merged report
*/
@Override
public JobReport mergerReports(JobReport... jobReports) {
List startTimes = new ArrayList<>();
List endTimes = new ArrayList<>();
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy