Search in sources :

Example 1 with SecaoApostila

use of com.tomasio.projects.trainning.model.SecaoApostila 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 2 with SecaoApostila

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

the class TeachingDocumentsServiceSimpleImpl method updateSecaoApostila.

@Override
@Transactional
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public void updateSecaoApostila(SecaoApostilaDTO secao) {
    SecaoApostilaDAO dao = factory.getSecaoApostilaDAO();
    SecaoApostila model = new SecaoApostila(secao);
    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) SecaoApostila(com.tomasio.projects.trainning.model.SecaoApostila) 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 SecaoApostila

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

the class TeachingDocumentsServiceSimpleImpl method findSecaoApostila.

@Override
@Transactional(readOnly = true)
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public SecaoApostilaDTO findSecaoApostila(Long id) {
    SecaoApostilaDAO dao = factory.getSecaoApostilaDAO();
    SecaoApostila secao = null;
    try {
        secao = 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 (secao != null) {
        return secao.createDTO();
    } else {
        return null;
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) SecaoApostila(com.tomasio.projects.trainning.model.SecaoApostila) 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 SecaoApostila

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

the class TeachingDocumentsServiceSimpleImpl method findAllSecoesApostila.

@Override
@Transactional(readOnly = true)
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public SecaoApostilaDTO[] findAllSecoesApostila(Long capituloId) {
    SecaoApostilaDAO dao = factory.getSecaoApostilaDAO();
    SecaoApostilaDTO[] secoesArray = null;
    try {
        List<SecaoApostila> secoes = dao.findAllSecoesApostila(capituloId);
        secoesArray = new SecaoApostilaDTO[secoes.size()];
        for (int i = 0; i < secoesArray.length; i++) {
            secoesArray[i] = secoes.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 secoesArray;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) SecaoApostila(com.tomasio.projects.trainning.model.SecaoApostila) SecaoApostilaDTO(com.tomasio.projects.trainning.dto.SecaoApostilaDTO) 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)

Aggregations

DAOException (com.tomasio.projects.trainning.exception.DAOException)4 CoreException (com.tomasio.projects.trainning.exeption.CoreException)4 SecaoApostila (com.tomasio.projects.trainning.model.SecaoApostila)4 Transactional (org.springframework.transaction.annotation.Transactional)4 FolderDTO (com.tomasio.projects.trainning.dto.FolderDTO)1 SecaoApostilaDTO (com.tomasio.projects.trainning.dto.SecaoApostilaDTO)1 AnexoApostila (com.tomasio.projects.trainning.model.AnexoApostila)1 Apostila (com.tomasio.projects.trainning.model.Apostila)1 CapituloApostila (com.tomasio.projects.trainning.model.CapituloApostila)1