Search in sources :

Example 1 with Apostila

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

the class TeachingDocumentsServiceSimpleImpl method findAllApostilas.

@Override
@Transactional(readOnly = true)
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public ApostilaDTO[] findAllApostilas(Long curriculoMinimoId) {
    ApostilaDAO dao = factory.getApostilaDAO();
    ApostilaDTO[] apostilasArray = null;
    try {
        List<Apostila> apostilas = dao.findAllApostilas(curriculoMinimoId);
        apostilasArray = new ApostilaDTO[apostilas.size()];
        for (int i = 0; i < apostilasArray.length; i++) {
            apostilasArray[i] = apostilas.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 apostilasArray;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) AnexoApostilaDTO(com.tomasio.projects.trainning.dto.AnexoApostilaDTO) SecaoApostilaDTO(com.tomasio.projects.trainning.dto.SecaoApostilaDTO) ApostilaDTO(com.tomasio.projects.trainning.dto.ApostilaDTO) CapituloApostilaDTO(com.tomasio.projects.trainning.dto.CapituloApostilaDTO) 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) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with Apostila

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

the class TeachingDocumentsServiceSimpleImpl method createApostila.

@Override
@Transactional
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public Long createApostila(ApostilaDTO apostila) {
    ApostilaDAO dao = factory.getApostilaDAO();
    ContentDAO contentDAO = factory.getContentDAO();
    String documentsRoot = "SGC/Material Didático/Apostilas";
    Apostila model = new Apostila(apostila);
    Long id = null;
    try {
        id = dao.create(model);
        model = dao.find(id);
        String folderName = apostila.getDisciplina().getCurriculoMinimo().getCurso().getCodigo() + "_" + model.getId() + "_" + apostila.getDisciplina().getNumeroGeral() + "_" + apostila.getDisciplina().getDescricao();
        String finalPath = documentsRoot + "/" + folderName;
        if (contentDAO.contentExistsByPath(finalPath) == false) {
            FolderDTO folder = new FolderDTO();
            folder.setName(folderName);
            String folderId = contentDAO.createFolder(folder, documentsRoot);
            FolderDTO assetsFolder = new FolderDTO();
            assetsFolder.setName("assets");
            String assetsFolderId = contentDAO.createFolderWithUUIDParent(assetsFolder, folderId);
            model.setAssetsFolderId(assetsFolderId);
            model.setFolderId(folderId);
            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 : DAOException(com.tomasio.projects.trainning.exception.DAOException) FolderDTO(com.tomasio.projects.trainning.dto.FolderDTO) CoreException(com.tomasio.projects.trainning.exeption.CoreException) 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) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with Apostila

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

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

the class TeachingDocumentsServiceSimpleImpl method updateApostila.

@Override
@Transactional
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public void updateApostila(ApostilaDTO apostila) {
    ApostilaDAO dao = factory.getApostilaDAO();
    Apostila model = new Apostila(apostila);
    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) 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) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with Apostila

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

the class TeachingDocumentsServiceSimpleImpl method findApostila.

@Override
@Transactional(readOnly = true)
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public ApostilaDTO findApostila(Long id) {
    ApostilaDAO dao = factory.getApostilaDAO();
    Apostila apostila = null;
    try {
        apostila = 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 (apostila != null) {
        return apostila.createDTO();
    } else {
        return null;
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) 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) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

DAOException (com.tomasio.projects.trainning.exception.DAOException)6 Apostila (com.tomasio.projects.trainning.model.Apostila)6 CoreException (com.tomasio.projects.trainning.exeption.CoreException)5 AnexoApostila (com.tomasio.projects.trainning.model.AnexoApostila)5 CapituloApostila (com.tomasio.projects.trainning.model.CapituloApostila)5 SecaoApostila (com.tomasio.projects.trainning.model.SecaoApostila)5 Transactional (org.springframework.transaction.annotation.Transactional)5 FolderDTO (com.tomasio.projects.trainning.dto.FolderDTO)2 AnexoApostilaDTO (com.tomasio.projects.trainning.dto.AnexoApostilaDTO)1 ApostilaDTO (com.tomasio.projects.trainning.dto.ApostilaDTO)1 CapituloApostilaDTO (com.tomasio.projects.trainning.dto.CapituloApostilaDTO)1 SecaoApostilaDTO (com.tomasio.projects.trainning.dto.SecaoApostilaDTO)1 HibernateException (org.hibernate.HibernateException)1 Session (org.hibernate.Session)1