package com.capgemini.reports.emailing.templates;

/**
 * In case report triggered by a workflow fails, this email is sent to the administrators.
 */
public class FailedWorkflowEmailTemplateAdmin extends FailedEmailTemplateAdmin {

    /**
     * Constructor.
     *
     * @param completeReportName the complete report name (like 'R22 - BOM Par Date')
     * @param postingTime        the time at which the report has been posted
     * @param startTime          the time at which the report has started to execute
     * @param failureTime        the he time at which the report has failed
     * @param errorMessage       the error message
     * @param relaunchURL        a URL that the admins may use to re-launch this report with the same parameters
     */
    public FailedWorkflowEmailTemplateAdmin(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>";
    }
}
