package de.ivu.elect.presentation.kandidatur.action;

import javax.annotation.Nonnull;
import javax.inject.Inject;

import de.ivu.elect.business.kandidatur.boundary.ListenkandidaturEdit;
import de.ivu.elect.business.kandidatur.entity.Kandidatur;
import de.ivu.elect.business.kandidatur.entity.KandidaturStatus;
import de.ivu.elect.business.kandidatur.entity.Listenkandidatur;
import de.ivu.elect.business.security.UseCasePermission;
import de.ivu.elect.jee.faces.FacesContextUtil;

public class NlWasKandidaturWiederbelebenAction extends AbstractKandidaturAction {

  private static final long serialVersionUID = 1L;

  @Inject
  private transient ListenkandidaturEdit listenkandidaturEdit;

  @Override
  protected UseCasePermission getRequiredPermission() {
    return UseCasePermission.WAHLVORSCHLAG_QS;
  }

  @Override
  public boolean isDisabledInternal(@Nonnull Kandidatur kandidatur) {
    return kandidatur.isZugelassen();
  }

  @Override
  public String doIt(Kandidatur kandidatur) {
    listenkandidaturEdit.setStatus(kandidatur.castTo(Listenkandidatur.class).getEntity(),
        KandidaturStatus.ZUGELASSEN, "");

    return FacesContextUtil.getCurrentViewId();
  }

  @Override
  public String getLabelKey() {
    return "listenkandidatur.search.action.zulassen.wiederherstellen";
  }

  @Override
  public String getIcon() {
    return "fa fa-child";
  }

}
