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

import javax.inject.Named;

import de.ivu.elect.business.gebietsbaum.entity.Gebiet;
import de.ivu.elect.business.security.UseCasePermission;
import de.ivu.elect.jee.faces.FacesContextUtil;
import de.ivu.elect.presentation.gebietsbaum.GebietEditView;
import de.ivu.elect.presentation.security.AbstractGebietSecurity;

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

  private static final long serialVersionUID = 1L;

  public static final String COMPONENT_NAME = "gebietEditAction";

  public GebietEditAction() {
    super();
  }

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

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

  @Override
  protected String doIt(Gebiet entity) {
    gebietSessionSelect.setEntity(entity);
    gebietConversationSelect.setEntity(entity);

    return GebietEditView.VIEW_ID;
  }

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

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

  @Override
  protected void refreshViewOnNonBlankResult(Gebiet entity, String result) {
    FacesContextUtil.redirectToViewNoRedirectParameter(result); // ELECTMUC-1552
  }
}
