package com.rjconsultores.ventaboletos.service.impl; import java.util.Calendar; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.rjconsultores.ventaboletos.dao.LogHistoricoContingenciaDAO; import com.rjconsultores.ventaboletos.entidad.LogHistoricoContingencia; import com.rjconsultores.ventaboletos.exception.BusinessException; import com.rjconsultores.ventaboletos.service.ContingenciaService; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; /** * @author vjcor * */ @Service("contingenciaService") public class ContingenciaServiceImpl implements ContingenciaService { @Autowired private LogHistoricoContingenciaDAO histContingenciaDAO; public List buscarHistorico(Integer empresaID, Integer estadoID) { return histContingenciaDAO.buscarHistorico(empresaID, estadoID); } @Transactional public LogHistoricoContingencia salvarHistoricoContingencia(LogHistoricoContingencia historicoCont) throws BusinessException { historicoCont.setUsuario(UsuarioLogado.getUsuarioLogado()); historicoCont.setDataHora(Calendar.getInstance().getTime()); if (historicoCont.getEmpresa() == null) { throw new BusinessException("Não é possível salvar sem a empresa"); } if (historicoCont.getEstado() == null) { throw new BusinessException("Não é possível salvar sem o estado referente"); } if (historicoCont.getMotivo() == null) { throw new BusinessException("Não é possível salvar sem o motivo referente"); } return histContingenciaDAO.suscribir(historicoCont); } }