use of com.tomasio.projects.trainning.dto.FolderDTO in project trainning by fernandotomasio.
the class TurmasEfetivasController method saveDocumento.
@RequestMapping("/save_documento")
public String saveDocumento(Model model, @Valid Documento documento, BindingResult bindingResult, @RequestParam(value = "file", required = false) MultipartFile file, WebRequest request) {
SimpleDateFormat df = new SimpleDateFormat("yyyy");
String turmaId = request.getParameter("turmaId");
TurmaEfetivaDTO turma = atividadesEnsinoService.findTurmaEfetiva(Long.parseLong(turmaId));
String folderId = turma.getFolderId();
String folderName = df.format(turma.getExercicio()) + "_" + turma.getCurso().getCodigo() + "_" + turma.getNumeroTurma() + "_" + turma.getId();
String documentsRoot = "SGC/Documentos de Treinamentos";
if (bindingResult.hasErrors()) {
return "turmas_efetivas/form_documento";
}
if (!file.isEmpty()) {
DocumentDTO dto = new DocumentDTO();
dto.setTitle(documento.getTitle());
dto.setDescription(documento.getDescription());
dto.setName(file.getOriginalFilename());
dto.setMimeType(file.getContentType());
try {
byte[] content = file.getBytes();
dto.setContentStream(content);
} catch (IOException ex) {
Logger.getLogger(TurmasEfetivasController.class.getName()).log(Level.SEVERE, null, ex);
}
if (folderId == null || folderId.equals("")) {
FolderDTO folder = new FolderDTO();
folder.setName(folderName);
folderId = ecmService.createFolder(folder, documentsRoot);
turma.setFolderId(folderId);
atividadesEnsinoService.updateTurmaEfetiva(turma);
model.addAttribute("turma", turma);
ecmService.createDocumentWithUUIDParent(dto, folderId);
} else {
boolean folderExists = ecmService.contentExistsByUUID(folderId);
if (folderExists) {
ecmService.createDocumentWithUUIDParent(dto, folderId);
} else {
FolderDTO folder = new FolderDTO();
folder.setName(folderName);
folderId = ecmService.createFolder(folder, documentsRoot);
turma.setFolderId(folderId);
atividadesEnsinoService.updateTurmaEfetiva(turma);
model.addAttribute("turma", turma);
ecmService.createDocumentWithUUIDParent(dto, folderId);
}
}
}
model.addAttribute("tab", "documentos");
return "redirect:detail/documentos";
}
use of com.tomasio.projects.trainning.dto.FolderDTO 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.dto.FolderDTO 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.dto.FolderDTO in project trainning by fernandotomasio.
the class ImportTurmasImplEfetivasFromTabelao method recuperarDocumentos.
private void recuperarDocumentos(String codCurso, String numeroTurma, TurmaEfetiva turmaCriada, Connection conn) {
SimpleDateFormat df = new SimpleDateFormat("yyyy");
ContentDAO contentDAO = new AlfrescoContentDAO();
TurmaDAO turmaDAO = new HibernateTurmaDAO();
String documentsRoot = "SGC/Documentos de Treinamentos/testes";
String oldFolderName = "D-CTP/Documentos de Treinamentos/2013/" + codCurso + "-" + numeroTurma;
String newFolderName = df.format(turmaCriada.getExercicio()) + "_" + turmaCriada.getCurso().getCodigo() + "_" + turmaCriada.getNumeroTurma() + "_" + turmaCriada.getId();
try {
WebServiceFactory.setEndpointAddress("http://dctp.decea.intraer:8080/ecm/api");
boolean existsOldFolder = contentExistsByPath(oldFolderName);
if (existsOldFolder) {
WebServiceFactory.setEndpointAddress("http://10.32.63.32:8080/alfresco/api");
FolderDTO folder = new FolderDTO();
folder.setName(newFolderName);
String folderId = contentDAO.createFolder(folder, documentsRoot);
turmaCriada.setFolderId(folderId);
turmaDAO.update(turmaCriada);
WebServiceFactory.setEndpointAddress("http://dctp.decea.intraer:8080/ecm/api");
ContentDTO[] contents = findAllContentByPath(oldFolderName);
for (ContentDTO content : contents) {
WebServiceFactory.setEndpointAddress("http://dctp.decea.intraer:8080/ecm/api");
DocumentDTO document = findDocumentByUUID(content.getUid());
document.setMimeType("application/pdf");
WebServiceFactory.setEndpointAddress("http://10.32.63.32:8080/alfresco/api");
contentDAO.createDocumentWithUUIDParent(document, folderId);
}
}
} catch (Exception ex) {
Logger.getLogger(ImportTurmasImplEfetivasFromTabelao.class.getName()).log(Level.SEVERE, null, ex);
}
}
Aggregations