package com.capgemini.reports.r25;

import com.capgemini.reports.common.AbstractSubmitServlet;
import com.capgemini.reports.definition.r25report.ExecutionR25;
import com.capgemini.reports.reports.parameters.Generics;
import com.capgemini.reports.reports.parameters.ProductUnit;

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

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

    private static final long serialVersionUID = 6072763196309128017L;

    @Override
    public ExecutionR25 prepareReport(final HttpServletRequest request) {
        // Obtain report parameters
        String productID = request.getParameter("product_id");
        String unitStr = request.getParameter("unit");
        String typeImpression = request.getParameter("type_impression");
        String langue = request.getParameter("langue");

        // Building product-unit relationship
            ProductUnit productUnit = new ProductUnit(productID, unitStr);
            return new ExecutionR25(productUnit, typeImpression, langue);


        }
    }

