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

import java.util.List;

import javax.ejb.Stateless;

import de.ivu.elect.business.mandant.entity.Mandant;
import de.ivu.elect.business.security.UseCasePermission;
import de.ivu.elect.business.security.UseCaseSecure;
import de.ivu.elect.business.system.entity.SystemLog;
import de.ivu.elect.business.system.entity.SystemLogStatus;

@Stateless
public class SystemLogEdit extends AbstractSystemLogEdit {

  public SystemLogEdit() {
    super();
  }

  @UseCaseSecure(UseCasePermission.SYSTEM_LOG_EDIT)
  public void pruefAll(Mandant mandant) {
    dao.updateStatus(mandant, SystemLogStatus.GEPRUEFT);
  }

  @UseCaseSecure(UseCasePermission.SYSTEM_LOG_EDIT)
  public void geprueft(SystemLog systemLog) {
    dao.attach(systemLog).setStatus(SystemLogStatus.GEPRUEFT);
  }

  @UseCaseSecure(UseCasePermission.SYSTEM_LOG_DELETE)
  public void deleteAll(Mandant mandant) {
    dao.deleteAll(mandant);
  }

  @UseCaseSecure(UseCasePermission.SYSTEM_LOG_EDIT)
  public void pruefSearched(List<SystemLog> systemLogList) {
    for (SystemLog systemLog : systemLogList) {
      geprueft(systemLog);
    }
  }

  @UseCaseSecure(UseCasePermission.SYSTEM_LOG_DELETE)
  public void deleteSearched(List<SystemLog> systemLogList) {
    for (SystemLog systemLog : dao.attachAll(systemLogList)) {
      dao.remove(systemLog);
    }
  }
}
