package de.ivu.elect.business.personenregister.control;

import java.io.Serializable;

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

import de.ivu.elect.business.konfiguration.entity.CustomParameterKategorie;
import de.ivu.elect.business.konfiguration.entity.KonfigurationWertGeaendertEvent;

public class PersonenRegisterKonfigurationListener implements Serializable {

  @Inject
  private transient PersonenregisterCacheResolver personenregisterCacheResolver;

  private static final long serialVersionUID = 1L;

  public void listen(@Observes(notifyObserver = Reception.ALWAYS, during = TransactionPhase.IN_PROGRESS) KonfigurationWertGeaendertEvent konfigurationWertGeaendertEvent) {
    if (CustomParameterKategorie.PERSONENREGISTER.equals(konfigurationWertGeaendertEvent.getKey().getKategorie())) {
      personenregisterCacheResolver.reset(konfigurationWertGeaendertEvent.getMandant());
    }
  }
}
