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

import javax.inject.Inject;

import de.ivu.elect.business.security.UseCasePermission;
import de.ivu.elect.business.wahl.boundary.WahlterminSessionSelect;
import de.ivu.elect.business.wahl.entity.Wahltermin;
import de.ivu.elect.business.wahl.entity.WahlterminMeta;
import de.ivu.elect.presentation.menu.AbstractMenuItemEntry;
import de.ivu.elect.presentation.security.AbstractGebietSecurity;

public abstract class AbstractWahlterminMenuItemEntry extends AbstractMenuItemEntry {

  private static final long serialVersionUID = 1L;

  @Inject
  private transient WahlterminSessionSelect wahlterminSelect;

  @Inject
  private transient WahlterminMeta wahlterminMeta;

  public AbstractWahlterminMenuItemEntry() {
    super();
  }

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

  protected abstract UseCasePermission getUseCasePermission();

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

  @Override
  public boolean isDisabledInternal() {
    return false;
  }

  protected WahlterminMeta getMeta() {
    return wahlterminMeta;
  }

  protected boolean isWahlterminSelected() {
    return getSelectedWahltermin() != null;
  }

  protected Wahltermin getSelectedWahltermin() {
    return wahlterminSelect.getEntity();
  }
}
