Search in sources :

Example 16 with CurriculoMinimoDTO

use of com.tomasio.projects.trainning.dto.CurriculoMinimoDTO in project trainning by fernandotomasio.

the class DOC002PDF 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();
    try {
        String curriculoMinimoIdParam = (String) params.get("curriculoMinimoId");
        Long curriculoMinimoId = Long.parseLong(curriculoMinimoIdParam);
        CurriculoMinimoDTO curriculoMinimo = teachingDocumentsService.findCurriculoMinimo(curriculoMinimoId);
        buildCover(document, curriculoMinimo);
        buildFrontispicio(document, curriculoMinimo);
        document.add(buildPrefacio(curriculoMinimo));
        document.add(Chunk.NEXTPAGE);
        document.add(buildAbreviaturas(curriculoMinimo));
        document.add(Chunk.NEXTPAGE);
        document.add(buildDisposicoesPreliminares(curriculoMinimo));
        document.add(Chunk.NEXTPAGE);
        document.add(buildAtividadesComplementares(curriculoMinimo));
        document.add(Chunk.NEXTPAGE);
        document.add(buildComplementacaoInstrucao(curriculoMinimo));
        document.add(Chunk.NEXTPAGE);
        // PdfPTable tableAtividadesAvaliativas = buildAtividadesAvaliativasTable(curriculoMinimo);
        // document.add(tableAtividadesAvaliativas);
        Paragraph p12 = new Paragraph();
        p12.add(new Phrase("4 DETALHAMENTO DAS UNIDADES DIDÁTICAS", fontManager.getBoldFont()));
        document.add(p12);
        document.add(Chunk.NEWLINE);
        DisciplinaDTO[] disciplinas = teachingDocumentsService.findAllDisciplinasByCurriculoMinimo(curriculoMinimo.getId());
        for (DisciplinaDTO disciplina : disciplinas) {
            PdfPTable tableDisciplina = buildTableDisciplina(disciplina);
            document.add(tableDisciplina);
            document.add(Chunk.NEWLINE);
            UnidadeDidaticaDTO[] unidades = teachingDocumentsService.findAllUnidadesDidaticas(disciplina.getId());
            PdfPTable unidadesHeaderTable = new PdfPTable(1);
            unidadesHeaderTable.setWidthPercentage(100);
            PdfPCell p20 = new PdfPCell(new Phrase("UNIDADES DIDÁTICAS", fontManager.getBoldFont()));
            unidadesHeaderTable.addCell(p20);
            unidadesHeaderTable.setHorizontalAlignment(Element.ALIGN_CENTER);
            document.add(unidadesHeaderTable);
            document.add(Chunk.NEWLINE);
            for (UnidadeDidaticaDTO unidade : unidades) {
                PdfPTable tableUnidade = buildTableUnidade(unidade);
                document.add(tableUnidade);
                document.add(Chunk.NEWLINE);
            }
            PdfPTable tableRecomendacoes = buildTableRecomendacoesMetodologicas(disciplina);
            document.add(tableRecomendacoes);
            document.add(Chunk.NEWLINE);
            PdfPTable perfisTable = buildTablePerfisRelacionamento(disciplina);
            document.add(perfisTable);
            document.add(Chunk.NEWLINE);
            PdfPTable referenciasTable = buildTableReferencias(disciplina);
            document.add(referenciasTable);
            document.add(Chunk.NEXTPAGE);
        }
        document.add(Chunk.NEXTPAGE);
        document.add(buildDisposicoesFinais(curriculoMinimo));
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);
        document.add(buildAssinatura());
        document.add(Chunk.NEXTPAGE);
        document.add(buildSumario(eventHandler.titles));
    } 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();
    } catch (IOException ex) {
        Logger.getLogger(DOC002PDF.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DocumentException ex) {
        Logger.getLogger(DOC002PDF.class.getName()).log(Level.SEVERE, null, ex);
    }
    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);
                } else {
                    over.showTextAligned(PdfContentByte.ALIGN_LEFT, actual_page + "/" + total_pages, 58, 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 : PdfPCell(com.itextpdf.text.pdf.PdfPCell) Phrase(com.itextpdf.text.Phrase) PdfReader(com.itextpdf.text.pdf.PdfReader) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) UnidadeDidaticaDTO(com.tomasio.projects.trainning.dto.UnidadeDidaticaDTO) ObjetivoUnidadeDidaticaDTO(com.tomasio.projects.trainning.dto.ObjetivoUnidadeDidaticaDTO) Paragraph(com.itextpdf.text.Paragraph) PdfPTable(com.itextpdf.text.pdf.PdfPTable) CoreException(com.tomasio.projects.trainning.exeption.CoreException) PdfStamper(com.itextpdf.text.pdf.PdfStamper) DocumentException(com.itextpdf.text.DocumentException) DisciplinaDTO(com.tomasio.projects.trainning.dto.DisciplinaDTO) ObjetivoDisciplinaDTO(com.tomasio.projects.trainning.dto.ObjetivoDisciplinaDTO) BaseFont(com.itextpdf.text.pdf.BaseFont) CurriculoMinimoDTO(com.tomasio.projects.trainning.dto.CurriculoMinimoDTO) PdfContentByte(com.itextpdf.text.pdf.PdfContentByte)

Example 17 with CurriculoMinimoDTO

use of com.tomasio.projects.trainning.dto.CurriculoMinimoDTO in project trainning by fernandotomasio.

the class ApostilasController method go.

@RequestMapping("/go")
public String go(Model model, WebRequest request) {
    String curriculoMinimoIdParam = request.getParameter("curriculoMinimoId");
    if (curriculoMinimoIdParam == null) {
        model.addAttribute("curriculosDataList", initializeCurriculosDataList());
        return "apostilas/select_cm";
    }
    Long curriculoMinimoId = Long.parseLong(curriculoMinimoIdParam);
    CurriculoMinimoDTO curriculo = teachingDocumentsService.findCurriculoMinimo(curriculoMinimoId);
    model.addAttribute("curriculoMinimo", curriculo);
    return "redirect:/apostilas";
}
Also used : CurriculoMinimoDTO(com.tomasio.projects.trainning.dto.CurriculoMinimoDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 18 with CurriculoMinimoDTO

use of com.tomasio.projects.trainning.dto.CurriculoMinimoDTO in project trainning by fernandotomasio.

the class CommonsController method initializeSelectableCurriculos.

public Map<Object, Object> initializeSelectableCurriculos() {
    Map<Object, Object> result = new HashMap<>();
    CurriculoMinimoDTO[] curriculos = teachingDocumentsService.findAllCurriculosMinimos();
    for (CurriculoMinimoDTO curriculo : curriculos) {
        result.put(curriculo.getId(), curriculo.getCurso().getCodigo() + " - " + curriculo.getCurso().getDescricao());
    }
    return result;
}
Also used : CurriculoMinimoDTO(com.tomasio.projects.trainning.dto.CurriculoMinimoDTO)

Example 19 with CurriculoMinimoDTO

use of com.tomasio.projects.trainning.dto.CurriculoMinimoDTO in project trainning by fernandotomasio.

the class CurriculosMinimosController method saveDisciplina.

public void saveDisciplina(DisciplinaCMForm disciplinaCMForm) {
    RequestContext requestContext = RequestContextHolder.getRequestContext();
    CurriculoMinimoForm cmForm = requestContext.getFlowScope().get("cMForm", CurriculoMinimoForm.class);
    CurriculoMinimoDTO curriculoMinimo = teachingDocumentsService.findCurriculoMinimo(cmForm.getId());
    DisciplinaDTO disciplina = new DisciplinaDTO();
    disciplina.setNumeroDisciplina(disciplinaCMForm.getNumero());
    disciplina.setId(disciplinaCMForm.getId());
    disciplina.setDescricao(disciplinaCMForm.getDescricao());
    disciplina.setQuantidadeTemposAula(disciplinaCMForm.getCargaHorariaInstrucao());
    disciplina.setQuantidadeTemposAvaliacao(disciplinaCMForm.getCargaHorariaAvaliacao());
    disciplina.setCurriculoMinimo(curriculoMinimo);
    AreaEnsinoDTO area = teachingDocumentsService.findAreaConhecimento(disciplinaCMForm.getAreaEnsinoId());
    disciplina.setAreaEnsino(area);
    CampoDTO campo = teachingDocumentsService.findCampo(disciplinaCMForm.getCampoId());
    disciplina.setCampo(campo);
    disciplinaCMForm.setCampoLabel(campo.getDescricao());
    disciplinaCMForm.setAreaEnsinoLabel(area.getNome());
    if (disciplina.getId() == null) {
        Long id = teachingDocumentsService.createDisciplina(disciplina);
        disciplinaCMForm.setId(id);
        List<DisciplinaCMForm> disciplinasDataList = cmForm.getDisciplinasDataList();
        disciplinasDataList.add(disciplinaCMForm);
    } else {
        teachingDocumentsService.updateDisciplina(disciplina);
    }
}
Also used : DisciplinaDTO(com.tomasio.projects.trainning.dto.DisciplinaDTO) ObjetivoDisciplinaDTO(com.tomasio.projects.trainning.dto.ObjetivoDisciplinaDTO) CampoDTO(com.tomasio.projects.trainning.dto.CampoDTO) DisciplinaCMForm(com.tomasio.projects.trainning.form.cm.DisciplinaCMForm) CurriculoMinimoDTO(com.tomasio.projects.trainning.dto.CurriculoMinimoDTO) RequestContext(org.springframework.webflow.execution.RequestContext) CurriculoMinimoForm(com.tomasio.projects.trainning.form.cm.CurriculoMinimoForm) AreaEnsinoDTO(com.tomasio.projects.trainning.dto.AreaEnsinoDTO)

Example 20 with CurriculoMinimoDTO

use of com.tomasio.projects.trainning.dto.CurriculoMinimoDTO in project trainning by fernandotomasio.

the class CurriculosMinimosController method saveStep7.

public void saveStep7(CurriculoMinimoForm form) {
    CMFormStep7 cMFormStep7 = form.getcMFormStep7();
    CurriculoMinimoDTO curriculoMinimo = teachingDocumentsService.findCurriculoMinimo(form.getId());
    curriculoMinimo.setDisposicoesGerais(cMFormStep7.getDisposicoesGerais());
    teachingDocumentsService.updateCurriculoMinimo(curriculoMinimo);
}
Also used : CMFormStep7(com.tomasio.projects.trainning.form.cm.CMFormStep7) CurriculoMinimoDTO(com.tomasio.projects.trainning.dto.CurriculoMinimoDTO)

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