
package de.ivu.elect.presentation.system.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.system.boundary.SystemLogEdit;
import de.ivu.elect.business.system.entity.SystemLog;
import de.ivu.elect.presentation.View;
import de.ivu.elect.presentation.system.SystemLogEditView;

@Named(SystemLogGeprueftAction.COMPONENT_NAME)
public class SystemLogGeprueftAction extends AbstractSystemLogAction {

  public static final String COMPONENT_NAME = "systemLogGeprueftAction";

  private static final long serialVersionUID = 1L;

  @Inject
  SystemLogEdit systemLogEdit;

  @Override
  public boolean isDisabledInternal(@Nonnull SystemLog entity) {
    return !entity.getStatus().isGerueftSetzenMoeglich();
  }

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

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

  @Override
  protected String doIt(SystemLog entity) {
    systemLogEdit.geprueft(entity);
    messages.addInfoMessage("system.log.geprueft");
    return null;
  }

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

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

  @Override
  protected boolean isAsyncSupported() {
    return false;
  }
}
