
package de.ivu.elect.presentation.dokumente.exchange;

import java.io.Serializable;

import javax.enterprise.event.Observes;
import javax.enterprise.event.Reception;
import javax.inject.Inject;

import org.apache.deltaspike.core.api.scope.ConversationGroup;
import org.apache.deltaspike.core.api.scope.GroupedConversation;
import org.apache.deltaspike.core.api.scope.GroupedConversationScoped;

import de.ivu.elect.business.datei.entity.FileType;
import de.ivu.elect.business.gebietsbaum.boundary.GebietSelectChangeEvent;
import de.ivu.elect.business.wahl.boundary.WahlSelectChangeEvent;
import de.ivu.elect.business.wahl.boundary.WahlterminSelectChangeEvent;

@GroupedConversationScoped
@ConversationGroup(DokumentBulkExportSearchEntryConversationSelect.class)
public class DokumentBulkExportSearchEntryConversationSelect implements Serializable {

  private static final long serialVersionUID = 1L;

  @Inject
  private transient GroupedConversation conversation;

  private DokumentBulkExportSearchEntry dokumentBulkExportSearchEntry;

  private FileType finaleKonvertierung;

  public DokumentBulkExportSearchEntryConversationSelect() {
    super();
  }

  public DokumentBulkExportSearchEntry getEntry() {
    return dokumentBulkExportSearchEntry;
  }

  public void setEntry(DokumentBulkExportSearchEntry dokumentBulkExportSearchEntry) {
    this.dokumentBulkExportSearchEntry = dokumentBulkExportSearchEntry;
  }

  public FileType getFinaleKonvertierung() {
    return finaleKonvertierung;
  }

  public void setFinaleKonvertierung(FileType finaleKonvertierung) {
    this.finaleKonvertierung = finaleKonvertierung;
  }

  public void clear() {
    setEntry(null);
    setFinaleKonvertierung(null);
  }

  public void close() {
    clear();

    conversation.close();
  }

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

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

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