package com.capgemini.reports.definition.r15r16r17reports;

import com.capgemini.reports.ReportLaunchTypeEnum;
import com.capgemini.reports.documentationobjects.DocNorm;
import com.capgemini.reports.documentationobjects.DocNormStandard;
import com.capgemini.reports.documentationobjects.DocTechnic;
import com.capgemini.reports.execution.AbstractExecutionReport;
import com.capgemini.reports.execution.IDataReportPreparator;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;


/**
 * Prepare the common data for report 15, 16 and 17.
 *
 * @param <T> Generic object for a report
 */
@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
public abstract class AbstractExecutionR15R16R17<T extends AbstractExecutionR15R16R17<T>> extends AbstractExecutionReport<T, T> {
    protected static final String FRENCH_LANGUAGE = "Francais";
    private static final long serialVersionUID = 4911952011990726425L;
    // Report parameters
    protected final boolean french;
    protected final String frenchInput;
    protected final String itemId;
    // Documents gathered
    protected final List<DocNorm> docNormList = new ArrayList<>();
    protected final List<DocNormStandard> docNormStandardList = new ArrayList<>();
    protected final List<DocTechnic> docTechnicList = new ArrayList<>();
    // Data gathered
    protected String dateReleased = "";
    protected String revisionArticle = "";
    protected String produitUnit = "";
    protected String typeProduit;
    protected String clausePropriete;

    /**
     * Builds the super class which helps to execute a R15 R16 or 17 reports.
     *
     * @param itemID       {@link String} - the Id of the top Item
     * @param language     {@link String} - the chosen language
     * @param priorityCode int - the priority code found in the reporting.properties file associated to a report.
     * @param revisionRule {@link String} - the revision rule for resolution structure
     * @param launchType   {@link ReportLaunchTypeEnum} - the launch type of the report
     */
    public AbstractExecutionR15R16R17(final String itemID, final String language, final int priorityCode, final String revisionRule,
                                      final ReportLaunchTypeEnum launchType) {
        super(priorityCode, revisionRule, launchType);
        this.frenchInput = language;
        this.french = isFrench(language);
        this.itemId = itemID;
    }

    protected static boolean isFrench(final String language) {
        return FRENCH_LANGUAGE.equals(language);
    }

    @Override
    public abstract IDataReportPreparator<T> getDataPreparator();
}
