
package de.ivu.elect.presentation.system;

import static java.util.stream.Collectors.toList;

import java.util.List;

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

import de.ivu.elect.business.search.control.AbstractElectSearchParameters;
import de.ivu.elect.business.security.UseCasePermission;
import de.ivu.elect.business.system.boundary.TimerStatusErmittler;
import de.ivu.elect.business.system.entity.TimerStatus;
import de.ivu.elect.jee.presentation.dynamicform.FormBuilder;
import de.ivu.elect.presentation.AbstractElectSearchView;
import de.ivu.elect.presentation.View;
import de.ivu.elect.presentation.hilfe.OnlineHilfeId;
import de.ivu.elect.presentation.security.AbstractGebietSecurityFilter;

@OnlineHilfeId("696")
@RequestScoped
@Named(TimerStatusView.COMPONENT_NAME)
@View(viewId = TimerStatusView.VIEW_ID, useCase = UseCasePermission.TIMER_STATUSUEBERSICHT_ANZEIGEN)
public class TimerStatusView extends AbstractElectSearchView<TimerStatus> {

  private static final long serialVersionUID = 1L;

  public static final String COMPONENT_NAME = "timerStatusView";

  public static final String VIEW_ID = "/system/timer-status.xhtml";

  @Inject
  private transient TimerStatusErmittler timerStatusErmittler;

  public TimerStatusView() {
    super();
  }

  @Override
  protected String getViewId() {
    return VIEW_ID;
  }

  @Override
  protected AbstractGebietSecurityFilter<TimerStatus> getGebietSecurityFilter() {
    return KEIN_GEBIET_SECURITY_FILTER;
  }

  @Override
  public boolean isSupportsLazyLoading() {
    return false; // ELECT-8409
  }

  @Override
  public int getDefaultPageSize() {
    return getPageSizeShowAll();
  }

  @Override
  public AbstractElectSearchParameters getSearchParameters() {
    return AbstractElectSearchParameters.EMPTY;
  }

  /**
   * @deprecated To be removed...
   * @see AbstractElectSearchView#presetSearchParameters
   */
  @Deprecated
  @Override
  public void presetSearchParameters() {
    // To be removed...
  }

  @Override
  public void addProperties(FormBuilder formBuilder) {
    // nichts zu tun
  }

  @Override
  protected List<TimerStatus> performSearch() {
    return timerStatusErmittler.getTimerStatus().stream().sorted().collect(toList());
  }

  @Override
  public boolean isBtnResetRendered() {
    return false;
  }
}
