Search in sources :

Example 1 with AreaEnsino

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

the class TeachingDocumentsServiceSimpleImpl method createAreaConhecimento.

@Override
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
@Transactional
public Long createAreaConhecimento(AreaEnsinoDTO areaConhecimento) {
    AreaConhecimentoDAO dao = factory.getAreaConhecimentoDAO();
    AreaEnsino _areaEnsino = new AreaEnsino(areaConhecimento);
    Long id = null;
    try {
        id = dao.createAreaConhecimento(_areaEnsino);
    } catch (DAOException ex) {
        throw new CoreException(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) AreaEnsino(com.tomasio.projects.trainning.model.AreaEnsino) CoreException(com.tomasio.projects.trainning.exeption.CoreException) DAOException(com.tomasio.projects.trainning.exception.DAOException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with AreaEnsino

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

the class HibernateAreaConhecimentoDAO method findAllAreasConhecimento.

@SuppressWarnings("unchecked")
@Override
public List<AreaEnsino> findAllAreasConhecimento() throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    List<AreaEnsino> areas;
    try {
        Criteria criteria = session.createCriteria(AreaEnsino.class);
        areas = criteria.list();
        return areas;
    } catch (HibernateException e) {
        Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("indicadores.find.unique.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) HibernateException(org.hibernate.HibernateException) AreaEnsino(com.tomasio.projects.trainning.model.AreaEnsino) Criteria(org.hibernate.Criteria) Session(org.hibernate.Session)

Example 3 with AreaEnsino

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

the class TeachingDocumentsServiceSimpleImpl method findAreaConhecimento.

@Override
@Transactional(readOnly = true)
public AreaEnsinoDTO findAreaConhecimento(Long id) {
    AreaConhecimentoDAO dao = factory.getAreaConhecimentoDAO();
    AreaEnsino area = null;
    try {
        area = dao.findAreaConhecimento(id);
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    }
    if (!(area == null)) {
        return area.createDTO();
    } else {
        return null;
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) AreaEnsino(com.tomasio.projects.trainning.model.AreaEnsino) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with AreaEnsino

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

the class TeachingDocumentsServiceSimpleImpl method findAllAreasConhecimento.

@Override
@Transactional(readOnly = true)
public AreaEnsinoDTO[] findAllAreasConhecimento() {
    AreaConhecimentoDAO dao = factory.getAreaConhecimentoDAO();
    AreaEnsinoDTO[] areasArray = null;
    try {
        List<AreaEnsino> areas = dao.findAllAreasConhecimento();
        if (areas != null) {
            areasArray = new AreaEnsinoDTO[areas.size()];
            for (int i = 0; i < areas.size(); i++) {
                areasArray[i] = areas.get(i).createDTO();
            }
        }
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    }
    return areasArray;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) AreaEnsino(com.tomasio.projects.trainning.model.AreaEnsino) AreaEnsinoDTO(com.tomasio.projects.trainning.dto.AreaEnsinoDTO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with AreaEnsino

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

the class TeachingDocumentsServiceSimpleImpl method updateAreaConhecimento.

@Override
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
@Transactional
public void updateAreaConhecimento(AreaEnsinoDTO areaConhecimento) {
    AreaConhecimentoDAO dao = factory.getAreaConhecimentoDAO();
    AreaEnsino _areaEnsino = new AreaEnsino(areaConhecimento);
    Long id = null;
    try {
        dao.updateAreaConhecimento(_areaEnsino);
    } catch (DAOException ex) {
        throw new CoreException(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) AreaEnsino(com.tomasio.projects.trainning.model.AreaEnsino) 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 AreaEnsino (com.tomasio.projects.trainning.model.AreaEnsino)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 AreaEnsinoDTO (com.tomasio.projects.trainning.dto.AreaEnsinoDTO)1 Criteria (org.hibernate.Criteria)1