use of com.tomasio.projects.trainning.dto.CurriculoMinimoDTO in project trainning by fernandotomasio.
the class CurriculosMinimosController method saveStep1.
public void saveStep1(CurriculoMinimoForm form) {
CMFormStep1 cMFormStep1 = form.getcMFormStep1();
CursoDTO curso = trainningService.findCurso(form.getCursoId());
if (form.getId() == null) {
CurriculoMinimoDTO curriculoMinimo = new CurriculoMinimoDTO();
curriculoMinimo.setAmbito(cMFormStep1.getAmbito());
curriculoMinimo.setConceituacoes(cMFormStep1.getConceituacoes());
curriculoMinimo.setFinalidadeInstrucao(cMFormStep1.getFinalidade());
curriculoMinimo.setCurso(curso);
Long id = teachingDocumentsService.createCurriculoMinimo(curriculoMinimo);
form.setId(id);
} else {
CurriculoMinimoDTO curriculoMinimo = teachingDocumentsService.findCurriculoMinimo(form.getId());
curriculoMinimo.setAmbito(cMFormStep1.getAmbito());
curriculoMinimo.setConceituacoes(cMFormStep1.getConceituacoes());
curriculoMinimo.setFinalidadeInstrucao(cMFormStep1.getFinalidade());
teachingDocumentsService.updateCurriculoMinimo(curriculoMinimo);
}
}
use of com.tomasio.projects.trainning.dto.CurriculoMinimoDTO in project trainning by fernandotomasio.
the class CurriculosMinimosController method saveStep4.
public void saveStep4(CurriculoMinimoForm form) {
CMFormStep4 cMFormStep4 = form.getcMFormStep4();
CurriculoMinimoDTO curriculoMinimo = teachingDocumentsService.findCurriculoMinimo(form.getId());
curriculoMinimo.setFinalidade(cMFormStep4.getFinalidade());
curriculoMinimo.setObjetivosGerais(cMFormStep4.getObjetivosGerais());
teachingDocumentsService.updateCurriculoMinimo(curriculoMinimo);
}
use of com.tomasio.projects.trainning.dto.CurriculoMinimoDTO in project trainning by fernandotomasio.
the class TeachingDocumentsServiceSimpleImpl method findAllCurriculosMinimos.
@Override
@Transactional(readOnly = true)
public CurriculoMinimoDTO[] findAllCurriculosMinimos() {
CurriculoMinimoDAO dao = factory.getCurriculoMinimoDAO();
CurriculoMinimoDTO[] curriculosArray = null;
try {
List<CurriculoMinimo> curriculos = dao.findAllCurriculosMinimos();
if (curriculos != null) {
curriculosArray = new CurriculoMinimoDTO[curriculos.size()];
for (int i = 0; i < curriculos.size(); i++) {
curriculosArray[i] = curriculos.get(i).createDTO();
}
}
} catch (DAOException ex) {
throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
}
return curriculosArray;
}
use of com.tomasio.projects.trainning.dto.CurriculoMinimoDTO in project trainning by fernandotomasio.
the class DOC001PDF method makeReport.
@Override
public void makeReport() {
teachingDocumentsService = (TeachingDocumentsService) services.get("teachingDocumentsService");
ecmService = (ECMService) services.get("ecmService");
document = documentManager.getDocumentPortrait();
os = documentManager.prepareDocument(document);
writer = documentManager.getWritter();
ChapterSectionTOC eventHandler = new ChapterSectionTOC();
writer.setPageEvent(eventHandler);
document.open();
String curriculoMinimoIdParam = (String) params.get("curriculoMinimoId");
Long curriculoMinimoId = Long.parseLong(curriculoMinimoIdParam);
CurriculoMinimoDTO curriculoMinimo = teachingDocumentsService.findCurriculoMinimo(curriculoMinimoId);
try {
// CONSTRÓI CAPA
buildCover(document, curriculoMinimo);
// CONSTRÓI FRONTISPÍCIO
buildFrontispicio(document, curriculoMinimo);
buildAtoAprovacao(document, curriculoMinimo);
document.add(buildChapter1(curriculoMinimo));
document.add(Chunk.NEXTPAGE);
document.add(buildChapter2(curriculoMinimo));
document.add(Chunk.NEXTPAGE);
document.add(buildChapter3(curriculoMinimo));
document.add(Chunk.NEXTPAGE);
document.add(buildChapter4(curriculoMinimo));
document.add(Chunk.NEXTPAGE);
document.add(buildChapter5(curriculoMinimo));
document.add(buildChapter6(curriculoMinimo));
document.add(Chunk.NEXTPAGE);
document.add(buildChapter7(curriculoMinimo));
document.add(Chunk.NEXTPAGE);
document.add(buildChapter8(curriculoMinimo));
document.add(Chunk.NEXTPAGE);
document.add(buildReferencias(curriculoMinimo));
document.add(Chunk.NEXTPAGE);
document.add(buildSumario(eventHandler.titles));
// int total = writer.reorderPages(null);
// System.out.println("total : " + total);
} catch (DocumentException e) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, e);
throw new CoreException(e.getMessage());
} finally {
document.close();
}
try {
PdfReader reader = new PdfReader(os.toByteArray());
int n = reader.getNumberOfPages();
String pagesInterval = String.format("1-4,%d, 5-%d", n, n - 1);
reader.selectPages(pagesInterval);
os = new ByteArrayOutputStream();
PdfStamper stamper = new PdfStamper(reader, os);
stamper.close();
reader.close();
System.out.println("number of pages " + reader.getNumberOfPages());
} catch (IOException ex) {
Logger.getLogger(DOC001PDF.class.getName()).log(Level.SEVERE, null, ex);
} catch (DocumentException ex) {
Logger.getLogger(DOC001PDF.class.getName()).log(Level.SEVERE, null, ex);
}
// / Experimentos
try {
PdfReader reader = new PdfReader(os.toByteArray());
os = new ByteArrayOutputStream();
PdfStamper stamper = new PdfStamper(reader, os);
int total = reader.getNumberOfPages();
PdfContentByte over = null;
int total_pages = total - 1;
for (int i = 1; i < total; i++) {
int actual_page = i - 1;
if (i > 5) {
over = stamper.getOverContent(i);
System.out.println(over);
over.beginText();
BaseFont baseFont = BaseFont.createFont(BaseFont.TIMES_ROMAN, "UTF-8", false);
over.setFontAndSize(baseFont, 12);
if ((i % 2) == 0) {
over.showTextAligned(PdfContentByte.ALIGN_RIGHT, actual_page + "/" + total_pages, 538, 803, 0);
over.showTextAligned(PdfContentByte.ALIGN_LEFT, curriculoMinimo.getNumeroPublicacaoCM() + "/" + curriculoMinimo.getAnoPublicacaoCM(), 84, 803, 0);
} else {
over.showTextAligned(PdfContentByte.ALIGN_LEFT, actual_page + "/" + total_pages, 58, 803, 0);
over.showTextAligned(PdfContentByte.ALIGN_RIGHT, curriculoMinimo.getNumeroPublicacaoCM() + "/" + curriculoMinimo.getAnoPublicacaoCM(), 510, 803, 0);
}
over.endText();
}
}
// PdfContentByte content = stamper.getOverContent(1);
// ColumnText ct = new ColumnText( content );
// ct.setSimpleColumn(50,50,50,50);
// ct.setText(new Phrase("TESTANDO"));
// ct.go();
stamper.close();
reader.close();
} catch (IOException ex) {
// Logger.getLogger(DOC001PDF.class.getName()).log(Level.SEVERE, null, ex);
} catch (DocumentException ex) {
Logger.getLogger(DOC001PDF.class.getName()).log(Level.SEVERE, null, ex);
}
}
use of com.tomasio.projects.trainning.dto.CurriculoMinimoDTO 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);
}
}
Aggregations