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

import com.capgemini.reports.bomlineholder.processor.AltOrDetBehaviour;
import com.capgemini.reports.definition.r01report.visitors.R01VisitorKeys;
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 R01AltOrDetBehaviour implements AltOrDetBehaviour<R01VisitorKeys, String> {
    private static final long serialVersionUID = -1337127910440186192L;

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

    @Override
    public void treatAlternateOrDETAsReceptor(final Map<R01VisitorKeys, String> map) {
        treatAnyPartBelowThisAltOrDet(map);
    }

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

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