package com.capgemini.reports.definition.r15r16r17reports.r15r17reports.r15report;

import com.capgemini.framework.teamcenter.authent.TcSession;
import com.capgemini.framework.teamcenter.exceptions.KurtException;
import com.capgemini.reports.definition.r15r16r17reports.R15R16R17R24R25Keys.SpecificR15R16;
import com.capgemini.reports.definition.r15r16r17reports.r15r17reports.AbstractR15R17Printer;
import com.capgemini.reports.execution.mapconstructor.IMapConstructor;
import com.capgemini.reports.printing.PrintParameters;
import lombok.extern.slf4j.Slf4j;

import java.util.EnumMap;
import java.util.Map;

/**
 * This class is able to put the data gathered by an {@link ExecutionR15} into some {@link PrintParameters} for printing.
 */
@Slf4j
public final class R15Printer extends AbstractR15R17Printer<ExecutionR15> implements IMapConstructor<ExecutionR15, ExecutionR15> {

    private static final long serialVersionUID = 4102259712529027708L;

    @Override
    protected void addSpecificParameters(final ExecutionR15 execution, final PrintParameters mainReport) {
        Map<SpecificR15R16, Object> map = new EnumMap<>(SpecificR15R16.class);
        boolean isFrench = execution.isFrench();
        String frontiereAvion = execution.getFrontiereAvion();
        map.put(SpecificR15R16.INSTALLATION_INTERFACE, isFrench ? french(frontiereAvion) : english(frontiereAvion));
        String frontiereCooperant = execution.getFrontiereCooperant();
        map.put(SpecificR15R16.PARTNER_INTERFACE, isFrench ? french(frontiereCooperant) : english(frontiereCooperant));
        map.put(SpecificR15R16.PRODUCT_UNIT, execution.getProduitUnit());
        map.put(SpecificR15R16.SUB_TITLE,
                "Documents de définition et procédés et pratiques de réalisation\nDefinition and process documents and manufacturing practices");
        mainReport.addReportParameters(map);
        mainReport.addReportParameter(SpecificR15R16.IS_PREVIOUS_DEF.toString(), true);
    }

    @Override
    protected String getTitle(final ExecutionR15 execution) {
        return "Définition de réalisation de l'article\nPart Manufacturing definition";
    }

    @Override
    public void constructDataMaps(TcSession session, final PrintParameters printParameters, final ExecutionR15 report) throws KurtException {
        long start = System.currentTimeMillis();
        this.print(report, printParameters);
        log.trace(EXECUTION_TIME_XXX_MS_FOR_YYY, System.currentTimeMillis() - start, "data filtering");
    }
}
