package com.capgemini.reports.execution.mapconstructor;

import com.capgemini.framework.teamcenter.authent.TcSession;
import com.capgemini.framework.teamcenter.exceptions.KurtException;
import com.capgemini.reports.exceptions.FileLoadingException;
import com.capgemini.reports.exceptions.InvalidInputException;
import com.capgemini.reports.exceptions.ReportPrintException;
import com.capgemini.reports.execution.AbstractExecutionReport;
import com.capgemini.reports.printing.PrintParameters;
import net.sf.jasperreports.engine.JRException;

import java.io.IOException;
import java.io.Serializable;
import java.util.Map;

/**
 * This interface will allow to construct data map for the reports.
 *
 * @param <T> generic object for reports
 * @param <U> An intermediate Type object that contains all generated data
 */
public interface IMapConstructor<T extends AbstractExecutionReport<T, U>, U> extends Serializable {

    /** Message to display execution time. */
    String EXECUTION_TIME_XXX_MS_FOR_YYY = "Execution time : {} ms for {}";

    /**
     * Creates the main report template.<br>
     * If a simple template should be loaded from the disc, use {@link AbstractStaticTemplateMapConstructor}.
     *
     * @param report the report to build the template for
     * @param optionalData optionally, some additonal data might be required
     * @return the {@link PrintParameters} with the template on board
     * @throws ReportPrintException
     * @throws FileLoadingException
     * @throws InvalidInputException
     */
    PrintParameters makeMasterTemplate(final T report, final U optionalData) throws ReportPrintException, FileLoadingException, InvalidInputException;

    /**
     * Constructs some data {@link Map}s from the Tc data, and puts them into the provided PrintParameters.
     *
     *
     * @param session
     * @param printParameters the {@link PrintParameters} that must be set up
     * @param reportdata will provide informations for the report which is executing
     * @throws KurtException
     * @throws IOException
     * @throws JRException
     */
    void constructDataMaps(TcSession session, final PrintParameters printParameters, final U reportdata) throws KurtException, JRException, IOException;

}
