package de.ivu.elect.presentation.wahl.menu;

public class NlWasHsbcToggleMenuItem {/* extends AbstractMenuItemEntry {

  private static final long serialVersionUID = 1L;

  @Inject
  private transient WahlSessionSelect wahlSessionSelect;

  @Inject
  private transient CurrentCustomer currentCustomer;

  @Inject
  private transient NlWasWahlEdit nlWasWahlEdit;

  @Inject
  private transient WahlExtendedDAO wahlExtendedDAO;

  @Inject

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

  @Override
  public boolean isRendered() {
    return hasUseCasePermission(UseCasePermission.CUSTOMER_10) && isHsbcPossible();
  }

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

  @Nullable
  @Override
  public String getTargetViewId() {
    return KEIN_TARGET;
  }

  @Override
  public String getLabelKey() {
    if (isHsbcEnabled()) {
      return "hsbc.off.menu.item";
    }
    return "hsbc.on.menu.item";
  }

  @Override
  public String getIcon() {
    if (isHsbcEnabled()) {
      return "fa fa-toggle-on";
    }

    return "fa fa-toggle-off";
  }

  @Override
  public String doAction() {

    var wahl = wahlSessionSelect.getEntity();
    var aktivated = nlWasWahlEdit.toggleHsbc(wahl);
    wahlExtendedDAO.refresh(wahl);

    if (aktivated) {
      addInfoMessage("hsbc.enabled");
    } else {
      addInfoMessage("hsbc.disabled");

    }
    return FacesContextUtil.getCurrentViewId();
  }

  protected boolean isHsbcPossible() {
    return Optional
        .ofNullable(wahlSessionSelect.getEntity())
        .map(this::isReinesHsb)
        .orElse(false);
  }

  private boolean isReinesHsb(Wahl wahl) {
    return wahl != null &&
        NlWahlart.isWasHSB(wahl, currentCustomer.getCustomer())
        && !NlWahlart.isWasCSB(wahl, currentCustomer.getCustomer())
        && !NlWahlart.isWasPSB(wahl, currentCustomer.getCustomer());
  }

  protected boolean isHsbcEnabled() {
    return Optional
        .ofNullable(wahlSessionSelect.getEntity())
        .map(w -> NlWahlart.isWasHSBC(w, currentCustomer.getCustomer()))
        .orElse(false);
  }

}
*/
}