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

import javax.inject.Inject;

import de.ivu.elect.business.gebietsbaum.boundary.GebietSessionSelect;
import de.ivu.elect.business.security.UseCasePermission;
import de.ivu.elect.business.wahl.boundary.WahlSessionSelector;
import de.ivu.elect.business.wahl.boundary.WahlterminSessionSelect;
import de.ivu.elect.presentation.menu.AbstractMenuItemEntry;
import de.ivu.elect.presentation.security.AbstractGebietSecurity;

/**
 *  on 01.02.2017.
 */
public abstract class AbstractStatistikSearchMenuItemEntry extends AbstractMenuItemEntry {

  private static final long serialVersionUID = 1L;

  @Inject
  WahlterminSessionSelect wahlterminSessionSelect;

  @Inject
  WahlSessionSelector wahlSessionSelector;

  @Inject
  GebietSessionSelect gebietSessionSelect;

  @Override
  public boolean isRendered() {
    return hasUseCasePermission(getUseCasePermission());
  }

  protected abstract UseCasePermission getUseCasePermission();

  @Override
  public boolean isDisabledInternal() {
    return (!wahlterminSessionSelect.isSelected() && !wahlSessionSelector.isSelected()) || !gebietSessionSelect.isSelected();
  }

  @Override
  protected AbstractGebietSecurity getGebietSecurity() {
    return KEINE_GEBIET_SECURITY;
  }

  @Override
  public String getIcon() {
    return getIcons().getIconCalculate();
  }
}
