Search in sources :

Example 6 with AreaDTO

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

the class AreasController method newArea.

@RequestMapping("/new")
public String newArea(Model model) {
    AreaDTO[] areas = trainningService.findAllAreas();
    AreaForm areaForm = new AreaForm();
    model.addAttribute(areaForm);
    model.addAttribute("areas", areas);
    return "areas/form";
}
Also used : AreaForm(com.tomasio.projects.trainning.form.AreaForm) AreaDTO(com.tomasio.projects.trainning.dto.AreaDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with AreaDTO

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

the class AreasController method detailArea.

@RequestMapping("/detail")
public String detailArea(Model model, WebRequest request) {
    String areaId = request.getParameter("areaId");
    AreaDTO area = trainningService.findArea(Long.parseLong(areaId));
    model.addAttribute("area", area);
    model.addAttribute("parent", area.getParent());
    return "areas/detail";
}
Also used : AreaDTO(com.tomasio.projects.trainning.dto.AreaDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with AreaDTO

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

the class AreasController method saveArea.

@RequestMapping("/save")
public String saveArea(Model model, @Valid AreaForm areaForm, BindingResult bindingResult, WebRequest request) {
    if (bindingResult.hasErrors()) {
        model.addAttribute("areas", trainningService.findAllAreas());
        return "areas/form";
    }
    AreaDTO dto = new AreaDTO();
    dto.setSigla(areaForm.getSigla());
    dto.setNome(areaForm.getNome());
    dto.setParent(trainningService.findArea(areaForm.getParentId()));
    if (areaForm.getId() > 0) {
        try {
            dto.setId(areaForm.getId());
            trainningService.updateArea(dto);
            model.addAttribute("successMessage", "Área atualizada com sucesso.");
        } catch (CoreException e) {
            model.addAttribute("errorMessage", e.getMessage());
        }
    } else {
        try {
            trainningService.createArea(dto);
            model.addAttribute("successMessage", "Área criada com sucesso.");
        } catch (CoreException e) {
            model.addAttribute("errorMessage", e.getMessage());
        }
    }
    AreaDTO[] areas = trainningService.findAllAreas();
    model.addAttribute("areas", areas);
    model.addAttribute("total", areas.length);
    return "areas";
}
Also used : CoreException(com.tomasio.projects.trainning.exeption.CoreException) AreaDTO(com.tomasio.projects.trainning.dto.AreaDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with AreaDTO

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

the class PLN004ODF method makeReport.

@Override
public void makeReport() {
    TrainningService trainningService = (TrainningService) services.get("trainningService");
    PlanningService planningService = (PlanningService) services.get("planningService");
    AtaService ataService = (AtaService) services.get("ataService");
    try {
        Long areaId = (Long) params.get("areaId");
        Long planejamentoId = (Long) params.get("planejamentoId");
        PlanejamentoDTO planejamento = planningService.findPlanejamento(planejamentoId);
        AreaDTO area = trainningService.findArea(areaId);
        ItemPlanejamentoDTO[] itensPlanejamento = planningService.findAllItensPlanejamentoByAreaId(areaId, planejamentoId);
        odt = OdfTextDocument.newTextDocument();
        odt.newParagraph("ATA DA REUNIÃO DE PLANEJAMENTO " + planejamento.getExercicioFormatted() + " DA ÁREA " + area.getNome() + " (" + area.getSigla() + ")");
        odt.newParagraph("");
        List<ItemAtaDTO> listItemAta = new ArrayList<ItemAtaDTO>();
        for (ItemPlanejamentoDTO itemPlanejamento : itensPlanejamento) {
            ItemAtaDTO[] itensAta = ataService.findAllItensAtasByItemPlanejamentoId(itemPlanejamento.getId());
            if (itensAta != null && itensAta.length > 0) {
                listItemAta.addAll(Arrays.asList(itensAta));
            }
        }
        OdfTable ataTable = OdfTable.newTable(odt, listItemAta.size() + 1, 6);
        OdfTableCell numeroHeader = ataTable.getCellByPosition(0, 0);
        numeroHeader.setStringValue("#");
        numeroHeader.setHorizontalAlignment("left");
        OdfTableCell tipoHeader = ataTable.getCellByPosition(1, 0);
        tipoHeader.setStringValue("Tipo");
        tipoHeader.setHorizontalAlignment("left");
        OdfTableCell cursoHeader = ataTable.getCellByPosition(2, 0);
        cursoHeader.setStringValue("Curso");
        cursoHeader.setHorizontalAlignment("center");
        OdfTableCell descricaoHeader = ataTable.getCellByPosition(3, 0);
        descricaoHeader.setStringValue("Descrição");
        descricaoHeader.setHorizontalAlignment("left");
        OdfTableCell reponsavelHeader = ataTable.getCellByPosition(4, 0);
        reponsavelHeader.setStringValue("Responsável");
        reponsavelHeader.setHorizontalAlignment("center");
        OdfTableCell prazoHeader = ataTable.getCellByPosition(5, 0);
        prazoHeader.setStringValue("Prazo");
        prazoHeader.setHorizontalAlignment("center");
        for (int i = 0; i < listItemAta.size(); i++) {
            ItemAtaDTO itemAtaDTO = (ItemAtaDTO) listItemAta.get(i);
            String tipo = "";
            String responsavel = "";
            String prazo = "";
            if (itemAtaDTO instanceof AcaoDTO) {
                tipo = "A";
                responsavel = ((AcaoDTO) itemAtaDTO).getResponsavel();
                prazo = ((AcaoDTO) itemAtaDTO).getPrazo();
            } else if (itemAtaDTO instanceof DecisaoDTO) {
                tipo = "D";
                responsavel = ((DecisaoDTO) itemAtaDTO).getResponsavel();
            } else {
                tipo = "C";
            }
            OdfTableCell numeroCell = ataTable.getCellByPosition(0, i + 1);
            numeroCell.setStringValue(Integer.toString(i + 1));
            OdfTableCell tipoCell = ataTable.getCellByPosition(1, i + 1);
            tipoCell.setStringValue(tipo);
            OdfTableCell cursoCell = ataTable.getCellByPosition(2, i + 1);
            cursoCell.setStringValue(itemAtaDTO.getItemPlanejamento().getCurso().getCodigo());
            OdfTableCell descricaoCell = ataTable.getCellByPosition(3, i + 1);
            descricaoCell.setStringValue(itemAtaDTO.getTexto());
            OdfTableCell responsavelCell = ataTable.getCellByPosition(4, i + 1);
            responsavelCell.setStringValue(responsavel);
            OdfTableCell prazoCell = ataTable.getCellByPosition(5, i + 1);
            prazoCell.setStringValue(prazo);
        }
        odt.newParagraph("");
        odt.newParagraph("DISTRIBUIÇAO DE VAGAS: ");
        for (ItemPlanejamentoDTO itemPlanejamento : itensPlanejamento) {
            odt.newParagraph("");
            odt.newParagraph(itemPlanejamento.getCurso().getCodigo() + " - " + itemPlanejamento.getCurso().getDescricao());
            odt.newParagraph("");
            StripItemPlanejamentoDTO[] strips = planningService.findAllStripItemPlanejamento(itemPlanejamento.getId());
            itemPlanejamento = planningService.findItemPlanejamento(itemPlanejamento.getId());
            ResponsavelAreaDTO[] responsaveis = planningService.findAllResponsaveisAnalise(itemPlanejamento.getPlanejamento().getId(), itemPlanejamento.getCurso().getArea().getId());
            OdfTable distribuicaoTable = OdfTable.newTable(odt, strips.length + 1, 7 + responsaveis.length);
            int pos_responsavel = 7;
            OdfTableCell organizacaoHeader = distribuicaoTable.getCellByPosition(0, 0);
            organizacaoHeader.setStringValue("OM");
            organizacaoHeader.setHorizontalAlignment("left");
            OdfTableCell minimoHeader = distribuicaoTable.getCellByPosition(1, 0);
            minimoHeader.setStringValue("Mínimo");
            minimoHeader.setHorizontalAlignment("center");
            OdfTableCell idealHeader = distribuicaoTable.getCellByPosition(2, 0);
            idealHeader.setStringValue("Ideal");
            idealHeader.setHorizontalAlignment("center");
            OdfTableCell existenteHeader = distribuicaoTable.getCellByPosition(3, 0);
            existenteHeader.setStringValue("Existente");
            existenteHeader.setHorizontalAlignment("center");
            OdfTableCell gapMinimoHeader = distribuicaoTable.getCellByPosition(4, 0);
            gapMinimoHeader.setStringValue("Gap Min");
            gapMinimoHeader.setHorizontalAlignment("center");
            OdfTableCell gapIdealHeader = distribuicaoTable.getCellByPosition(5, 0);
            gapIdealHeader.setStringValue("Gap Ideal");
            gapIdealHeader.setHorizontalAlignment("center");
            OdfTableCell solicitadoHeader = distribuicaoTable.getCellByPosition(6, 0);
            solicitadoHeader.setStringValue("Sol.");
            solicitadoHeader.setHorizontalAlignment("center");
            for (ResponsavelAreaDTO responsavel : responsaveis) {
                System.out.println(responsavel.getOrganizacao().getSigla());
                OdfTableCell responsavelHeader = distribuicaoTable.getCellByPosition(pos_responsavel, 0);
                responsavelHeader.setStringValue(responsavel.getOrganizacao().getSigla());
                responsavelHeader.setHorizontalAlignment("center");
                pos_responsavel++;
            }
            int linha = 1;
            for (StripItemPlanejamentoDTO stripItem : strips) {
                OdfTableCell om = distribuicaoTable.getCellByPosition(0, linha);
                om.setStringValue(stripItem.getOrganizacao().getSigla());
                om.setHorizontalAlignment("left");
                OdfTableCell minimo = distribuicaoTable.getCellByPosition(1, linha);
                minimo.setStringValue(Integer.toString(stripItem.getIndicadorMinimo()));
                minimo.setHorizontalAlignment("center");
                OdfTableCell ideal = distribuicaoTable.getCellByPosition(2, linha);
                ideal.setStringValue(Integer.toString(stripItem.getIndicadorIdeal()));
                ideal.setHorizontalAlignment("center");
                OdfTableCell existente = distribuicaoTable.getCellByPosition(3, linha);
                existente.setStringValue(Integer.toString(stripItem.getIndicadorExistente()));
                existente.setHorizontalAlignment("center");
                OdfTableCell gapMinimo = distribuicaoTable.getCellByPosition(4, linha);
                gapMinimo.setStringValue(Integer.toString(Math.abs(stripItem.getGapMinimo())));
                gapMinimo.setHorizontalAlignment("center");
                OdfTableCell gapIdeal = distribuicaoTable.getCellByPosition(5, linha);
                gapIdeal.setStringValue(Integer.toString(Math.abs(stripItem.getGapIdeal())));
                gapIdeal.setHorizontalAlignment("center");
                OdfTableCell solicitado = distribuicaoTable.getCellByPosition(6, linha);
                if (stripItem.getTreinamentoSolicitado() != null) {
                    solicitado.setStringValue(Integer.toString(stripItem.getTreinamentoSolicitado().getQuantidade()));
                } else {
                    solicitado.setStringValue("-");
                }
                solicitado.setHorizontalAlignment("center");
                Map analisesMap = stripItem.getAnalises();
                pos_responsavel = 7;
                for (ResponsavelAreaDTO responsavel : responsaveis) {
                    String quantidade = "-";
                    if (analisesMap != null) {
                        AnaliseDTO analise = (AnaliseDTO) analisesMap.get(responsavel.getOrganizacao().getId().toString());
                        if (analise != null) {
                            quantidade = String.valueOf(analise.getQuantidade());
                        }
                    }
                    OdfTableCell valor = distribuicaoTable.getCellByPosition(pos_responsavel, linha);
                    valor.setStringValue(quantidade);
                    valor.setHorizontalAlignment("center");
                    pos_responsavel++;
                }
                linha++;
            }
        }
        odt.save(os);
    } catch (Exception ex) {
        Logger.getLogger(PLN004ODF.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : PlanningService(com.tomasio.projects.trainning.interfaces.PlanningService) ItemAtaDTO(com.tomasio.projects.trainning.dto.ItemAtaDTO) ArrayList(java.util.ArrayList) DecisaoDTO(com.tomasio.projects.trainning.dto.DecisaoDTO) AreaDTO(com.tomasio.projects.trainning.dto.AreaDTO) ResponsavelAreaDTO(com.tomasio.projects.trainning.dto.ResponsavelAreaDTO) AtaService(com.tomasio.projects.trainning.interfaces.AtaService) ItemPlanejamentoDTO(com.tomasio.projects.trainning.dto.ItemPlanejamentoDTO) StripItemPlanejamentoDTO(com.tomasio.projects.trainning.dto.StripItemPlanejamentoDTO) ResponsavelAreaDTO(com.tomasio.projects.trainning.dto.ResponsavelAreaDTO) AcaoDTO(com.tomasio.projects.trainning.dto.AcaoDTO) StripItemPlanejamentoDTO(com.tomasio.projects.trainning.dto.StripItemPlanejamentoDTO) AnaliseDTO(com.tomasio.projects.trainning.dto.AnaliseDTO) ItemPlanejamentoDTO(com.tomasio.projects.trainning.dto.ItemPlanejamentoDTO) StripItemPlanejamentoDTO(com.tomasio.projects.trainning.dto.StripItemPlanejamentoDTO) PlanejamentoDTO(com.tomasio.projects.trainning.dto.PlanejamentoDTO) OdfTableCell(org.odftoolkit.odfdom.doc.table.OdfTableCell) TrainningService(com.tomasio.projects.trainning.interfaces.TrainningService) OdfTable(org.odftoolkit.odfdom.doc.table.OdfTable) Map(java.util.Map)

Example 10 with AreaDTO

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

the class MainPlanejamentoController method showIndex.

@RequestMapping({ "/", "/index", "" })
public String showIndex(Model model, @ModelAttribute("topOrganization") OrganizacaoDTO topOrganization, @ModelAttribute("userOrganization") OrganizacaoDTO userOrganization, WebRequest request) {
    String planejamentoIdParam = request.getParameter("planejamentoId");
    if (planejamentoIdParam == null || planejamentoIdParam.equals("") || planejamentoIdParam.equals("NULL")) {
        PlanejamentoDTO[] planejamentos = planningService.findAllPlanejamentos(topOrganization.getId());
        List<PlanejamentoDTO> listPlanejamento = new ArrayList<PlanejamentoDTO>();
        for (PlanejamentoDTO p : planejamentos) {
            if (p.getExercicioFormatted().equals("2018")) {
                listPlanejamento.add(p);
            }
        }
        if (planejamentos.length == 1) {
            planejamentoIdParam = planejamentos[0].getId().toString();
        } else {
            model.addAttribute("planejamentos", listPlanejamento);
            return "planejamento/select_planejamento";
        }
    }
    PlanejamentoDTO planejamento = planningService.findPlanejamento(Long.parseLong(planejamentoIdParam));
    if (planejamento == null) {
        return "404";
    }
    model.addAttribute("planejamento", planejamento);
    // Long organizacaoId = Long.parseLong("419"); //PAME
    // Long organizacaoId = Long.parseLong("112402"); //SDTE
    Long organizacaoId = userOrganization.getId();
    // TODO: Checar responsabilidade por permissões de acesso e não pelo topOrganizacao
    List<AreaDTO> areasSobResponsabilidade;
    if (organizacaoId == topOrganization.getId()) {
        areasSobResponsabilidade = Arrays.asList(trainningService.findAllAreasByPlanejamentoId(Long.parseLong(planejamentoIdParam)));
    } else {
        areasSobResponsabilidade = Arrays.asList(planningService.findAllAreasSobResponsabilidade(Long.parseLong(planejamentoIdParam), organizacaoId));
    }
    if (areasSobResponsabilidade.isEmpty()) {
        // return "403";
        areasSobResponsabilidade = Arrays.asList(trainningService.findAllAreasByPlanejamentoId(Long.parseLong(planejamentoIdParam)));
    }
    String areaIdParam = request.getParameter("areaId");
    if (areaIdParam == null || areaIdParam.equals("") || areaIdParam.equals("NULL")) {
        Collections.sort(areasSobResponsabilidade, new Comparator<AreaDTO>() {

            @Override
            public int compare(AreaDTO o1, AreaDTO o2) {
                return o1.getSigla().compareTo(o2.getSigla());
            }
        });
        AreaDTO[] areas = areasSobResponsabilidade.toArray(new AreaDTO[areasSobResponsabilidade.size()]);
        // TODO: mostrar áreas sob responsabilidade para quem não é administrador,
        // mostrar todas para quem é.
        // AreaDTO[] areas = trainningService.findAllAreasByPlanejamentoId(Long.parseLong(planejamentoIdParam));
        model.addAttribute("areas", areas);
        return "planejamento/select_area";
    }
    AreaDTO area = trainningService.findArea(Long.parseLong(areaIdParam));
    if (area == null) {
        return "404";
    }
    model.addAttribute("area", area);
    ItemPlanejamentoDTO[] itensPlanejamento = planningService.findAllItensPlanejamentoByAreaId(area.getId(), planejamento.getId());
    /**
     * Colunas na tabela de cursos indicando se o responsável já finalizou
     * sua análise
     *
     * ResponsavelAreaDTO[] responsaveisAnalise =
     * planningService.findAllResponsaveisAnalise(planejamento.getId(),
     * area.getId()); model.addAttribute("responsaveisAnalise",
     * responsaveisAnalise);
     */
    model.addAttribute("itensPlanejamento", itensPlanejamento);
    return null;
}
Also used : ArrayList(java.util.ArrayList) AreaDTO(com.tomasio.projects.trainning.dto.AreaDTO) ResponsavelAreaDTO(com.tomasio.projects.trainning.dto.ResponsavelAreaDTO) StripItemPlanejamentoDTO(com.tomasio.projects.trainning.dto.StripItemPlanejamentoDTO) PlanejamentoDTO(com.tomasio.projects.trainning.dto.PlanejamentoDTO) ItemPlanejamentoDTO(com.tomasio.projects.trainning.dto.ItemPlanejamentoDTO) StripItemPlanejamentoDTO(com.tomasio.projects.trainning.dto.StripItemPlanejamentoDTO) ItemPlanejamentoDTO(com.tomasio.projects.trainning.dto.ItemPlanejamentoDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

AreaDTO (com.tomasio.projects.trainning.dto.AreaDTO)17 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 CoreException (com.tomasio.projects.trainning.exeption.CoreException)7 AreaDAO (com.tomasio.projects.trainning.dao.AreaDAO)4 ItemPlanejamentoDTO (com.tomasio.projects.trainning.dto.ItemPlanejamentoDTO)4 PlanejamentoDTO (com.tomasio.projects.trainning.dto.PlanejamentoDTO)4 ResponsavelAreaDTO (com.tomasio.projects.trainning.dto.ResponsavelAreaDTO)4 DAOException (com.tomasio.projects.trainning.exception.DAOException)4 Area (com.tomasio.projects.trainning.model.Area)4 ArrayList (java.util.ArrayList)4 Transactional (org.springframework.transaction.annotation.Transactional)4 OrganizacaoDTO (com.tomasio.projects.trainning.dto.OrganizacaoDTO)3 CursoDTO (com.tomasio.projects.trainning.dto.CursoDTO)2 StripItemPlanejamentoDTO (com.tomasio.projects.trainning.dto.StripItemPlanejamentoDTO)2 AreaForm (com.tomasio.projects.trainning.form.AreaForm)2 ParseException (java.text.ParseException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 AcaoDTO (com.tomasio.projects.trainning.dto.AcaoDTO)1