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

import com.capgemini.reports.definition.r22report.visitors.R22VisitorKeys;
import com.capgemini.reports.snecmaobjects.ISnecmaObject;
import com.capgemini.reports.snecmaobjects.admin.RFAdminAGRevision;
import com.capgemini.reports.snecmaobjects.admin.RFAdminAPRevision;
import com.capgemini.reports.snecmaobjects.admin.RFAdminARevision;
import com.capgemini.reports.snecmaobjects.admin.RFAdminRevision;
import com.capgemini.reports.snecmaobjects.descriptif.DescriptifRevision;
import com.capgemini.reports.snecmaobjects.generic.GenericAssembRevision;
import com.capgemini.reports.snecmaobjects.generic.GenericRevision;
import com.capgemini.reports.snecmaobjects.mockup.MockupRevision;
import com.capgemini.reports.snecmaobjects.part.*;
import com.capgemini.reports.snecmaobjects.product.ProductRevision;
import com.capgemini.reports.snecmaobjects.rf.RFGenericRevision;
import com.capgemini.reports.snecmaobjects.rf.RFPartAssembRevision;
import com.capgemini.reports.snecmaobjects.rf.RFPartRevision;
import com.capgemini.reports.snecmaobjects.supermodel.SuperModelRevision;
import com.capgemini.reports.snecmaobjects.visitor.IReceptorVisitor;

import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;

/**
 * Visit a Receptor SnecmaObject to make a R22 report.
 */
public class R22ReceptorVisitor implements IReceptorVisitor<Map<R22VisitorKeys, String>> {
    private static final long serialVersionUID = -674550302066648191L;

    private static final String SEPARATOR = " ; ";

    @Override
    public Map<R22VisitorKeys, String> visitReceptor(final ProductRevision aProductRev) {
        // No use in R22 report
        return new HashMap<>();
    }

    @Override
    public Map<R22VisitorKeys, String> visitReceptor(final GenericRevision aGenericRev) {
        // No use in R22 report
        return new HashMap<>();
    }

    @Override
    public Map<R22VisitorKeys, String> visitReceptor(final GenericAssembRevision aGenericAssembRev) {
        // No use in R22 report
        return new HashMap<>();
    }

    @Override
    public Map<R22VisitorKeys, String> visitReceptor(SuperModelRevision aSuperModelRev) {
        return null;
    }

    @Override
    public Map<R22VisitorKeys, String> visitReceptor(final AlternateRevision aAlternateRev) {
        return getReceptorProperties(aAlternateRev);
    }

    @Override
    public Map<R22VisitorKeys, String> visitReceptor(final DETRevision aDetRev) {
        return getReceptorProperties(aDetRev);
    }

    @Override
    public Map<R22VisitorKeys, String> visitReceptor(final PartAeroRevision aPartAeroRev) {
        return getReceptorProperties(aPartAeroRev);
    }

    @Override
    public Map<R22VisitorKeys, String> visitReceptor(final PartNoAeroRevision aPartNoAeroRev) {
        return getReceptorProperties(aPartNoAeroRev);
    }

    @Override
    public Map<R22VisitorKeys, String> visitReceptor(final PartAssembRevision aPartAssembRev) {
        return getReceptorProperties(aPartAssembRev);
    }

    @Override
    public Map<R22VisitorKeys, String> visitReceptor(final PartMatRevision aPartMatRev) {
        return getReceptorProperties(aPartMatRev);
    }

    @Override
    public Map<R22VisitorKeys, String> visitReceptor(final StandardRevision aStandardRev) {
        return getReceptorProperties(aStandardRev);
    }

    @Override
    public Map<R22VisitorKeys, String> visitReceptor(final RFGenericRevision aRfGenericRev) {
        // No use in R22 report
        return new HashMap<>();
    }

    @Override
    public Map<R22VisitorKeys, String> visitReceptor(final RFPartAssembRevision aRfPartAssembRev) {
        // No use in R22 report
        return new HashMap<>();
    }

    @Override
    public Map<R22VisitorKeys, String> visitReceptor(final RFPartRevision aRfPartRev) {
        // No use in R22 report
        return new HashMap<>();
    }

    @Override
    public Map<R22VisitorKeys, String> visitReceptor(final RFAdminRevision aRfAdminRev) {
        // No use in R22 report
        return new HashMap<>();
    }

    @Override
    public Map<R22VisitorKeys, String> visitReceptor(final RFAdminARevision aRfAdminARev) {
        // No use in R22 report
        return new HashMap<>();
    }

    @Override
    public Map<R22VisitorKeys, String> visitReceptor(final RFAdminAPRevision aRfAdminAPRev) {
        // No use in R22 report
        return new HashMap<>();
    }

    @Override
    public Map<R22VisitorKeys, String> visitReceptor(final RFAdminAGRevision aRfAdminAGRev) {
        // No use in R22 report
        return new HashMap<>();
    }

    /**
     * Get the Receptor properties. <br>
     * <p>
     * expected format : (item_id ; item_revision_id)
     */
    private Map<R22VisitorKeys, String> getReceptorProperties(final ISnecmaObject iSnecmaObject) {
        Map<R22VisitorKeys, String> theMap = new EnumMap<>(R22VisitorKeys.class);
        theMap.put(R22VisitorKeys.RECEPTEUR, iSnecmaObject.getItemId() + SEPARATOR + iSnecmaObject.getRevisionId());
        return theMap;
    }

    @Override
    public Map<R22VisitorKeys, String> visitReceptor(final MockupRevision aMockupRev) {
        // This object is not use in this report
        return null;
    }

    @Override
    public Map<R22VisitorKeys, String> visitReceptor(DescriptifRevision aDescriptifRev) {
        // This object is not use in this report
        return null;
    }

    @Override
    public Map<R22VisitorKeys, String> emptyRf() {
        return new HashMap<>();
    }
}
