Search in sources :

Example 1 with Referencia

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

the class TeachingDocumentsServiceSimpleImpl method findReferencia.

@Override
@Transactional(readOnly = true)
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public ReferenciaDTO findReferencia(Long id) {
    ReferenciaDAO dao = factory.getReferenciaDAO();
    Referencia referencia = null;
    try {
        referencia = dao.find(id);
    } 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.getMessage());
    }
    if (referencia != null) {
        return referencia.createDTO();
    } else {
        return null;
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Referencia(com.tomasio.projects.trainning.model.Referencia) CoreException(com.tomasio.projects.trainning.exeption.CoreException) DAOException(com.tomasio.projects.trainning.exception.DAOException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with Referencia

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

the class TeachingDocumentsServiceSimpleImpl method updateReferencia.

@Override
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
@Transactional
public void updateReferencia(ReferenciaDTO referencia) {
    ReferenciaDAO dao = factory.getReferenciaDAO();
    Referencia model = new Referencia(referencia);
    try {
        dao.update(model);
    } 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.getMessage());
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Referencia(com.tomasio.projects.trainning.model.Referencia) CoreException(com.tomasio.projects.trainning.exeption.CoreException) DAOException(com.tomasio.projects.trainning.exception.DAOException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with Referencia

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

the class TeachingDocumentsServiceSimpleImpl method createReferencia.

@Override
@Transactional
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public Long createReferencia(ReferenciaDTO referencia) {
    ReferenciaDAO dao = factory.getReferenciaDAO();
    Referencia model = new Referencia(referencia);
    Long id = null;
    try {
        id = dao.create(model);
    } 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.getMessage());
    }
    return id;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Referencia(com.tomasio.projects.trainning.model.Referencia) CoreException(com.tomasio.projects.trainning.exeption.CoreException) DAOException(com.tomasio.projects.trainning.exception.DAOException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with Referencia

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

the class TeachingDocumentsServiceSimpleImpl method findAllReferenciasByDisciplina.

@Override
@Transactional(readOnly = true)
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public ReferenciaDTO[] findAllReferenciasByDisciplina(Long disciplinaId) {
    ReferenciaDAO dao = factory.getReferenciaDAO();
    ReferenciaDTO[] referenciasArray = null;
    try {
        List<Referencia> referencias = dao.findAll(disciplinaId);
        referenciasArray = new ReferenciaDTO[referencias.size()];
        for (int i = 0; i < referenciasArray.length; i++) {
            referenciasArray[i] = referencias.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 referenciasArray;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) ReferenciaDTO(com.tomasio.projects.trainning.dto.ReferenciaDTO) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Referencia(com.tomasio.projects.trainning.model.Referencia) CoreException(com.tomasio.projects.trainning.exeption.CoreException) DAOException(com.tomasio.projects.trainning.exception.DAOException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with Referencia

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

the class HibernateReferenciaDAO method findAll.

@Override
public List<Referencia> findAll(Long disciplinaId) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        Criteria criteria = session.createCriteria(Referencia.class);
        criteria.add(Restrictions.eq("disciplina.id", disciplinaId));
        @SuppressWarnings("unchecked") List<Referencia> referencias = criteria.list();
        return referencias;
    } catch (HibernateException e) {
        Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("referencias.find.list.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) HibernateException(org.hibernate.HibernateException) Criteria(org.hibernate.Criteria) Referencia(com.tomasio.projects.trainning.model.Referencia) Session(org.hibernate.Session)

Aggregations

DAOException (com.tomasio.projects.trainning.exception.DAOException)6 Referencia (com.tomasio.projects.trainning.model.Referencia)6 CoreException (com.tomasio.projects.trainning.exeption.CoreException)4 Transactional (org.springframework.transaction.annotation.Transactional)4 HibernateException (org.hibernate.HibernateException)2 Session (org.hibernate.Session)2 ReferenciaDTO (com.tomasio.projects.trainning.dto.ReferenciaDTO)1 Criteria (org.hibernate.Criteria)1