Search in sources :

Example 1 with ComplementacaoInstrucao

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

the class TeachingDocumentsServiceSimpleImpl method findComplementacaoInstrucao.

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

Example 2 with ComplementacaoInstrucao

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

the class TeachingDocumentsServiceSimpleImpl method findAllComplementacoesInstrucaoByPUD.

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

Example 3 with ComplementacaoInstrucao

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

the class TeachingDocumentsServiceSimpleImpl method updateComplementacaoInstrucao.

@Override
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
@Transactional
public void updateComplementacaoInstrucao(ComplementacaoInstrucaoDTO complementacao) {
    ComplementacaoInstrucaoDAO dao = factory.getComplementacaoInstrucaoDAO();
    ComplementacaoInstrucao model = new ComplementacaoInstrucao(complementacao);
    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) ComplementacaoInstrucao(com.tomasio.projects.trainning.model.ComplementacaoInstrucao) CoreException(com.tomasio.projects.trainning.exeption.CoreException) DAOException(com.tomasio.projects.trainning.exception.DAOException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with ComplementacaoInstrucao

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

the class TeachingDocumentsServiceSimpleImpl method createComplementacaoInstrucao.

@Override
@Transactional
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public Long createComplementacaoInstrucao(ComplementacaoInstrucaoDTO complementacao) {
    ComplementacaoInstrucaoDAO dao = factory.getComplementacaoInstrucaoDAO();
    ComplementacaoInstrucao model = new ComplementacaoInstrucao(complementacao);
    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) ComplementacaoInstrucao(com.tomasio.projects.trainning.model.ComplementacaoInstrucao) CoreException(com.tomasio.projects.trainning.exeption.CoreException) DAOException(com.tomasio.projects.trainning.exception.DAOException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with ComplementacaoInstrucao

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

the class HibernateComplementacaoInstrucaoDAO method findAll.

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

Aggregations

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