package com.capgemini.reports.definition.r22report.visitors.bomlineholder;

import com.capgemini.reports.bomlineholder.processor.AltOrDetBehaviour;
import com.capgemini.reports.definition.r22report.visitors.R22VisitorKeys;
import com.capgemini.reports.snecmaobjects.part.AlternateRevision;
import com.capgemini.reports.snecmaobjects.part.DETRevision;

import java.util.Map;

/**
 * This class visits Parts that are below an {@link AlternateRevision} or a {@link DETRevision}.<br>
 * It puts "Oui" in the ALTERNATIVE field of a map.
 */
public class R22AltOrDetBehaviour implements AltOrDetBehaviour<R22VisitorKeys, String> {
    private static final long serialVersionUID = -6520666717827385535L;

    private static final String OUI = "Oui";
    private static final String EMPTY_STRING = "";

    @Override
    public boolean shouldVisitPartsInPseudoFolder() {
        return true;
    }

    @Override
    public boolean shouldVisitPartsBelowAlt() {
        return true;
    }

    @Override
    public void treatPartsInPseudoFolder(final Map<R22VisitorKeys, String> map) {
        // EMPTY fields, if current object is an ALTERNATE or DET
        map.put(R22VisitorKeys.REPERE_FONCTIONNEL_REVISION, EMPTY_STRING);
        map.put(R22VisitorKeys.RESPONSABLE_REPERE, EMPTY_STRING);
        map.put(R22VisitorKeys.ALT, EMPTY_STRING);
        map.put(R22VisitorKeys.SB, EMPTY_STRING);
        map.put(R22VisitorKeys.NQC, EMPTY_STRING);
        map.put(R22VisitorKeys.PANACHAGE, EMPTY_STRING);
        map.put(R22VisitorKeys.COEFF, EMPTY_STRING);

        // Column alternative must be defined to OUI
        map.put(R22VisitorKeys.ALTERNATIVE, OUI);
    }

    @Override
    public void treatAlternateOrDETAsReceptor(final Map<R22VisitorKeys, String> map) {
        // Column alternative must be defined to OUI
        map.put(R22VisitorKeys.ALTERNATIVE, OUI);
    }
}
