Search in sources :

Example 1 with Abreviatura

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

the class TeachingDocumentsServiceSimpleImpl method findAbreviatura.

@Override
@Transactional(readOnly = true)
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public AbreviaturaDTO findAbreviatura(Long id) {
    AbreviaturaDAO dao = factory.getAbreviaturaDAO();
    Abreviatura abreviatura = null;
    try {
        abreviatura = 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 (abreviatura != null) {
        return abreviatura.createDTO();
    } else {
        return null;
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) Abreviatura(com.tomasio.projects.trainning.model.Abreviatura) CoreException(com.tomasio.projects.trainning.exeption.CoreException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) DAOException(com.tomasio.projects.trainning.exception.DAOException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with Abreviatura

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

the class HibernateAbreviaturaDAO method findAll.

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

Example 3 with Abreviatura

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

the class TeachingDocumentsServiceSimpleImpl method updateAbreviatura.

@Override
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
@Transactional
public void updateAbreviatura(AbreviaturaDTO abreviatura) {
    AbreviaturaDAO dao = factory.getAbreviaturaDAO();
    Abreviatura model = new Abreviatura(abreviatura);
    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) Abreviatura(com.tomasio.projects.trainning.model.Abreviatura) CoreException(com.tomasio.projects.trainning.exeption.CoreException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) DAOException(com.tomasio.projects.trainning.exception.DAOException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with Abreviatura

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

the class TeachingDocumentsServiceSimpleImpl method createAbreviatura.

@Override
@Transactional
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public Long createAbreviatura(AbreviaturaDTO abreviatura) {
    AbreviaturaDAO dao = factory.getAbreviaturaDAO();
    Abreviatura model = new Abreviatura(abreviatura);
    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) Abreviatura(com.tomasio.projects.trainning.model.Abreviatura) CoreException(com.tomasio.projects.trainning.exeption.CoreException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) DAOException(com.tomasio.projects.trainning.exception.DAOException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with Abreviatura

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

the class TeachingDocumentsServiceSimpleImpl method findAllAbreviaturasByPUD.

@Override
@Transactional(readOnly = true)
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public AbreviaturaDTO[] findAllAbreviaturasByPUD(Long pudId) {
    AbreviaturaDAO dao = factory.getAbreviaturaDAO();
    AbreviaturaDTO[] abreviaturasArray = null;
    try {
        List<Abreviatura> abreviaturas = dao.findAll(pudId);
        abreviaturasArray = new AbreviaturaDTO[abreviaturas.size()];
        for (int i = 0; i < abreviaturasArray.length; i++) {
            abreviaturasArray[i] = abreviaturas.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 abreviaturasArray;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) Abreviatura(com.tomasio.projects.trainning.model.Abreviatura) CoreException(com.tomasio.projects.trainning.exeption.CoreException) AbreviaturaDTO(com.tomasio.projects.trainning.dto.AbreviaturaDTO) CoreException(com.tomasio.projects.trainning.exeption.CoreException) DAOException(com.tomasio.projects.trainning.exception.DAOException) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

DAOException (com.tomasio.projects.trainning.exception.DAOException)6 Abreviatura (com.tomasio.projects.trainning.model.Abreviatura)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 AbreviaturaDTO (com.tomasio.projects.trainning.dto.AbreviaturaDTO)1 Criteria (org.hibernate.Criteria)1