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;
}
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;
}
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;
}
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());
}
}
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;
}
}
Aggregations