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

import com.capgemini.reports.bomlineholder.processor.AltOrDetBehaviour;
import com.capgemini.reports.definition.r03report.visitors.R03VisitorKeys;
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 R03AltOrDetBehaviour implements AltOrDetBehaviour<R03VisitorKeys, String> {
    private static final long serialVersionUID = -3129556059907841821L;

    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<R03VisitorKeys, String> map) {
        treatAnyPartBelowThisAltOrDet(map);
    }

    @Override
    public void treatAlternateOrDETAsReceptor(final Map<R03VisitorKeys, String> map) {
        map.put(R03VisitorKeys.ALTERNATIVE, OUI);
    }

    private void treatAnyPartBelowThisAltOrDet(final Map<R03VisitorKeys, String> map) {
        // Empty fields
        map.put(R03VisitorKeys.REPERE_FONCTIONNEL, EMPTY_STRING);
        map.put(R03VisitorKeys.REVISION_REPERE_FONCTIONNEL, EMPTY_STRING);
      map.put(R03VisitorKeys.UIN, EMPTY_STRING);
        map.put(R03VisitorKeys.EQUIVALENT_SNSSIN, EMPTY_STRING);
        map.put(R03VisitorKeys.RESPONSABLE_REPERE, EMPTY_STRING);
        map.put(R03VisitorKeys.SUIVI_MONTAGE, EMPTY_STRING);
        map.put(R03VisitorKeys.ALT, EMPTY_STRING);
        map.put(R03VisitorKeys.SB, EMPTY_STRING);
        map.put(R03VisitorKeys.QUANTITE_CUMULEE, EMPTY_STRING);
        map.put(R03VisitorKeys.PANACHE, EMPTY_STRING);
        map.put(R03VisitorKeys.QUANTITE, EMPTY_STRING);

        // Mention that these parts are alternatives to each other
        map.put(R03VisitorKeys.ALTERNATIVE, OUI);
    }
}
