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

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

import de.ivu.elect.business.security.UseCasePermission;
import de.ivu.elect.business.wahlvorschlag.boundary.ListeConversationSelect;
import de.ivu.elect.business.wahlvorschlag.entity.Liste;
import de.ivu.elect.presentation.security.AbstractGebietSecurity;
import de.ivu.elect.presentation.stimmzettel.action.EntityAufStimmzettelDeleteAction;

@Named(ListeDeleteAction.COMPONENT_NAME)
public class ListeDeleteAction extends AbstractListeAction implements EntityAufStimmzettelDeleteAction<Liste> {

  private static final long serialVersionUID = 1L;

  public static final String COMPONENT_NAME = "listeDeleteAction";

  @Inject
  private transient ListeConversationSelect listeConversationSelect;

  public ListeDeleteAction() {
    super();
  }

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

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

  @Override
  protected boolean isDisabledInternal(@Nonnull Liste liste) {
    return isEinzelbewerberListe(liste) /* -> EinzelbewerberListeDeleteAction */;
  }

  @Override
  protected String doIt(Liste liste) {
    listeConversationSelect.setEntity(liste);

    // Return to current page and display the dialog!
    return null;
  }

  @Override
  protected boolean isFireChangeEvent() {
    return true;
  }

  @Override
  public String getDialogName() {
    return "DeleteConfirm";
  }

  @Override
  public String getLabelKey() {
    return "entity.edit.action.delete";
  }

  @Override
  public String getIcon() {
    return appIcons.getIconDelete();
  }
}
