Search in sources :

Example 1 with Conceituacao

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

the class TeachingDocumentsServiceSimpleImpl method findConceituacao.

@Override
@Transactional(readOnly = true)
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public ConceituacaoDTO findConceituacao(Long id) {
    ConceituacaoDAO dao = factory.getConceituacaoDAO();
    Conceituacao conceituacao = null;
    try {
        conceituacao = 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 (conceituacao != null) {
        return conceituacao.createDTO();
    } else {
        return null;
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) Conceituacao(com.tomasio.projects.trainning.model.Conceituacao) 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 Conceituacao

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

the class TeachingDocumentsServiceSimpleImpl method updateConceituacao.

@Override
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
@Transactional
public void updateConceituacao(ConceituacaoDTO conceituacao) {
    ConceituacaoDAO dao = factory.getConceituacaoDAO();
    Conceituacao model = new Conceituacao(conceituacao);
    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) Conceituacao(com.tomasio.projects.trainning.model.Conceituacao) 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 3 with Conceituacao

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

the class TeachingDocumentsServiceSimpleImpl method createConceituacao.

@Override
@Transactional
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public Long createConceituacao(ConceituacaoDTO conceituacao) {
    ConceituacaoDAO dao = factory.getConceituacaoDAO();
    Conceituacao model = new Conceituacao(conceituacao);
    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) Conceituacao(com.tomasio.projects.trainning.model.Conceituacao) 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 Conceituacao

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

the class TeachingDocumentsServiceSimpleImpl method findAllConceituacoesByPUD.

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

Example 5 with Conceituacao

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

the class HibernateConceituacaoDAO method remove.

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

Aggregations

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