package com.capgemini.reports.r26;

import com.capgemini.reports.common.AbstractSubmitServlet;
import com.capgemini.reports.definition.r26report.ExecutionR26;
import com.capgemini.reports.reports.parameters.EffectivityDate;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;

/**
 * This class receives demands to perform a R26 report.<br>
 * It prepares the data and creates the appropriate {@link ExecutionR26} instance that will carry out the job.
 */
@WebServlet("/report_r26/submit")
public class SubmitServletR26 extends AbstractSubmitServlet<ExecutionR26> {

    private static final long serialVersionUID = 6034599018215480837L;

    @Override
    public ExecutionR26 prepareReport(final HttpServletRequest request) {

        // Obtaining report parameters
        String component = request.getParameter("component");
        String effectivityStr = request.getParameter("datepicker");

        // Checking effectivity
        EffectivityDate effectivity = new EffectivityDate(effectivityStr);

        return new ExecutionR26(component, effectivity);
    }
}
