
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 Eml230bWahlvorschlagImportMapper extends AbstractEml230WahlvorschlagImportMapper {

  private static final long serialVersionUID = 1L;

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

  public static final String EML_ID = "230b";

  public static final String FILE_FORMAT_NAME = "eml.230b.file.format";

  @Inject
  private transient CurrentCustomer currentCustomer;

  public Eml230bWahlvorschlagImportMapper() {
    super();
  }

  @Override
  protected String getExpectedEmlId() {
    return EML_ID;
  }

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

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

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

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

    return EmlValidation.BESTAETIGEN;
  }

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