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

import com.capgemini.framework.teamcenter.object.types.SnecmaObjectTypes;
import com.capgemini.reports.ReportLaunchTypeEnum;
import com.capgemini.reports.database.javabean.enumeration.ReportCriteriaEnum;
import com.capgemini.reports.database.manager.MngCriteriaVal.CriteriaValue;
import com.capgemini.reports.definition.r15r16r17reports.AbstractExecutionR15R16R17;
import com.capgemini.reports.documentationobjects.DocDrawing;
import com.capgemini.reports.documentationobjects.DocGeometry;
import com.capgemini.reports.reports.parameters.IChecker;
import com.capgemini.reports.reports.parameters.checker.ObjectTypeChecker;
import com.capgemini.reports.snecmaobjects.ISnecmaObject;
import lombok.EqualsAndHashCode;
import lombok.Getter;

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

/**
 * Prepare the common data for report 15 and 17.
 *
 * @param <T> Generic object for a report
 */
@Getter
@EqualsAndHashCode(callSuper = true)
public abstract class AbstractExecutionR15R17<T extends AbstractExecutionR15R17<T>> extends AbstractExecutionR15R16R17<T> {
    private static final long serialVersionUID = 1041606367467834895L;

    // Documents gathered
    protected final List<DocGeometry> docGeometryList = new ArrayList<>();
    protected final List<DocDrawing> docDrawingList = new ArrayList<>();

    // Data gathered
    protected final String itemRevision;
    protected ISnecmaObject snecmaObject;
    protected String varMt = "";
    protected String previousReleaseDate = "";

    // Configuration data
    protected Calendar mostRecentDateReleased;
    protected String statusName;

    /**
     * Constructs some parameters requested for R15 and R17 reports execution.
     *
     * @param partId       the ID of the part
     * @param partRevision the revision f the Part
     * @param language     the selected language (French or English)
     * @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 AbstractExecutionR15R17(final String partId, final String partRevision, final String language, final int priorityCode,
                                   final String revisionRule, final ReportLaunchTypeEnum launchType) {
        super(partId, language, priorityCode, revisionRule, launchType);
        this.itemRevision = partRevision;
    }

    @Override
    public List<CriteriaValue> getLaunchData() {
        List<CriteriaValue> theCriteria = new ArrayList<>();
        theCriteria.add(new CriteriaValue(ReportCriteriaEnum.PART_ID, super.itemId));
        theCriteria.add(new CriteriaValue(ReportCriteriaEnum.PART_REVISION, itemRevision));
        theCriteria.add(new CriteriaValue(ReportCriteriaEnum.LANGUAGE, super.frenchInput));
        return theCriteria;
    }

    @Override
    public List<IChecker> getQuickChecks() {
        ArrayList<IChecker> quickChecks = new ArrayList<>();
        quickChecks.add(new ObjectTypeChecker(itemId, SnecmaObjectTypes.DET, SnecmaObjectTypes.PART_AERO, SnecmaObjectTypes.PART_ASSEMB,
                SnecmaObjectTypes.PART_MAT, SnecmaObjectTypes.PART_NO_AERO, SnecmaObjectTypes.STANDARD));
        return quickChecks;
    }
}
