package de.ivu.elect.wus.exchange.wahlvorschlag;

import javax.inject.Inject;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.ivu.elect.EmlValidation;
import de.ivu.elect.business.CurrentCustomer;
import de.ivu.elect.business.kandidatur.control.WahlvorschlagImportContext;
import de.ivu.elect.business.wahl.entity.NlWahlart;
import de.ivu.elect.business.wahl.entity.Wahl;
import de.ivu.elect.nl.eml.EmlWrapper;

public class Eml230cWahlvorschlagImportMapper extends AbstractEml230WahlvorschlagImportMapper {

  private static final long serialVersionUID = 1L;

  private static final Logger LOG = LoggerFactory.getLogger(Eml230cWahlvorschlagImportMapper.class);

  public static final String FILE_FORMAT = "eml.230c.file.format";

  @Inject
  private transient CurrentCustomer currentCustomer;

  @Override
  protected String getExpectedEmlId() {
    return "230c";
  }

  @Override
  protected String getWrongEmlIdMessageKey() {
    return "eml.230c.id.falsch";
  }

  @Override
  protected String getFormatName() {
    return FILE_FORMAT;
  }

  @Override
  protected boolean isAcceptInternal(Wahl wahl) {
    return NlWahlart.isWasCSB(wahl.getWahlart(), currentCustomer.getCustomer()); // ELECTVAPP-194
  }

  @Override
  protected EmlValidation bestimmeEmlValidation(WahlvorschlagImportContext context, EmlWrapper eml230Mapper) {
    if (NlWahlart.isWas(currentCustomer.getCustomer())) {
      return EmlValidation.ABFRAGEN; // siehe https://confluence.ivu.de/display/VAPP/EML-Import+validation /  ELECTVAPP-770
    }

    return EmlValidation.BESTAETIGEN; // siehe https://confluence.ivu.de/display/VAPP/EML-Import+validation /  ELECT-10409
  }

  @Override
  protected Logger getLog() {
    return LOG;
  }
}
