/** {@inheritDoc} */ @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED) public void excluir(Atividade atividade) throws NegocioException { this.validarSePodeAlterarWorkflow(atividade.getProcesso().getWorkflow()); List<Tarefa> lista = atividade.getTarefas(); // Não permite excluir uma atividade que contém tarefas if ((lista != null) && !lista.isEmpty()) { throw new NegocioException("erro.atividade.tarefas"); } this.atividadeDAO.excluir(atividade); }
/** {@inheritDoc} */ @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED) public void atualizar(Atividade atividade) throws NegocioException { this.validarSePodeAlterarWorkflow(atividade.getProcesso().getWorkflow()); Atividade atividadeDesatualizada = this.atividadeDAO.obterAntigo(atividade.getId()); if (!atividadeDesatualizada.getDepartamento().equals(atividade.getDepartamento())) { // caso o departamento foi modificado, os usuários não poderão ser os mesmos for (Tarefa tarefa : atividade.getTarefas()) { tarefa.setUsuario(null); this.getTarefaBO().atualizar(tarefa); } } this.atividadeDAO.atualizar(atividade); }
/** {@inheritDoc} */ @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED) public Integer salvar(Atividade atividade) throws NegocioException { Processo processo = this.getProcessoBO().obter(atividade.getProcesso().getId()); this.validarSePodeAlterarWorkflow(processo.getWorkflow()); return this.atividadeDAO.salvar(atividade); }