Search in sources :

Example 16 with TurmaDAO

use of com.tomasio.projects.trainning.dao.TurmaDAO in project trainning by fernandotomasio.

the class AtividadesEnsinoServiceSimpleImpl method createPreMatricula.

@Override
@Transactional
public Long createPreMatricula(PreMatriculaDTO preMatricula) {
    PreMatriculaDAO preMatriculaDAO = factory.getPreMatriculaDAO();
    IndicacaoDAO indicacaoDAO = factory.getIndicacaoDAO();
    TurmaDAO turmaDAO = factory.getTurmaDAO();
    PreMatricula _preMatricula = null;
    if (preMatricula instanceof PreMatriculaAlunoDTO) {
        _preMatricula = new PreMatriculaAluno((PreMatriculaAlunoDTO) preMatricula);
    } else {
        _preMatricula = new PreMatriculaInstrutor((PreMatriculaInstrutorDTO) preMatricula);
    }
    Long id = null;
    try {
        Indicacao _indicacao = _preMatricula.getIndicacao();
        TurmaEfetiva _turma = _preMatricula.getTurma();
        id = preMatriculaDAO.create(_preMatricula);
        _indicacao.setPreMatriculado(true);
        _turma.setPreAtivado(true);
        indicacaoDAO.update(_indicacao);
        turmaDAO.update(_turma);
    } catch (DAOException ex) {
        ex.printStackTrace();
        throw new CoreException(ex.getMessage());
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new CoreException("Erro em tempo de execução: " + ex.getMessage());
    }
    return id;
}
Also used : StatusTurmaEfetiva(com.tomasio.projects.trainning.model.StatusTurmaEfetiva) TurmaEfetiva(com.tomasio.projects.trainning.model.TurmaEfetiva) Indicacao(com.tomasio.projects.trainning.model.Indicacao) PreMatriculaAluno(com.tomasio.projects.trainning.model.PreMatriculaAluno) PreMatriculaAlunoDTO(com.tomasio.projects.trainning.dto.PreMatriculaAlunoDTO) DAOException(com.tomasio.projects.trainning.exception.DAOException) ParseException(java.text.ParseException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) IndicacaoDAO(com.tomasio.projects.trainning.dao.IndicacaoDAO) DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) PreMatricula(com.tomasio.projects.trainning.model.PreMatricula) PreMatriculaInstrutor(com.tomasio.projects.trainning.model.PreMatriculaInstrutor) PreMatriculaInstrutorDTO(com.tomasio.projects.trainning.dto.PreMatriculaInstrutorDTO) TurmaDAO(com.tomasio.projects.trainning.dao.TurmaDAO) PreMatriculaDAO(com.tomasio.projects.trainning.dao.PreMatriculaDAO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 17 with TurmaDAO

use of com.tomasio.projects.trainning.dao.TurmaDAO in project trainning by fernandotomasio.

the class AtividadesEnsinoServiceSimpleImpl method removePreMatricula.

@Override
@Transactional
public void removePreMatricula(Long preMatriculaId) {
    PreMatriculaDAO preMatriculaDAO = factory.getPreMatriculaDAO();
    IndicacaoDAO indicacaoDAO = factory.getIndicacaoDAO();
    TurmaDAO turmaDAO = factory.getTurmaDAO();
    try {
        PreMatricula preMatricula = preMatriculaDAO.find(preMatriculaId);
        Indicacao indicacao = preMatricula.getIndicacao();
        TurmaEfetiva turma = preMatricula.getTurma();
        preMatriculaDAO.remove(preMatriculaId);
        indicacao.setPreMatriculado(false);
        indicacaoDAO.update(indicacao);
        if (hasPreMatriculas(turma.getId())) {
            turma.setPreAtivado(true);
        } else {
            turma.setPreAtivado(false);
        }
        turmaDAO.update(turma);
    } catch (DAOException ex) {
        ex.printStackTrace();
        throw new CoreException(ex.getMessage());
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new CoreException("Erro em tempo de execução: " + ex.getMessage());
    }
}
Also used : IndicacaoDAO(com.tomasio.projects.trainning.dao.IndicacaoDAO) DAOException(com.tomasio.projects.trainning.exception.DAOException) StatusTurmaEfetiva(com.tomasio.projects.trainning.model.StatusTurmaEfetiva) TurmaEfetiva(com.tomasio.projects.trainning.model.TurmaEfetiva) CoreException(com.tomasio.projects.trainning.exeption.CoreException) PreMatricula(com.tomasio.projects.trainning.model.PreMatricula) Indicacao(com.tomasio.projects.trainning.model.Indicacao) TurmaDAO(com.tomasio.projects.trainning.dao.TurmaDAO) DAOException(com.tomasio.projects.trainning.exception.DAOException) ParseException(java.text.ParseException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) PreMatriculaDAO(com.tomasio.projects.trainning.dao.PreMatriculaDAO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 18 with TurmaDAO

use of com.tomasio.projects.trainning.dao.TurmaDAO in project trainning by fernandotomasio.

the class AtividadesEnsinoServiceSimpleImpl method findAllOrganizacoesGestoras.

@Override
@Transactional(readOnly = true)
public OrganizacaoDTO[] findAllOrganizacoesGestoras() {
    TurmaDAO dao = factory.getTurmaDAO();
    List<OrganizacaoDTO> organizacoes;
    OrganizacaoDTO[] organizacoesArray = null;
    try {
        organizacoes = dao.findAllOrganizacoesGestoras();
        organizacoesArray = new OrganizacaoDTO[organizacoes.size()];
        for (int i = 0; i < organizacoes.size(); i++) {
            organizacoesArray[i] = organizacoes.get(i);
        }
        return organizacoesArray;
    } catch (DAOException ex) {
        ex.printStackTrace();
        throw new CoreException(ex.getMessage());
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new CoreException(ex.getMessage());
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) TurmaDAO(com.tomasio.projects.trainning.dao.TurmaDAO) OrganizacaoDTO(com.tomasio.projects.trainning.dto.OrganizacaoDTO) DAOException(com.tomasio.projects.trainning.exception.DAOException) ParseException(java.text.ParseException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 19 with TurmaDAO

use of com.tomasio.projects.trainning.dao.TurmaDAO in project trainning by fernandotomasio.

the class AtividadesEnsinoServiceSimpleImpl method findAllTurmasEfetivasIds.

@Override
@Transactional(readOnly = true)
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public Long[] findAllTurmasEfetivasIds(Date exercicio, Long organizacaoGestoraId) {
    TurmaDAO dao = factory.getTurmaDAO();
    try {
        List<Long> turmasIds = dao.findAllTurmasEfetivasIds(exercicio, organizacaoGestoraId);
        Long[] turmasIdsArray = new Long[turmasIds.size()];
        turmasIds.toArray(turmasIdsArray);
        return turmasIdsArray;
    } catch (DAOException ex) {
        throw new CoreException(ex.getMessage());
    } catch (Exception ex) {
        throw new CoreException(ex.getMessage());
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) TurmaDAO(com.tomasio.projects.trainning.dao.TurmaDAO) DAOException(com.tomasio.projects.trainning.exception.DAOException) ParseException(java.text.ParseException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 20 with TurmaDAO

use of com.tomasio.projects.trainning.dao.TurmaDAO in project trainning by fernandotomasio.

the class ImportTurmasImplEfetivasFromTabelao method recuperarDocumentos.

private void recuperarDocumentos(String codCurso, String numeroTurma, TurmaEfetiva turmaCriada, Connection conn) {
    SimpleDateFormat df = new SimpleDateFormat("yyyy");
    ContentDAO contentDAO = new AlfrescoContentDAO();
    TurmaDAO turmaDAO = new HibernateTurmaDAO();
    String documentsRoot = "SGC/Documentos de Treinamentos/testes";
    String oldFolderName = "D-CTP/Documentos de Treinamentos/2013/" + codCurso + "-" + numeroTurma;
    String newFolderName = df.format(turmaCriada.getExercicio()) + "_" + turmaCriada.getCurso().getCodigo() + "_" + turmaCriada.getNumeroTurma() + "_" + turmaCriada.getId();
    try {
        WebServiceFactory.setEndpointAddress("http://dctp.decea.intraer:8080/ecm/api");
        boolean existsOldFolder = contentExistsByPath(oldFolderName);
        if (existsOldFolder) {
            WebServiceFactory.setEndpointAddress("http://10.32.63.32:8080/alfresco/api");
            FolderDTO folder = new FolderDTO();
            folder.setName(newFolderName);
            String folderId = contentDAO.createFolder(folder, documentsRoot);
            turmaCriada.setFolderId(folderId);
            turmaDAO.update(turmaCriada);
            WebServiceFactory.setEndpointAddress("http://dctp.decea.intraer:8080/ecm/api");
            ContentDTO[] contents = findAllContentByPath(oldFolderName);
            for (ContentDTO content : contents) {
                WebServiceFactory.setEndpointAddress("http://dctp.decea.intraer:8080/ecm/api");
                DocumentDTO document = findDocumentByUUID(content.getUid());
                document.setMimeType("application/pdf");
                WebServiceFactory.setEndpointAddress("http://10.32.63.32:8080/alfresco/api");
                contentDAO.createDocumentWithUUIDParent(document, folderId);
            }
        }
    } catch (Exception ex) {
        Logger.getLogger(ImportTurmasImplEfetivasFromTabelao.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : ParseException(java.text.ParseException) RemoteException(java.rmi.RemoteException) DAOException(com.tomasio.projects.trainning.exception.DAOException) ContentDAO(com.tomasio.projects.trainning.dao.ContentDAO) AlfrescoContentDAO(com.tomasio.projects.trainning.dao.AlfrescoContentDAO) ContentDTO(com.tomasio.projects.trainning.dto.ContentDTO) FolderDTO(com.tomasio.projects.trainning.dto.FolderDTO) HibernateTurmaDAO(com.tomasio.projects.trainning.dao.HibernateTurmaDAO) DocumentDTO(com.tomasio.projects.trainning.dto.DocumentDTO) AlfrescoContentDAO(com.tomasio.projects.trainning.dao.AlfrescoContentDAO) HibernateTurmaDAO(com.tomasio.projects.trainning.dao.HibernateTurmaDAO) TurmaDAO(com.tomasio.projects.trainning.dao.TurmaDAO) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

TurmaDAO (com.tomasio.projects.trainning.dao.TurmaDAO)29 DAOException (com.tomasio.projects.trainning.exception.DAOException)27 Transactional (org.springframework.transaction.annotation.Transactional)26 ParseException (java.text.ParseException)25 TurmaEfetiva (com.tomasio.projects.trainning.model.TurmaEfetiva)22 StatusTurmaEfetiva (com.tomasio.projects.trainning.model.StatusTurmaEfetiva)21 CoreException (com.tomasio.projects.trainning.exeption.CoreException)19 IndicacaoDAO (com.tomasio.projects.trainning.dao.IndicacaoDAO)13 Indicacao (com.tomasio.projects.trainning.model.Indicacao)11 PreMatriculaDAO (com.tomasio.projects.trainning.dao.PreMatriculaDAO)9 TurmaEfetivaDTO (com.tomasio.projects.trainning.dto.TurmaEfetivaDTO)9 PreMatricula (com.tomasio.projects.trainning.model.PreMatricula)9 CancelamentoMatriculaDAO (com.tomasio.projects.trainning.dao.CancelamentoMatriculaDAO)7 MatriculaDAO (com.tomasio.projects.trainning.dao.MatriculaDAO)7 NotificacaoMatriculaDAO (com.tomasio.projects.trainning.dao.NotificacaoMatriculaDAO)7 CancelamentoMatricula (com.tomasio.projects.trainning.model.CancelamentoMatricula)7 Matricula (com.tomasio.projects.trainning.model.Matricula)7 NotificacaoMatricula (com.tomasio.projects.trainning.model.NotificacaoMatricula)7 ArrayList (java.util.ArrayList)7 SimpleDateFormat (java.text.SimpleDateFormat)6