
package de.ivu.elect.presentation.stimmeingabe.menu;

import javax.inject.Inject;

import de.ivu.elect.business.CurrentCustomer;
import de.ivu.elect.business.security.UseCasePermission;
import de.ivu.elect.business.wahl.boundary.WahlSessionSelect;
import de.ivu.elect.business.wahl.entity.NlWahlart;
import de.ivu.elect.presentation.stimmeingabe.exchange.Eml510bImportiertExportDescription;
import de.ivu.elect.presentation.exchange.ExportDescription;
import de.ivu.elect.presentation.exchange.menu.AbstractExportMenuItemEntry;

public class Eml510bImportiertExportMenuItemEntry extends AbstractExportMenuItemEntry {

  private static final long serialVersionUID = 1L;

  @Inject
  private transient Eml510bImportiertExportDescription exportDescription;

  @Inject
  private transient WahlSessionSelect wahlSessionSelect;

  @Inject
  private transient CurrentCustomer currentCustomer;

  public Eml510bImportiertExportMenuItemEntry() {
    super();
  }

  @Override
  protected ExportDescription getExportDescription() {
    return exportDescription;
  }

  @Override
  protected UseCasePermission getUseCasePermission() {
    return super.getUseCasePermission();
  }

  @Override
  public boolean isRendered() {
    return super.isRendered() && isHSB();
  }

  private boolean isHSB() {
    return wahlSessionSelect.isSelected() && NlWahlart.isWasHSB(wahlSessionSelect.getEntity(), currentCustomer.getCustomer());
  }

  @Override
  public String getLabel() {
    return getMessage(getLabelKey(), getMessage(exportDescription.getDateiExportName()));
  }
}
