Search in sources :

Example 11 with CurriculoMinimoDTO

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);
    }
}
Also used : CurriculoMinimoDTO(com.tomasio.projects.trainning.dto.CurriculoMinimoDTO) CursoDTO(com.tomasio.projects.trainning.dto.CursoDTO) CMFormStep1(com.tomasio.projects.trainning.form.cm.CMFormStep1)

Example 12 with CurriculoMinimoDTO

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);
}
Also used : CMFormStep4(com.tomasio.projects.trainning.form.cm.CMFormStep4) CurriculoMinimoDTO(com.tomasio.projects.trainning.dto.CurriculoMinimoDTO)

Example 13 with CurriculoMinimoDTO

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;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) CurriculoMinimo(com.tomasio.projects.trainning.model.CurriculoMinimo) CurriculoMinimoDTO(com.tomasio.projects.trainning.dto.CurriculoMinimoDTO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 14 with CurriculoMinimoDTO

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);
    }
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) DocumentException(com.itextpdf.text.DocumentException) CurriculoMinimoDTO(com.tomasio.projects.trainning.dto.CurriculoMinimoDTO)

Example 15 with CurriculoMinimoDTO

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);
    }
}
Also used : StyleAttrCSSResolver(com.itextpdf.tool.xml.css.StyleAttrCSSResolver) CssFile(com.itextpdf.tool.xml.css.CssFile) PdfReader(com.itextpdf.text.pdf.PdfReader) CssAppliersImpl(com.itextpdf.tool.xml.html.CssAppliersImpl) CSSResolver(com.itextpdf.tool.xml.pipeline.css.CSSResolver) StyleAttrCSSResolver(com.itextpdf.tool.xml.css.StyleAttrCSSResolver) DocumentException(com.itextpdf.text.DocumentException) CapituloApostilaDTO(com.tomasio.projects.trainning.dto.CapituloApostilaDTO) CurriculoMinimoDTO(com.tomasio.projects.trainning.dto.CurriculoMinimoDTO) XMLParser(com.itextpdf.tool.xml.parser.XMLParser) HtmlPipeline(com.itextpdf.tool.xml.pipeline.html.HtmlPipeline) SecaoApostilaDTO(com.tomasio.projects.trainning.dto.SecaoApostilaDTO) ApostilaDTO(com.tomasio.projects.trainning.dto.ApostilaDTO) CapituloApostilaDTO(com.tomasio.projects.trainning.dto.CapituloApostilaDTO) Chapter(com.itextpdf.text.Chapter) IOException(java.io.IOException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) CssResolverPipeline(com.itextpdf.tool.xml.pipeline.css.CssResolverPipeline) XMLWorkerFontProvider(com.itextpdf.tool.xml.XMLWorkerFontProvider) XMLWorker(com.itextpdf.tool.xml.XMLWorker) CoreException(com.tomasio.projects.trainning.exeption.CoreException) CssAppliers(com.itextpdf.tool.xml.html.CssAppliers) PdfWriterPipeline(com.itextpdf.tool.xml.pipeline.end.PdfWriterPipeline) PdfStamper(com.itextpdf.text.pdf.PdfStamper) HtmlPipelineContext(com.itextpdf.tool.xml.pipeline.html.HtmlPipelineContext)

Aggregations

CurriculoMinimoDTO (com.tomasio.projects.trainning.dto.CurriculoMinimoDTO)36 ConclusaoPUDForm (com.tomasio.projects.trainning.form.pud.ConclusaoPUDForm)7 DisciplinaPUDForm (com.tomasio.projects.trainning.form.pud.DisciplinaPUDForm)7 PUDForm (com.tomasio.projects.trainning.form.pud.PUDForm)7 PublicacaoPUDForm (com.tomasio.projects.trainning.form.pud.PublicacaoPUDForm)7 RequestContext (org.springframework.webflow.execution.RequestContext)7 DisciplinaDTO (com.tomasio.projects.trainning.dto.DisciplinaDTO)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 ObjetivoDisciplinaDTO (com.tomasio.projects.trainning.dto.ObjetivoDisciplinaDTO)4 TecnicaEnsinoDTO (com.tomasio.projects.trainning.dto.TecnicaEnsinoDTO)4 CoreException (com.tomasio.projects.trainning.exeption.CoreException)4 SimpleDateFormat (java.text.SimpleDateFormat)4 Calendar (java.util.Calendar)4 DocumentException (com.itextpdf.text.DocumentException)3 UnidadeDidaticaDTO (com.tomasio.projects.trainning.dto.UnidadeDidaticaDTO)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 IOException (java.io.IOException)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3