package com.capgemini.reports.emailing.templates;

/**
 * Represents a mail to warn the user that this report, launched by a Workflow, has failed.
 */
public class FailedWorkflowEmailTemplate extends FailedEmailTemplate {

    /**
     * Represents a mail to warn the user that this report, launched by a Workflow, has failed.
     *
     * @param completeReportName the name of the report (e.g. R01 report "BOM Assemblage PU")
     * @param postingTime        a String describing he time at which this report was posted in the queues
     * @param startTime          a String describing he time at which this report's execution has started
     * @param failureTime        a String describing he time at which this report caused an error
     * @param errorMessage       the error message to include for the user
     * @param relaunchURL        an URL that can be used to re-launch this report
     */
    public FailedWorkflowEmailTemplate(final String completeReportName, final String postingTime, final String startTime, final String failureTime,
                                       final String errorMessage, final String relaunchURL) {
        super(completeReportName, postingTime, startTime, failureTime, makeErrorMessageFromFailure(errorMessage, relaunchURL));
    }

    private static String makeErrorMessageFromFailure(final String errorMessage, final String relaunchURL) {
        return "Description de l'erreur : " + errorMessage + "<p>" + "Lien de relance : <a href=\"" + relaunchURL + "\">" + relaunchURL + "<a>";
    }

}
