use of com.tomasio.projects.trainning.dto.ApostilaDTO in project trainning by fernandotomasio.
the class Apostila method createDTO.
public ApostilaDTO createDTO() {
ApostilaDTO dto = new ApostilaDTO();
dto.setId(id);
dto.setDefinicoes(definicoes);
dto.setFolderId(folderId);
dto.setIntroducao(introducao);
dto.setAssetsFolderId(assetsFolderId);
if (disciplina != null) {
dto.setDisciplina(disciplina.createDTO());
}
return dto;
}
use of com.tomasio.projects.trainning.dto.ApostilaDTO 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.dto.ApostilaDTO in project trainning by fernandotomasio.
the class DOC003PDF method makeReport.
@Override
public void makeReport() {
teachingDocumentsService = (TeachingDocumentsService) services.get("teachingDocumentsService");
document = documentManager.getDocumentPortrait();
os = documentManager.prepareDocument(document);
writer = documentManager.getWritter();
ChapterSectionTOC eventHandler = new ChapterSectionTOC();
writer.setPageEvent(eventHandler);
document.open();
CSSResolver cssResolver = new StyleAttrCSSResolver();
CssFile cssFile = null;
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
String cssStylePath = classLoader.getResource("doc3-styles.css").getPath();
cssFile = XMLWorkerHelper.getCSS(classLoader.getResourceAsStream("doc3-styles.css"));
cssResolver.addCss(cssFile);
XMLWorkerFontProvider fontProvider = new XMLWorkerFontProvider(XMLWorkerFontProvider.DONTLOOKFORFONTS);
String fontFilePath = classLoader.getResource("MyriadPro-Regular.otf").getPath();
// fontProvider.register(fontFilePath);
CssAppliers cssAppliers = new CssAppliersImpl(fontProvider);
HtmlPipelineContext htmlContext = new HtmlPipelineContext(cssAppliers);
htmlContext.setTagFactory(Tags.getHtmlTagProcessorFactory());
PdfWriterPipeline pdf = new PdfWriterPipeline(document, writer);
HtmlPipeline html = new HtmlPipeline(htmlContext, pdf);
CssResolverPipeline css = new CssResolverPipeline(cssResolver, html);
XMLWorker worker = new XMLWorker(css, true);
p = new XMLParser(worker);
try {
String apostilaIdParam = (String) params.get("apostilaId");
Long apostilaId = Long.parseLong(apostilaIdParam);
ApostilaDTO apostila = teachingDocumentsService.findApostila(apostilaId);
CurriculoMinimoDTO curriculo = teachingDocumentsService.findCurriculoMinimo(apostila.getDisciplina().getCurriculoMinimo().getId());
buildCover(document, curriculo, apostila);
CapituloApostilaDTO[] capitulos = teachingDocumentsService.findAllCapitulosApostila(apostilaId);
for (CapituloApostilaDTO capitulo : capitulos) {
Chapter ch = buildCapitulo(capitulo, p, document);
document.add(ch);
}
document.add(buildReferencias(apostilaId));
document.add(buildSumario(eventHandler.titles));
} catch (DocumentException e) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, e);
throw new CoreException(e.getMessage());
} catch (IOException ex) {
Logger.getLogger(DOC003PDF.class.getName()).log(Level.SEVERE, null, ex);
} finally {
document.close();
}
try {
PdfReader reader = new PdfReader(os.toByteArray());
int n = reader.getNumberOfPages();
String pagesInterval = String.format("1-2,%d, 3-%d", n, n - 1);
reader.selectPages(pagesInterval);
os = new ByteArrayOutputStream();
PdfStamper stamper = new PdfStamper(reader, os);
stamper.close();
reader.close();
} catch (IOException | DocumentException ex) {
Logger.getLogger(DOC003PDF.class.getName()).log(Level.SEVERE, null, ex);
}
}
use of com.tomasio.projects.trainning.dto.ApostilaDTO in project trainning by fernandotomasio.
the class DOC003PDF method buildReferencias.
private Chapter buildReferencias(Long apostilaId) {
ApostilaDTO apostila = teachingDocumentsService.findApostila(apostilaId);
ReferenciaDTO[] referencias = teachingDocumentsService.findAllReferenciasByDisciplina(apostila.getDisciplina().getId());
String referenciasLabel = "REFERÊNCIAS";
Paragraph referenciasChapter = new Paragraph(referenciasLabel, fontManager.getBoldFont());
referenciasChapter.setAlignment(Element.ALIGN_CENTER);
Chapter ch = new Chapter(referenciasChapter, 0);
ch.setNumberDepth(0);
ch.add(Chunk.NEWLINE);
for (ReferenciaDTO referencia : referencias) {
ch.add(new Paragraph(referencia.getTexto(), fontManager.getDefaultFont()));
}
return ch;
}
use of com.tomasio.projects.trainning.dto.ApostilaDTO in project trainning by fernandotomasio.
the class ApostilasController method detailApostila.
@RequestMapping("/detail")
public String detailApostila(Model model, WebRequest request) {
String apostilaIdParam = request.getParameter("apostilaId");
Long apostilaId = Long.parseLong(apostilaIdParam);
ApostilaDTO apostila = teachingDocumentsService.findApostila(apostilaId);
model.addAttribute("apostila", apostila);
CapituloApostilaDTO[] capitulos = teachingDocumentsService.findAllCapitulosApostila(apostila.getId());
List capitulosDataList = new ArrayList();
for (CapituloApostilaDTO capitulo : capitulos) {
Map itemCapitulo = new HashMap();
itemCapitulo.put("id", capitulo.getId());
UnidadeDidaticaDTO unidadeDidatica = teachingDocumentsService.findUnidadeDidatica(capitulo.getUnidadeDidatica().getId());
itemCapitulo.put("numero", unidadeDidatica.getNumeroGeral());
itemCapitulo.put("titulo", capitulo.getUnidadeDidatica().getDescricao());
SecaoApostilaDTO[] secoes = teachingDocumentsService.findAllSecoesApostila(capitulo.getId());
List secoesApostilaDataList = new ArrayList();
for (SecaoApostilaDTO secao : secoes) {
Map itemSecao = new HashMap();
itemSecao.put("id", secao.getId());
itemSecao.put("titulo", secao.getSubunidadeDidatica().getDescricao());
SubunidadeDidaticaDTO subunidadeDidatica = teachingDocumentsService.findSubunidadeDidatica(secao.getSubunidadeDidatica().getId());
itemSecao.put("numero", subunidadeDidatica.getNumeroGeral());
secoesApostilaDataList.add(itemSecao);
}
itemCapitulo.put("secoes", secoesApostilaDataList);
capitulosDataList.add(itemCapitulo);
}
List anexosDataList = new ArrayList();
AnexoApostilaDTO[] anexos = teachingDocumentsService.findAllAnexosApostilas(apostila.getId());
for (AnexoApostilaDTO anexo : anexos) {
Map item = new HashMap();
item.put("id", anexo.getId());
item.put("titulo", anexo.getTitulo());
anexosDataList.add(item);
}
model.addAttribute("capitulosDataList", capitulosDataList);
model.addAttribute("anexosDataList", anexosDataList);
return "apostilas/detail";
}
Aggregations