Search in sources :

Example 1 with AnexoApostila

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

the class TeachingDocumentsServiceSimpleImpl method createAnexoApostila.

@Override
@Transactional
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public Long createAnexoApostila(AnexoApostilaDTO anexo) {
    AnexoApostilaDAO dao = factory.getAnexoApostilaDAO();
    AnexoApostila model = new AnexoApostila(anexo);
    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) AnexoApostila(com.tomasio.projects.trainning.model.AnexoApostila) 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 AnexoApostila

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

the class TeachingDocumentsServiceSimpleImpl method findAllAnexosApostilas.

@Override
@Transactional(readOnly = true)
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public AnexoApostilaDTO[] findAllAnexosApostilas(Long apostilaId) {
    AnexoApostilaDAO dao = factory.getAnexoApostilaDAO();
    AnexoApostilaDTO[] anexosArray = null;
    try {
        List<AnexoApostila> anexos = dao.findAllAnexosApostilas(apostilaId);
        anexosArray = new AnexoApostilaDTO[anexos.size()];
        for (int i = 0; i < anexosArray.length; i++) {
            anexosArray[i] = anexos.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 anexosArray;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) AnexoApostila(com.tomasio.projects.trainning.model.AnexoApostila) CoreException(com.tomasio.projects.trainning.exeption.CoreException) AnexoApostilaDTO(com.tomasio.projects.trainning.dto.AnexoApostilaDTO) CoreException(com.tomasio.projects.trainning.exeption.CoreException) DAOException(com.tomasio.projects.trainning.exception.DAOException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with AnexoApostila

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

the class TeachingDocumentsServiceSimpleImpl method updateAnexoApostila.

@Override
@Transactional
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public void updateAnexoApostila(AnexoApostilaDTO anexo) {
    AnexoApostilaDAO dao = factory.getAnexoApostilaDAO();
    AnexoApostila model = new AnexoApostila(anexo);
    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) AnexoApostila(com.tomasio.projects.trainning.model.AnexoApostila) 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 AnexoApostila

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

the class TeachingDocumentsServiceSimpleImpl method findAnexoApostila.

@Override
@Transactional(readOnly = true)
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public AnexoApostilaDTO findAnexoApostila(Long id) {
    AnexoApostilaDAO dao = factory.getAnexoApostilaDAO();
    AnexoApostila anexo = null;
    try {
        anexo = 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 (anexo != null) {
        return anexo.createDTO();
    } else {
        return null;
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) AnexoApostila(com.tomasio.projects.trainning.model.AnexoApostila) 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 AnexoApostila

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

the class HibernateAnexoApostilaDAO method remove.

@Override
public void remove(Long id) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    AnexoApostila anexo = (AnexoApostila) session.get(AnexoApostila.class, id);
    try {
        session.delete(anexo);
    } catch (HibernateException e) {
        Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("anexos.remove.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) AnexoApostila(com.tomasio.projects.trainning.model.AnexoApostila) HibernateException(org.hibernate.HibernateException) Session(org.hibernate.Session)

Aggregations

DAOException (com.tomasio.projects.trainning.exception.DAOException)5 AnexoApostila (com.tomasio.projects.trainning.model.AnexoApostila)5 CoreException (com.tomasio.projects.trainning.exeption.CoreException)4 Transactional (org.springframework.transaction.annotation.Transactional)4 AnexoApostilaDTO (com.tomasio.projects.trainning.dto.AnexoApostilaDTO)1 HibernateException (org.hibernate.HibernateException)1 Session (org.hibernate.Session)1