
package de.ivu.elect.business.system.boundary;

import java.io.Serializable;

import javax.ejb.Stateless;
import javax.inject.Inject;

import de.ivu.elect.business.konfiguration.entity.ElectKonfigurationWerte;
import de.ivu.elect.business.konfiguration.entity.Konfiguration;
import de.ivu.elect.business.konfiguration.entity.KonfigurationLoader;
import de.ivu.elect.business.konfiguration.entity.MandantKonfigurationWerte;
import de.ivu.elect.business.mandant.entity.Mandant;
import de.ivu.elect.business.system.entity.SystemStatus;

@Stateless
public class SystemStatusUpdate implements Serializable {

  private static final long serialVersionUID = 1L;

  @Inject
  private transient SystemStatusStore systemStatusStore;

  @Inject
  private transient KonfigurationLoader konfigurationLoader;

  public SystemStatusUpdate() {
    super();
  }

  public void setSystemStatus(Mandant mandant, SystemStatus systemStatus) {
    if (mandant != null) {
      Konfiguration konfiguration = konfigurationLoader.getParameter(mandant, MandantKonfigurationWerte.SYSTEM_STATUS);
      konfiguration.setWert(systemStatus.name());
      systemStatusStore.setSystemStatus(mandant.getPk(), systemStatus);
    }
  }
}
