package com.capgemini.reports.emailing.templates;


/**
 * Represents a mail to warn the user that his report has successfully completed and may be retrieved.
 */
public class SuccessfulEmailTemplate extends AbstractEmailTemplate {

    private static final String SUCCESSFUL_FR = " terminé avec succès";
    private static final String TEMPLATE_LOCATION = "template_email_finished.html";

    /**
     * Represents a mail to warn the user that his report has successfully completed and may be retrieved.
     *
     * @param completeReportName String - the name of the report (e.g. R01 report "BOM Assemblage PU")
     * @param postingTime        String - the time at which this report was posted in the queues
     * @param startTime          String - the time at which this report's execution has started
     * @param endTime            String - the time at which this report was completed
     * @param reportLocation     String - the location at which the user may retrieve this report
     */
    public SuccessfulEmailTemplate(final String completeReportName, final String postingTime, final String startTime, final String endTime,
                                   final String reportLocation) {
        super(completeReportName + SUCCESSFUL_FR);
        assignParameters(completeReportName, postingTime, startTime, endTime, reportLocation);
    }

    /**
     * Represents a mail to warn the user that his SCHEDULED report has successfully completed and may be retrieved.
     *
     * @param completeReportName String - the name of the report (e.g. R01 report "BOM Assemblage PU")
     * @param postingTime        String - the time at which this report was posted in the queues
     * @param startTime          String - the time at which this report's execution has started
     * @param endTime            String - the time at which this report was completed
     * @param reportLocation     String - the location at which the user may retrieve this report
     * @param schedulingName     String - the scheduling mane of the SCHEDULED report
     */
    public SuccessfulEmailTemplate(final String completeReportName, final String postingTime, final String startTime, final String endTime,
                                   final String reportLocation, final String schedulingName) {
        super(completeReportName + " - planification " + schedulingName + SUCCESSFUL_FR);
        assignParameters(completeReportName, postingTime, startTime, endTime, reportLocation);
    }

    private void assignParameters(final String completeReportName, final String postingTime, final String startTime, final String endTime,
                                  final String reportLocation) {
        String hyperLink = "<a href=\"" + reportLocation + "\">" + reportLocation + "</a>";

        this.setTagValue(EmailTagEnum.POSTING_TIME, postingTime);
        this.setTagValue(EmailTagEnum.REPORT_NAME, completeReportName);
        this.setTagValue(EmailTagEnum.START_TIME, startTime);
        this.setTagValue(EmailTagEnum.END_TIME, endTime);
        this.setTagValue(EmailTagEnum.REPORT_LOCATION, hyperLink);
    }

    @Override
    protected String getEmailTemplate() {
        return TEMPLATE_LOCATION;
    }

}
