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

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

import de.ivu.elect.business.gebietsbaum.entity.Gebiet;
import de.ivu.elect.business.security.UseCasePermission;
import de.ivu.elect.presentation.security.AbstractGebietSecurity;

@Named(GebietDeleteAction.COMPONENT_NAME)
public class GebietDeleteAction extends AbstractGebietAction {

  private static final long serialVersionUID = 1L;

  public static final String COMPONENT_NAME = "gebietDeleteAction";

  public GebietDeleteAction() {
    super();
  }

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

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

  @Override
  public boolean isDisabledInternal(@Nonnull Gebiet gebiet) {
    // WASDE-594
    return attach(gebiet).hasUntergeordneteGebiete();
  }

  @Nullable
  @Override
  protected String doIt(Gebiet gebiet) {
    gebietConversationSelect.setEntity(gebiet);

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

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

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

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

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