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

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

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

/**
 * ELECTVAPP-1031
 */
public class NlGebietPublicKeyImportAction extends AbstractGebietAction {

  private static final long serialVersionUID = 1L;

  @Inject
  private transient NlPrivatePublicKeyNeeded nlPrivatePublicKeyNeeded;

  public NlGebietPublicKeyImportAction() {
    super();
  }

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

  @Override
  public boolean isDisabledInternal(@Nonnull Gebiet gebiet) {
    return super.isDisabledInternal(gebiet) || !NlPublicKeyImportView.isPublicKeyImportZulaessig(gebiet.getWahl(), gebiet, nlPrivatePublicKeyNeeded);
  }

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

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

    return NlPublicKeyImportView.VIEW_ID;
  }

  @Override
  public String getLabelKey() {
    return "eml.public.key.import.menu.item";
  }

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