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

import java.util.List;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;

import de.ivu.elect.jee.presentation.menu.AbstractBaseMenuItemEntry;
import de.ivu.elect.jee.presentation.menu.AbstractSubMenuEntry;
import de.ivu.elect.jee.presentation.menu.MenuEntry;

@RequestScoped
public class StimmenMainMenuEntry extends AbstractSubMenuEntry {

  private static final long serialVersionUID = 1L;

  @Inject
  private transient StimmeingabeMenuBuilder stimmeingabeMenuBuilder;

  public StimmenMainMenuEntry() {
    super();
  }

  @Override
  protected List<MenuEntry> getSubMenuEntriesSorted() {
    return stimmeingabeMenuBuilder.getSubMenuEntriesSorted();
  }

  @Override
  public String getLabelKey() {
    return "stimmen.main.menu.item.label"; //   Erfassung ist besser, als "Stimmen", weil dann klar ist, was genau passiert
  }


  public boolean isSubTopicActive() {
    return getSubMenuEntriesSorted().stream().filter(menuEntry -> menuEntry instanceof AbstractBaseMenuItemEntry).anyMatch(MenuEntry::isTopicActive);
  }
}
