Search in sources :

Example 1 with ComentarioDTO

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

the class Comentario method createDTOMinimal.

@Override
public ComentarioDTO createDTOMinimal() {
    SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm");
    ComentarioDTO dto = new ComentarioDTO();
    dto.setId(id);
    dto.setDataCriacao(dataCriacao);
    if (dataCriacao != null) {
        dto.setDataCriacaoFormatted(df.format(dataCriacao));
    }
    dto.setTexto(texto);
    dto.setUser(user);
    return dto;
}
Also used : ComentarioDTO(com.tomasio.projects.trainning.dto.ComentarioDTO) SimpleDateFormat(java.text.SimpleDateFormat)

Example 2 with ComentarioDTO

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

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

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

the class AtaServiceSimpleImpl method createItemAta.

@Override
@Transactional
public Long createItemAta(ItemAtaDTO itemAta) {
    ItemAtaDAO dao = factory.getItemAtaDAO();
    ItemAta _itemAta = null;
    if (itemAta instanceof AcaoDTO) {
        _itemAta = new Acao((AcaoDTO) itemAta);
    }
    if (itemAta instanceof DecisaoDTO) {
        _itemAta = new Decisao((DecisaoDTO) itemAta);
    }
    if (itemAta instanceof ComentarioDTO) {
        _itemAta = new Comentario((ComentarioDTO) itemAta);
    }
    Long id = null;
    try {
        id = dao.create(_itemAta);
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    }
    return id;
}
Also used : AcaoDTO(com.tomasio.projects.trainning.dto.AcaoDTO) DAOException(com.tomasio.projects.trainning.exception.DAOException) ItemAta(com.tomasio.projects.trainning.model.ItemAta) CoreException(com.tomasio.projects.trainning.exeption.CoreException) ComentarioDTO(com.tomasio.projects.trainning.dto.ComentarioDTO) DecisaoDTO(com.tomasio.projects.trainning.dto.DecisaoDTO) ItemAtaDAO(com.tomasio.projects.trainning.dao.ItemAtaDAO) Comentario(com.tomasio.projects.trainning.model.Comentario) Acao(com.tomasio.projects.trainning.model.Acao) Decisao(com.tomasio.projects.trainning.model.Decisao) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with ComentarioDTO

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

the class HibernateItemAtaDAO method update.

@Override
public void update(ItemAtaDTO itemAta) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        ItemAta _itemAta;
        if (itemAta instanceof AcaoDTO) {
            _itemAta = new Acao((AcaoDTO) itemAta);
        } else if (itemAta instanceof DecisaoDTO) {
            _itemAta = new Decisao((DecisaoDTO) itemAta);
        } else if (itemAta instanceof ComentarioDTO) {
            _itemAta = new Comentario((ComentarioDTO) itemAta);
        } else {
            _itemAta = null;
        }
        session.update(_itemAta);
    } catch (HibernateException e) {
        Logger.getLogger(HibernateItemAtaDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("itens_atas.update.error"));
    }
}
Also used : AcaoDTO(com.tomasio.projects.trainning.dto.AcaoDTO) DAOException(com.tomasio.projects.trainning.exception.DAOException) ItemAta(com.tomasio.projects.trainning.model.ItemAta) ComentarioDTO(com.tomasio.projects.trainning.dto.ComentarioDTO) HibernateException(org.hibernate.HibernateException) DecisaoDTO(com.tomasio.projects.trainning.dto.DecisaoDTO) 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)

Aggregations

ComentarioDTO (com.tomasio.projects.trainning.dto.ComentarioDTO)5 AcaoDTO (com.tomasio.projects.trainning.dto.AcaoDTO)4 DecisaoDTO (com.tomasio.projects.trainning.dto.DecisaoDTO)4 ItemAtaDTO (com.tomasio.projects.trainning.dto.ItemAtaDTO)2 DAOException (com.tomasio.projects.trainning.exception.DAOException)2 CoreException (com.tomasio.projects.trainning.exeption.CoreException)2 Acao (com.tomasio.projects.trainning.model.Acao)2 Comentario (com.tomasio.projects.trainning.model.Comentario)2 Decisao (com.tomasio.projects.trainning.model.Decisao)2 ItemAta (com.tomasio.projects.trainning.model.ItemAta)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 ItemAtaDAO (com.tomasio.projects.trainning.dao.ItemAtaDAO)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 HibernateException (org.hibernate.HibernateException)1 Session (org.hibernate.Session)1