Search in sources :

Example 1 with CapituloApostila

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

the class TeachingDocumentsServiceSimpleImpl method findCapituloApostila.

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

Example 2 with CapituloApostila

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

the class TeachingDocumentsServiceSimpleImpl method createSecaoApostila.

@Override
@Transactional
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public Long createSecaoApostila(SecaoApostilaDTO secao) {
    SecaoApostilaDAO dao = factory.getSecaoApostilaDAO();
    ContentDAO contentDAO = factory.getContentDAO();
    CapituloApostilaDAO capituloDAO = factory.getCapituloApostilaDAO();
    ApostilaDAO apostilaDAO = factory.getApostilaDAO();
    SecaoApostila model = new SecaoApostila(secao);
    Long id = null;
    try {
        id = dao.create(model);
        model = dao.find(id);
        String folderName = String.valueOf(model.getId());
        CapituloApostila capitulo = capituloDAO.find(model.getCapituloApostila().getId());
        Apostila apostila = apostilaDAO.find(capitulo.getApostila().getId());
        FolderDTO folder = new FolderDTO();
        folder.setName(folderName);
        String assetsFolderId = contentDAO.createFolderWithUUIDParent(folder, apostila.getAssetsFolderId());
        model.setAssetsFolderId(assetsFolderId);
        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());
    }
    return id;
}
Also used : SecaoApostila(com.tomasio.projects.trainning.model.SecaoApostila) CapituloApostila(com.tomasio.projects.trainning.model.CapituloApostila) AnexoApostila(com.tomasio.projects.trainning.model.AnexoApostila) Apostila(com.tomasio.projects.trainning.model.Apostila) CapituloApostila(com.tomasio.projects.trainning.model.CapituloApostila) SecaoApostila(com.tomasio.projects.trainning.model.SecaoApostila) CoreException(com.tomasio.projects.trainning.exeption.CoreException) DAOException(com.tomasio.projects.trainning.exception.DAOException) DAOException(com.tomasio.projects.trainning.exception.DAOException) FolderDTO(com.tomasio.projects.trainning.dto.FolderDTO) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with CapituloApostila

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

the class TeachingDocumentsServiceSimpleImpl method updateCapituloApostila.

@Override
@Transactional
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public void updateCapituloApostila(CapituloApostilaDTO capitulo) {
    CapituloApostilaDAO dao = factory.getCapituloApostilaDAO();
    CapituloApostila model = new CapituloApostila(capitulo);
    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) CapituloApostila(com.tomasio.projects.trainning.model.CapituloApostila) CoreException(com.tomasio.projects.trainning.exeption.CoreException) DAOException(com.tomasio.projects.trainning.exception.DAOException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with CapituloApostila

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

the class TeachingDocumentsServiceSimpleImpl method findAllCapitulosApostila.

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

Example 5 with CapituloApostila

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

the class TeachingDocumentsServiceSimpleImpl method createCapituloApostila.

@Override
@Transactional
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public Long createCapituloApostila(CapituloApostilaDTO capitulo) {
    CapituloApostilaDAO dao = factory.getCapituloApostilaDAO();
    CapituloApostila model = new CapituloApostila(capitulo);
    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) CapituloApostila(com.tomasio.projects.trainning.model.CapituloApostila) 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 CapituloApostila (com.tomasio.projects.trainning.model.CapituloApostila)6 CoreException (com.tomasio.projects.trainning.exeption.CoreException)5 Transactional (org.springframework.transaction.annotation.Transactional)5 CapituloApostilaDTO (com.tomasio.projects.trainning.dto.CapituloApostilaDTO)1 FolderDTO (com.tomasio.projects.trainning.dto.FolderDTO)1 AnexoApostila (com.tomasio.projects.trainning.model.AnexoApostila)1 Apostila (com.tomasio.projects.trainning.model.Apostila)1 SecaoApostila (com.tomasio.projects.trainning.model.SecaoApostila)1 HibernateException (org.hibernate.HibernateException)1 Session (org.hibernate.Session)1