Search in sources :

Example 6 with ItemAtaDTO

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

the class HibernateItemAtaDAO method findAll.

@SuppressWarnings("unchecked")
@Override
public List<ItemAtaDTO> findAll() throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        List<ItemAta> itens_atas = session.createQuery("from ItemAta itemAta order by itemAta.dataCriacao desc").list();
        List<ItemAtaDTO> dto = new ArrayList<ItemAtaDTO>();
        for (ItemAta item_ata : itens_atas) {
            dto.add(item_ata.createDTO());
        }
        return dto;
    } catch (HibernateException e) {
        Logger.getLogger(HibernateItemAtaDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("itens_atas.find.list.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) ItemAta(com.tomasio.projects.trainning.model.ItemAta) HibernateException(org.hibernate.HibernateException) ItemAtaDTO(com.tomasio.projects.trainning.dto.ItemAtaDTO) ArrayList(java.util.ArrayList) Session(org.hibernate.Session)

Example 7 with ItemAtaDTO

use of com.tomasio.projects.trainning.dto.ItemAtaDTO 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 8 with ItemAtaDTO

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

the class HibernateItemAtaDAO method findAllByItemPlanejamentoId.

@SuppressWarnings("unchecked")
@Override
public List<ItemAtaDTO> findAllByItemPlanejamentoId(Long itemPlanejamentoId) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        List<ItemAta> itens_atas = session.createQuery("from ItemAta itemAta" + " where itemAta.itemPlanejamento.id =:itemPlanejamentoId order by itemAta.dataCriacao asc").setLong("itemPlanejamentoId", itemPlanejamentoId).list();
        List<ItemAtaDTO> dto = new ArrayList<ItemAtaDTO>();
        for (ItemAta item_ata : itens_atas) {
            if (item_ata instanceof Acao) {
                dto.add(((Acao) item_ata).createDTO());
            }
            if (item_ata instanceof Decisao) {
                dto.add(((Decisao) item_ata).createDTO());
            }
            if (item_ata instanceof Comentario) {
                dto.add(((Comentario) item_ata).createDTO());
            }
        }
        return dto;
    } catch (HibernateException e) {
        Logger.getLogger(HibernateItemAtaDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("itens_atas.find.list.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) ItemAta(com.tomasio.projects.trainning.model.ItemAta) HibernateException(org.hibernate.HibernateException) ItemAtaDTO(com.tomasio.projects.trainning.dto.ItemAtaDTO) ArrayList(java.util.ArrayList) Comentario(com.tomasio.projects.trainning.model.Comentario) Session(org.hibernate.Session) Acao(com.tomasio.projects.trainning.model.Acao) Decisao(com.tomasio.projects.trainning.model.Decisao)

Example 9 with ItemAtaDTO

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

the class HibernateItemAtaDAO method findAllByUser.

@SuppressWarnings("unchecked")
@Override
public List<ItemAtaDTO> findAllByUser(String user) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        List<ItemAta> itens_atas = session.createQuery("from ItemAta itemAta" + " where itemAta.user=:user order by itemAta.dataCriacao desc").setString("user", user).list();
        List<ItemAtaDTO> dto = new ArrayList<ItemAtaDTO>();
        for (ItemAta item_ata : itens_atas) {
            dto.add(item_ata.createDTO());
        }
        return dto;
    } catch (HibernateException e) {
        Logger.getLogger(HibernateItemAtaDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("itens_atas.find.list.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) ItemAta(com.tomasio.projects.trainning.model.ItemAta) HibernateException(org.hibernate.HibernateException) ItemAtaDTO(com.tomasio.projects.trainning.dto.ItemAtaDTO) ArrayList(java.util.ArrayList) Session(org.hibernate.Session)

Example 10 with ItemAtaDTO

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

the class AtaServiceSimpleImpl method findAllItensAtas.

@Override
@Transactional(readOnly = true)
public ItemAtaDTO[] findAllItensAtas() {
    ItemAtaDAO dao = factory.getItemAtaDAO();
    ItemAtaDTO[] itensArray = null;
    try {
        List<ItemAtaDTO> itensAtas = dao.findAll();
        if (itensAtas != null) {
            itensArray = new ItemAtaDTO[itensAtas.size()];
            itensAtas.toArray(itensArray);
        }
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    }
    return itensArray;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) ItemAtaDTO(com.tomasio.projects.trainning.dto.ItemAtaDTO) ItemAtaDAO(com.tomasio.projects.trainning.dao.ItemAtaDAO) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ItemAtaDTO (com.tomasio.projects.trainning.dto.ItemAtaDTO)11 DAOException (com.tomasio.projects.trainning.exception.DAOException)7 CoreException (com.tomasio.projects.trainning.exeption.CoreException)5 ArrayList (java.util.ArrayList)5 ItemAtaDAO (com.tomasio.projects.trainning.dao.ItemAtaDAO)4 Transactional (org.springframework.transaction.annotation.Transactional)4 AcaoDTO (com.tomasio.projects.trainning.dto.AcaoDTO)3 DecisaoDTO (com.tomasio.projects.trainning.dto.DecisaoDTO)3 ItemAta (com.tomasio.projects.trainning.model.ItemAta)3 HibernateException (org.hibernate.HibernateException)3 Session (org.hibernate.Session)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 ComentarioDTO (com.tomasio.projects.trainning.dto.ComentarioDTO)2 AnaliseDTO (com.tomasio.projects.trainning.dto.AnaliseDTO)1 AreaDTO (com.tomasio.projects.trainning.dto.AreaDTO)1 ItemPlanejamentoDTO (com.tomasio.projects.trainning.dto.ItemPlanejamentoDTO)1 PlanejamentoDTO (com.tomasio.projects.trainning.dto.PlanejamentoDTO)1 ResponsavelAreaDTO (com.tomasio.projects.trainning.dto.ResponsavelAreaDTO)1 StripItemPlanejamentoDTO (com.tomasio.projects.trainning.dto.StripItemPlanejamentoDTO)1