package de.ivu.elect.presentation.dashboard.entries;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

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

import de.ivu.elect.business.WahlOderWahlterminApp;

@RequestScoped //ELECT-15902
public class DashboardEntryBuilder implements Serializable {

  private static final long serialVersionUID = 1L;

  @Inject
  private transient WahlDashboardEntry wahlDashboardFieldset;

  @Inject
  private transient WahlterminDashboardEntry wahlterminDashboardFieldset;

  @Inject
  private transient WahlOderWahlterminApp wahlOderWahlterminApp;

  @Inject
  private transient DokumentvorlagenDashboardEntry dokumentvorlagenDashboardFieldset;

  @Inject
  private transient UngueltigeSystemparameterDashboardEntry ungueltigeSystemparameterDashboardEntry;

  @Inject
  private transient SystemLogDashboardEntry systemLogDashboardEntry;

  @Inject
  private transient GebietDashbordEntry gebietDashbordEntry;

  public List<AbstractDashboardEntry> getEntries() {
    List<AbstractDashboardEntry> result = getEntriesInternal();
    result.add(dokumentvorlagenDashboardFieldset);
    return result;
  }

  protected List<AbstractDashboardEntry> getEntriesInternal() {
    List<AbstractDashboardEntry> result = new ArrayList<>();
    result.add(ungueltigeSystemparameterDashboardEntry);
    result.add(systemLogDashboardEntry);
    if (wahlOderWahlterminApp.isWahlApp()) {
      result.add(wahlDashboardFieldset);
    }
    if (wahlOderWahlterminApp.isWahlterminApp()) {
      result.add(wahlterminDashboardFieldset);
    }
    result.add(gebietDashbordEntry);
    return result;
  }

}
