Search in sources :

Example 11 with Conclusao

use of com.tomasio.projects.trainning.model.Conclusao in project trainning by fernandotomasio.

the class HibernateConclusaoDAO method findAllConcluidos.

@Override
public List<Conclusao> findAllConcluidos(Long[] organizacoesId, Long capacitacaoId, Long turmaId, Long pessoaId, boolean aproveitamento) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        Criteria criteria = session.createCriteria(Conclusao.class);
        criteria.createAlias("capacitacao", "c");
        criteria.createAlias("pessoa", "p");
        criteria.createAlias("p.organizacao", "o");
        if (organizacoesId != null) {
            criteria = criteria.add(Restrictions.in("o.id", organizacoesId));
        }
        if (capacitacaoId != null) {
            criteria = criteria.add(Restrictions.eq("c.id", capacitacaoId));
        }
        if (turmaId != null && turmaId > 0) {
            criteria.createAlias("matricula", "m");
            criteria.createAlias("m.turma", "t");
            criteria = criteria.add(Restrictions.eq("t.id", turmaId));
        }
        if (pessoaId != null) {
            criteria = criteria.add(Restrictions.eq("p.id", pessoaId));
        }
        criteria = criteria.add(Restrictions.eq("comAproveitamento", aproveitamento));
        @SuppressWarnings("unchecked") List<Conclusao> conclusoes = criteria.list();
        return conclusoes;
    } catch (HibernateException ex) {
        Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
        throw new DAOException(MessageHelper.getMessage("conclusoes.list.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) HibernateException(org.hibernate.HibernateException) Conclusao(com.tomasio.projects.trainning.model.Conclusao) Criteria(org.hibernate.Criteria) Session(org.hibernate.Session)

Example 12 with Conclusao

use of com.tomasio.projects.trainning.model.Conclusao in project trainning by fernandotomasio.

the class HibernateConclusaoDAO method findAllConcluidosTurmasOresp.

@Override
public List<Conclusao> findAllConcluidosTurmasOresp(Long organizacaoRespId, Date exercicio, boolean aproveitamento, String searchTerm) throws DAOException {
    SimpleDateFormat dfYear = new SimpleDateFormat("yyyy");
    Session session = sessionFactory.getCurrentSession();
    if (exercicio != null) {
        try {
            exercicio = dfYear.parse(dfYear.format(exercicio));
        } catch (ParseException ex) {
            Logger.getLogger(HibernateTurmaDAO.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    try {
        Criteria criteria = session.createCriteria(Conclusao.class);
        criteria.createAlias("matricula", "m");
        criteria.createAlias("m.turma", "t");
        criteria.createAlias("t.curso", "c");
        if (exercicio != null) {
            criteria.add(Restrictions.eq("t.exercicio", exercicio));
        }
        if (organizacaoRespId != null && organizacaoRespId > 0L) {
            criteria.add(Restrictions.eq("t.responsavelId", organizacaoRespId));
        }
        if (searchTerm != null && !searchTerm.equals("")) {
            Disjunction or = Restrictions.disjunction();
            or.add(Restrictions.ilike("c.codigo", "%" + searchTerm + "%")).add(Restrictions.ilike("c.descricao", "%" + searchTerm + "%"));
            criteria.add(or);
        }
        criteria = criteria.add(Restrictions.eq("comAproveitamento", aproveitamento));
        criteria.addOrder(Order.asc("c.codigo"));
        criteria.addOrder(Order.asc("t.numeroTurma"));
        @SuppressWarnings("unchecked") List<Conclusao> conclusoes = criteria.list();
        return conclusoes;
    } catch (HibernateException ex) {
        Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
        throw new DAOException(MessageHelper.getMessage("conclusoes.list.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) Disjunction(org.hibernate.criterion.Disjunction) HibernateException(org.hibernate.HibernateException) Conclusao(com.tomasio.projects.trainning.model.Conclusao) ParseException(java.text.ParseException) Criteria(org.hibernate.Criteria) SimpleDateFormat(java.text.SimpleDateFormat) Session(org.hibernate.Session)

Example 13 with Conclusao

use of com.tomasio.projects.trainning.model.Conclusao in project trainning by fernandotomasio.

the class AtividadesEnsinoServiceSimpleImpl method findAllConcluidosByOrganizacao.

@Override
@Transactional(readOnly = true)
public ConclusaoDTO[] findAllConcluidosByOrganizacao(Long organizacaoId, Long capacitacaoId, boolean aproveitamento) {
    ConclusaoDAO dao = factory.getConclusaoDAO();
    ConclusaoDTO[] concluidosArray = null;
    try {
        List<Conclusao> concluidos = dao.findAllConcluidosByOrganizacao(organizacaoId, capacitacaoId, aproveitamento);
        concluidosArray = new ConclusaoDTO[concluidos.size()];
        for (int i = 0; i < concluidosArray.length; i++) {
            concluidosArray[i] = concluidos.get(i).createDTO();
        }
        return concluidosArray;
    } catch (DAOException ex) {
        Logger.getLogger(AtividadesEnsinoServiceSimpleImpl.class.getName()).log(Level.SEVERE, null, ex);
        throw new CoreException(ex.getMessage());
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) CertificadoConclusaoDTO(com.tomasio.projects.trainning.dto.CertificadoConclusaoDTO) ConclusaoDTO(com.tomasio.projects.trainning.dto.ConclusaoDTO) ConclusaoDAO(com.tomasio.projects.trainning.dao.ConclusaoDAO) CertificadoConclusaoDAO(com.tomasio.projects.trainning.dao.CertificadoConclusaoDAO) CertificadoConclusao(com.tomasio.projects.trainning.model.CertificadoConclusao) Conclusao(com.tomasio.projects.trainning.model.Conclusao) Transactional(org.springframework.transaction.annotation.Transactional)

Example 14 with Conclusao

use of com.tomasio.projects.trainning.model.Conclusao in project trainning by fernandotomasio.

the class AtividadesEnsinoServiceSimpleImpl method findAllConcluidosByTurma.

@Override
@Transactional(readOnly = true)
public ConclusaoDTO[] findAllConcluidosByTurma(Long turmaId, boolean aproveitamento) {
    ConclusaoDAO dao = factory.getConclusaoDAO();
    ConclusaoDTO[] concluidosArray = null;
    try {
        List<Conclusao> concluidos = dao.findAllconcluidosByTurma(turmaId, aproveitamento);
        concluidosArray = new ConclusaoDTO[concluidos.size()];
        for (int i = 0; i < concluidosArray.length; i++) {
            concluidosArray[i] = concluidos.get(i).createDTO();
        }
        return concluidosArray;
    } catch (DAOException ex) {
        Logger.getLogger(AtividadesEnsinoServiceSimpleImpl.class.getName()).log(Level.SEVERE, null, ex);
        throw new CoreException(ex.getMessage());
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) CertificadoConclusaoDTO(com.tomasio.projects.trainning.dto.CertificadoConclusaoDTO) ConclusaoDTO(com.tomasio.projects.trainning.dto.ConclusaoDTO) ConclusaoDAO(com.tomasio.projects.trainning.dao.ConclusaoDAO) CertificadoConclusaoDAO(com.tomasio.projects.trainning.dao.CertificadoConclusaoDAO) CertificadoConclusao(com.tomasio.projects.trainning.model.CertificadoConclusao) Conclusao(com.tomasio.projects.trainning.model.Conclusao) Transactional(org.springframework.transaction.annotation.Transactional)

Example 15 with Conclusao

use of com.tomasio.projects.trainning.model.Conclusao in project trainning by fernandotomasio.

the class AtividadesEnsinoServiceSimpleImpl method updateConclusao.

@Override
@Transactional
public void updateConclusao(ConclusaoDTO conclusao) {
    ConclusaoDAO dao = factory.getConclusaoDAO();
    Conclusao _conclusao = new Conclusao(conclusao);
    try {
        dao.update(_conclusao);
    } catch (DAOException ex) {
        Logger.getLogger(AtividadesEnsinoServiceSimpleImpl.class.getName()).log(Level.SEVERE, null, ex);
        throw new CoreException(ex.getMessage());
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) ConclusaoDAO(com.tomasio.projects.trainning.dao.ConclusaoDAO) CertificadoConclusaoDAO(com.tomasio.projects.trainning.dao.CertificadoConclusaoDAO) CertificadoConclusao(com.tomasio.projects.trainning.model.CertificadoConclusao) Conclusao(com.tomasio.projects.trainning.model.Conclusao) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

DAOException (com.tomasio.projects.trainning.exception.DAOException)17 Conclusao (com.tomasio.projects.trainning.model.Conclusao)17 CertificadoConclusao (com.tomasio.projects.trainning.model.CertificadoConclusao)12 ConclusaoDAO (com.tomasio.projects.trainning.dao.ConclusaoDAO)10 CertificadoConclusaoDAO (com.tomasio.projects.trainning.dao.CertificadoConclusaoDAO)9 CoreException (com.tomasio.projects.trainning.exeption.CoreException)9 Transactional (org.springframework.transaction.annotation.Transactional)9 CertificadoConclusaoDTO (com.tomasio.projects.trainning.dto.CertificadoConclusaoDTO)7 ConclusaoDTO (com.tomasio.projects.trainning.dto.ConclusaoDTO)7 Session (org.hibernate.Session)7 HibernateException (org.hibernate.HibernateException)6 ArrayList (java.util.ArrayList)4 ParseException (java.text.ParseException)3 SimpleDateFormat (java.text.SimpleDateFormat)3 Criteria (org.hibernate.Criteria)2 CursoDAO (com.tomasio.projects.trainning.dao.CursoDAO)1 HibernateConclusaoDAO (com.tomasio.projects.trainning.dao.HibernateConclusaoDAO)1 HibernateCursoDAO (com.tomasio.projects.trainning.dao.HibernateCursoDAO)1 HibernatePessoaDAO (com.tomasio.projects.trainning.dao.HibernatePessoaDAO)1 PessoaDAO (com.tomasio.projects.trainning.dao.PessoaDAO)1