Search in sources :

Example 1 with ItemAtaDTO

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

the class MainPlanejamentoController method detailItemAta.

@RequestMapping("/detail_item_ata_ajax")
@ResponseBody
public ItemAtaDTO detailItemAta(Model model, WebRequest request) {
    String itemAtaId = request.getParameter("itemAtaId");
    ItemAtaDTO itemAta = ataService.findItemAta(Long.parseLong(itemAtaId));
    return itemAta;
}
Also used : ItemAtaDTO(com.tomasio.projects.trainning.dto.ItemAtaDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with ItemAtaDTO

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

the class MainPlanejamentoController method listItensAtaAjax.

@RequestMapping("/itens_ata_ajax")
@ResponseBody
public List listItensAtaAjax(Model model, WebRequest request) {
    List result = new ArrayList<>();
    String itemPlanejamentoId = request.getParameter("itemPlanejamentoId");
    ItemAtaDTO[] itensAta = ataService.findAllItensAtasByItemPlanejamentoId(Long.parseLong(itemPlanejamentoId));
    for (ItemAtaDTO itemAtaDTO : itensAta) {
        Map<String, Object> item = new HashMap<>();
        item.put("id", itemAtaDTO.getId());
        item.put("texto", itemAtaDTO.getTexto());
        String tipo = "";
        String tipoSigla = "";
        String tipoCSS = "";
        if (itemAtaDTO instanceof AcaoDTO) {
            AcaoDTO acao = (AcaoDTO) itemAtaDTO;
            tipo = "Ação";
            tipoCSS = "label-purple";
            tipoSigla = acao.getTipoSigla();
            item.put("prazo", acao.getPrazo());
            item.put("responsavel", acao.getResponsavel());
        }
        if (itemAtaDTO instanceof DecisaoDTO) {
            DecisaoDTO decisao = (DecisaoDTO) itemAtaDTO;
            tipo = "Decisão";
            tipoSigla = decisao.getTipoSigla();
            tipoCSS = "label-success";
            item.put("prazo", "-");
            item.put("responsavel", decisao.getResponsavel());
        }
        if (itemAtaDTO instanceof ComentarioDTO) {
            ComentarioDTO comentario = (ComentarioDTO) itemAtaDTO;
            tipo = "Comentário";
            tipoSigla = comentario.getTipoSigla();
            tipoCSS = "label-warning";
            item.put("prazo", "-");
            item.put("responsavel", "-");
        }
        item.put("dataCriacao", itemAtaDTO.getDataCriacaoFormatted());
        item.put("tipo", tipo);
        item.put("tipoSigla", tipoSigla);
        item.put("tipoCSS", tipoCSS);
        item.put("user", itemAtaDTO.getUser());
        result.add(item);
    }
    return result;
}
Also used : AcaoDTO(com.tomasio.projects.trainning.dto.AcaoDTO) HashMap(java.util.HashMap) ComentarioDTO(com.tomasio.projects.trainning.dto.ComentarioDTO) ArrayList(java.util.ArrayList) ItemAtaDTO(com.tomasio.projects.trainning.dto.ItemAtaDTO) DecisaoDTO(com.tomasio.projects.trainning.dto.DecisaoDTO) List(java.util.List) ArrayList(java.util.ArrayList) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with ItemAtaDTO

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

the class MainPlanejamentoController method saveItemAta.

@RequestMapping("/save_itens_ata_ajax")
@ResponseBody
public boolean saveItemAta(Model model, WebRequest request) {
    String itemAtaId = request.getParameter("itemAtaId");
    String itemPlanejamentoId = request.getParameter("itemPlanejamentoId");
    String texto = request.getParameter("texto");
    String responsavel = request.getParameter("responsavel");
    String prazo = request.getParameter("prazo");
    String tipo = request.getParameter("tipo");
    String username = request.getParameter("username");
    ItemAtaDTO itemAta;
    if (tipo.equals("A")) {
        itemAta = new AcaoDTO();
        ((AcaoDTO) itemAta).setResponsavel(responsavel);
        ((AcaoDTO) itemAta).setPrazo(prazo);
    } else if (tipo.equals("D")) {
        itemAta = new DecisaoDTO();
        ((DecisaoDTO) itemAta).setResponsavel(responsavel);
    } else if (tipo.equals("C")) {
        itemAta = new ComentarioDTO();
    } else {
        return false;
    }
    itemAta.setItemPlanejamento(planningService.findItemPlanejamento(Long.parseLong(itemPlanejamentoId)));
    itemAta.setTexto(texto);
    itemAta.setDataCriacao(new Date());
    itemAta.setUser(username);
    if (itemAtaId != null && !itemAtaId.equals("")) {
        try {
            itemAta.setId(Long.parseLong(itemAtaId));
            ataService.updateItemAta(itemAta);
        } catch (CoreException e) {
            return false;
        }
    } else {
        try {
            ataService.createItemAta(itemAta);
        } catch (CoreException e) {
            return false;
        }
    }
    return true;
}
Also used : AcaoDTO(com.tomasio.projects.trainning.dto.AcaoDTO) CoreException(com.tomasio.projects.trainning.exeption.CoreException) ComentarioDTO(com.tomasio.projects.trainning.dto.ComentarioDTO) ItemAtaDTO(com.tomasio.projects.trainning.dto.ItemAtaDTO) DecisaoDTO(com.tomasio.projects.trainning.dto.DecisaoDTO) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with ItemAtaDTO

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

the class AtaServiceSimpleImpl method findAllItensAtasByUser.

@Override
@Transactional(readOnly = true)
public ItemAtaDTO[] findAllItensAtasByUser(String user) {
    ItemAtaDAO dao = factory.getItemAtaDAO();
    ItemAtaDTO[] itensArray = null;
    try {
        List<ItemAtaDTO> itensAtas = dao.findAllByUser(user);
        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)

Example 5 with ItemAtaDTO

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

the class AtaServiceSimpleImpl method findAllItensAtasByItemPlanejamentoId.

@Override
@Transactional(readOnly = true)
public ItemAtaDTO[] findAllItensAtasByItemPlanejamentoId(Long itemPlanejamentoId) {
    ItemAtaDAO dao = factory.getItemAtaDAO();
    ItemAtaDTO[] itensArray = null;
    try {
        List<ItemAtaDTO> itensAtas = dao.findAllByItemPlanejamentoId(itemPlanejamentoId);
        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