package com.capgemini.reports.definition.r13report.printer;

import com.capgemini.framework.common.LanguageHelper;
import com.capgemini.framework.teamcenter.object.pom.status.StatusEnum;
import com.capgemini.framework.teamcenter.object.pom.status.TcReleaseStatus;
import com.capgemini.reports.changeobjects.change.AbstractChangeObject;
import com.capgemini.reports.changeobjects.change.FPPRevision;
import com.capgemini.reports.definition.r13report.R13Keys;
import com.capgemini.reports.definition.r13report.execution.ExecutionR13FPP;
import com.capgemini.reports.execution.mapconstructor.IMapConstructor;
import lombok.EqualsAndHashCode;

import java.util.*;

import static com.capgemini.reports.changeobjects.change.AbstractChangeObject.getItemIdFromModelObjectSetToString;

/**
 * Printer of a R13 Report for FPP objects.
 */
@EqualsAndHashCode(callSuper = true)
public class R13PrinterFPP extends AbstractR13Printer<ExecutionR13FPP, FPPRevision> implements IMapConstructor<ExecutionR13FPP, List<FPPRevision>> {
    private static final long serialVersionUID = 6460682170787086789L;

    @Override
    protected Map<FPPRevision, Map<String, String>> getChangeObjectData(final FPPRevision fpp, final Map<String, String> typeObjectParam) {
        // copyParameters
        Map<String, String> prefixCopy = new HashMap<>(typeObjectParam);

        // Add specific FPP parameters
        prefixCopy.put(R13Keys.TYPE.toString(), LanguageHelper.french(fpp.getOrigineDemande()));
        prefixCopy.put(R13Keys.FPP.PARTS_FPP.toString(), getItemIdFromModelObjectSetToString(fpp.getPartsOfSubModifications()));

        Map<FPPRevision, Map<String, String>> result = new LinkedHashMap<>();
        result.put(fpp, prefixCopy); // Only ever one object here (the original FPP)

        // Workflow and active task parameters
        return result;
    }

    @Override
    protected boolean isValid(final TcReleaseStatus status, final AbstractChangeObject change) {
        boolean validStatus = false;
        if (status.getStatusEnum() == StatusEnum.J0) {
            validStatus = true;
        }
        return validStatus;
    }

    @Override
    protected void specificTreatmentEmptyLines(final Map<String, String> mapPrinter) {
        // No sepcific treatment
    }
}
