package de.ivu.elect.presentation;

import de.ivu.elect.business.gebietsbaum.boundary.GebietSelectChangeEvent;
import de.ivu.elect.business.wahl.boundary.WahlSelectChangeEvent;
import de.ivu.elect.business.wahl.boundary.WahlterminSelectChangeEvent;
import org.apache.deltaspike.core.api.scope.ViewAccessScoped;

import javax.enterprise.event.Observes;
import javax.enterprise.event.Reception;
import java.io.Serializable;
import java.util.List;

// Hintergrund: ELECTBB-355
@ViewAccessScoped
public class ElectStatusViewStore implements Serializable {

  private transient List statusEntries;

  public List getStatusEntries() {
    return statusEntries;
  }

  public void setStatusEntries(List statusEntries) {
    this.statusEntries = statusEntries;
  }


  public void onWahlSelectChangeEvent(@Observes(notifyObserver = Reception.IF_EXISTS) WahlSelectChangeEvent event) {
    reset();
  }

  public void onWahlterminSelectChangeEvent(@Observes(notifyObserver = Reception.IF_EXISTS) WahlterminSelectChangeEvent event) {
    reset();
  }

  public void onGebietSelectChangeEvent(@Observes(notifyObserver = Reception.IF_EXISTS) GebietSelectChangeEvent event) {
    reset();
  }

  public void reset() {
    statusEntries = null;
  }

}
