package com.capgemini.reports.execution.actions;

import com.capgemini.framework.teamcenter.authent.TcSession;
import com.capgemini.reports.checkdata.CheckingDataHelper;
import com.capgemini.reports.database.javabean.DbReport;
import com.capgemini.reports.exceptions.FileLoadingException;
import com.capgemini.reports.exceptions.InvalidUserInputException;
import com.capgemini.reports.execution.AbstractExecutionReport;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;

/** This class is an {@link IPreExecutionStep} which performs 'quick checks' on a report. */
@Slf4j
@EqualsAndHashCode
public class QuickCheckAction implements IPreExecutionStep {

    private static final long serialVersionUID = 8658242340621050777L;

    @Override
    public <T extends AbstractExecutionReport<T, ?>> void performPreAction(T report, DbReport dbReport, TcSession session)
            throws InvalidUserInputException, FileLoadingException {
        // Do a quick Check. If it fails, the exception thrown will interrupt this execution
        log.debug("Beggining quick checks of the scheduled {} report {}.", report.getReportIdentifier().getReportCode(),
                report.getReportTechnicalUid());
        CheckingDataHelper.doQuickCheck(session, report);
    }

}
