use of com.tomasio.projects.trainning.dto.DocumentDTO in project trainning by fernandotomasio.
the class PudsController method savePublicacao.
public void savePublicacao(PublicacaoPUDForm form) {
CurriculoMinimoDTO curriculo = teachingDocumentsService.findCurriculoMinimo(form.getCurriculoMinimoId());
curriculo.setNumeroBoletimPUD(form.getNumeroBoletim());
Calendar dataBoletim = Calendar.getInstance();
curriculo.setDataBoletimPUD(dataBoletim);
SimpleDateFormat df = new SimpleDateFormat("ddMMyy");
Map services = new HashMap<>();
services.put("teachingDocumentsService", teachingDocumentsService);
services.put("ecmService", ecmService);
Map params = new HashMap<>();
params.put("curriculoMinimoId", String.valueOf(curriculo.getId()));
DOC002PDF report = new DOC002PDF(params, services);
DocumentDTO document = new DocumentDTO();
document.setContentStream(report.build());
document.setTitle("PUD do Curso " + curriculo.getCurso().getCodigo());
document.setName(curriculo.getCurso().getCodigo() + "-" + df.format(curriculo.getDataBoletimPUD().getTime()) + ".pdf");
document.setMimeType("application/pdf");
String documentUID = ecmService.createDocumentWithUUIDParent(document, "045c40a2-f22e-4c96-9a30-0de7909ef736");
if (documentUID != null) {
curriculo.setPudDocumentUID(documentUID);
teachingDocumentsService.updateCurriculoMinimo(curriculo);
}
}
use of com.tomasio.projects.trainning.dto.DocumentDTO 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.DocumentDTO in project trainning by fernandotomasio.
the class EcmController method swf.
@RequestMapping("/swf")
public void swf(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("application/x-shockwave-flash");
response.addHeader("Content-Disposition", "attachment; filename=" + "content.swf");
// PrintWriter out = response.getWriter();
ServletOutputStream out = response.getOutputStream();
String uuid = request.getParameter("uuid");
DocumentDTO content = service.findDocumentSWFByUUID(uuid);
if (content != null) {
out.write(content.getContentStream());
}
out.close();
}
use of com.tomasio.projects.trainning.dto.DocumentDTO in project trainning by fernandotomasio.
the class EcmController method download.
@RequestMapping("/download")
public void download(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String uuid = request.getParameter("uuid");
DocumentDTO content = service.findDocumentByUUID(uuid);
// response.setContentType("application/pdf");
String[] slices = content.getName().split(".");
String extension = null;
if (slices.length > 0) {
extension = slices[slices.length - 1];
}
if (extension != null) {
if (extension.toUpperCase().equals("doc".toUpperCase())) {
response.setContentType("application/msword");
} else if (extension.toUpperCase().equals("pdf".toUpperCase())) {
response.setContentType("application/pdf");
} else if (extension.toUpperCase().equals("png".toUpperCase())) {
response.setContentType("image/png");
} else if (extension.toUpperCase().equals("jpg".toUpperCase())) {
response.setContentType("image/jpeg");
} else if (extension.toUpperCase().equals("jpeg".toUpperCase())) {
response.setContentType("image/jpeg");
} else if (extension.toUpperCase().equals("docx".toUpperCase())) {
response.setContentType("application/msword");
} else if (extension.toUpperCase().equals("odt".toUpperCase())) {
response.setContentType("application/msword");
} else if (extension.toUpperCase().equals("txt".toUpperCase())) {
response.setContentType("text/plain");
} else if (extension.toUpperCase().equals("xls".toUpperCase())) {
response.setContentType("application/excel");
} else if (extension.toUpperCase().equals("ppt".toUpperCase())) {
response.setContentType("application/mspowerpoint");
} else if (extension.toUpperCase().equals("pptx".toUpperCase())) {
response.setContentType("application/mspowerpoint");
}
}
response.addHeader("Content-Disposition", "attachment; filename=" + content.getName());
ServletOutputStream out = response.getOutputStream();
out.write(content.getContentStream());
out.close();
}
use of com.tomasio.projects.trainning.dto.DocumentDTO in project trainning by fernandotomasio.
the class ImagesController method uploadFile.
@RequestMapping("/upload")
public void uploadFile(HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "upload", required = false) MultipartFile file) throws IOException {
PrintWriter out = response.getWriter();
String folderId = request.getParameter("folder");
DocumentDTO dto = new DocumentDTO();
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);
}
ecmService.createDocumentWithUUIDParent(dto, folderId);
out.print("upload realizado com sucesso!");
}
Aggregations