Search in sources :

Example 1 with Disciplina

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

the class TeachingDocumentsServiceSimpleImpl method findAllDisciplinasByCurriculoMinimo.

@Override
@Transactional(readOnly = true)
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public DisciplinaDTO[] findAllDisciplinasByCurriculoMinimo(Long curriculoMinimoId) {
    DisciplinaDAO dao = factory.getDisciplinaDAO();
    DisciplinaDTO[] disciplinasArray = null;
    try {
        List<Disciplina> disciplinas = dao.findAllByCurriculoMinimo(curriculoMinimoId);
        disciplinasArray = new DisciplinaDTO[disciplinas.size()];
        for (int i = 0; i < disciplinasArray.length; i++) {
            disciplinasArray[i] = disciplinas.get(i).createDTO();
        }
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    } catch (Exception ex) {
        throw new CoreException("Erro de sistema: " + ex.toString());
    }
    return disciplinasArray;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) Disciplina(com.tomasio.projects.trainning.model.Disciplina) ObjetivoDisciplina(com.tomasio.projects.trainning.model.ObjetivoDisciplina) CoreException(com.tomasio.projects.trainning.exeption.CoreException) DisciplinaDTO(com.tomasio.projects.trainning.dto.DisciplinaDTO) ObjetivoDisciplinaDTO(com.tomasio.projects.trainning.dto.ObjetivoDisciplinaDTO) CoreException(com.tomasio.projects.trainning.exeption.CoreException) DAOException(com.tomasio.projects.trainning.exception.DAOException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with Disciplina

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

the class HibernateDisciplinaDAO method remove.

@Override
public void remove(Long id) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        Disciplina disciplina = (Disciplina) session.get(Disciplina.class, id);
        session.delete(disciplina);
    } catch (HibernateException e) {
        Logger.getLogger(HibernateDisciplinaDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException("Erro ao remover Disciplina!");
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) Disciplina(com.tomasio.projects.trainning.model.Disciplina) HibernateException(org.hibernate.HibernateException) Session(org.hibernate.Session)

Example 3 with Disciplina

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

the class HibernateDisciplinaDAO method find.

@Override
public Disciplina find(Long id) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        Disciplina disciplina = (Disciplina) session.get(Disciplina.class, id);
        fillDisciplina(disciplina);
        return disciplina;
    } catch (HibernateException e) {
        Logger.getLogger(HibernateDisciplinaDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("disciplinas.find.unique.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) Disciplina(com.tomasio.projects.trainning.model.Disciplina) HibernateException(org.hibernate.HibernateException) Session(org.hibernate.Session)

Example 4 with Disciplina

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

the class HibernateDisciplinaDAO method findAllByPUD.

@Override
public List<Disciplina> findAllByPUD(Long pudId) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        Criteria criteria = session.createCriteria(Disciplina.class);
        criteria.add(Restrictions.eq("planoUnidadesDidaticas.id", pudId));
        criteria.addOrder(Order.asc("numeroDisciplina"));
        @SuppressWarnings("unchecked") List<Disciplina> disciplinas = criteria.list();
        for (Disciplina disciplina : disciplinas) {
            fillDisciplina(disciplina);
        }
        return disciplinas;
    } catch (HibernateException e) {
        Logger.getLogger(HibernateDisciplinaDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("disciplinas.find.list.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) Disciplina(com.tomasio.projects.trainning.model.Disciplina) HibernateException(org.hibernate.HibernateException) Criteria(org.hibernate.Criteria) Session(org.hibernate.Session)

Example 5 with Disciplina

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

the class HibernateDisciplinaDAO method findAllByCurriculoMinimo.

@Override
public List<Disciplina> findAllByCurriculoMinimo(Long curriculoMinimoId) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        Criteria criteria = session.createCriteria(Disciplina.class);
        criteria.add(Restrictions.eq("curriculoMinimo.id", curriculoMinimoId));
        criteria.addOrder(Order.asc("numeroDisciplina"));
        @SuppressWarnings("unchecked") List<Disciplina> disciplinas = criteria.list();
        for (Disciplina disciplina : disciplinas) {
            fillDisciplina(disciplina);
        }
        return disciplinas;
    } catch (HibernateException e) {
        Logger.getLogger(HibernateDisciplinaDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("disciplinas.find.list.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) Disciplina(com.tomasio.projects.trainning.model.Disciplina) HibernateException(org.hibernate.HibernateException) Criteria(org.hibernate.Criteria) Session(org.hibernate.Session)

Aggregations

DAOException (com.tomasio.projects.trainning.exception.DAOException)9 Disciplina (com.tomasio.projects.trainning.model.Disciplina)9 CoreException (com.tomasio.projects.trainning.exeption.CoreException)5 ObjetivoDisciplina (com.tomasio.projects.trainning.model.ObjetivoDisciplina)5 Transactional (org.springframework.transaction.annotation.Transactional)5 HibernateException (org.hibernate.HibernateException)4 Session (org.hibernate.Session)4 DisciplinaDTO (com.tomasio.projects.trainning.dto.DisciplinaDTO)2 ObjetivoDisciplinaDTO (com.tomasio.projects.trainning.dto.ObjetivoDisciplinaDTO)2 Criteria (org.hibernate.Criteria)2