Search in sources :

Example 1 with AnotacaoDTO

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

the class Anotacao method createDTOMinimal.

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

Example 2 with AnotacaoDTO

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

the class TurmasEfetivasController method saveAnotacao.

@RequestMapping("/save_anotacao_ajax")
@ResponseBody
public boolean saveAnotacao(Model model, WebRequest request) {
    String anotacaoId = request.getParameter("anotacaoId");
    String objectId = request.getParameter("objectId");
    String texto = request.getParameter("texto");
    String username = request.getParameter("username");
    String visible = request.getParameter("visible");
    AnotacaoDTO anotacao = new AnotacaoDTO();
    anotacao.setDataCriacao(new Date());
    anotacao.setId(Long.parseLong(anotacaoId));
    anotacao.setObjectId(objectId);
    anotacao.setTexto(texto);
    anotacao.setUser(username);
    anotacao.setVisibleInTca(false);
    anotacao.setVisibleInWebpage(Boolean.parseBoolean(visible));
    if (anotacao.getId() != null && anotacao.getId() > 0) {
        systemService.updateAnotacao(anotacao);
    } else {
        systemService.createAnotacao(anotacao);
    }
    return true;
}
Also used : AnotacaoDTO(com.tomasio.projects.trainning.dto.AnotacaoDTO) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with AnotacaoDTO

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

the class SystemServiceSimpleImpl method findAllAnotacoesByUser.

@Override
@Transactional(readOnly = true)
public AnotacaoDTO[] findAllAnotacoesByUser(String user) {
    AnotacaoDAO dao = factory.getAnotacaoDAO();
    AnotacaoDTO[] anotacoesArray = null;
    try {
        List<AnotacaoDTO> anotacoes = dao.findAllByUser(user);
        if (anotacoes != null) {
            anotacoesArray = new AnotacaoDTO[anotacoes.size()];
            anotacoes.toArray(anotacoesArray);
        }
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    }
    return anotacoesArray;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) AnotacaoDTO(com.tomasio.projects.trainning.dto.AnotacaoDTO) AnotacaoDAO(com.tomasio.projects.trainning.dao.AnotacaoDAO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with AnotacaoDTO

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

the class AnotacoesController method saveAnotacao.

@RequestMapping("/save")
@ResponseBody
public boolean saveAnotacao(Model model, WebRequest request) {
    String anotacaoId = request.getParameter("anotacaoId");
    String objectId = request.getParameter("objectId");
    String texto = request.getParameter("text");
    String username = request.getParameter("username");
    String visible = request.getParameter("visible");
    AnotacaoDTO anotacao = new AnotacaoDTO();
    anotacao.setDataCriacao(new Date());
    anotacao.setObjectId(objectId);
    anotacao.setUser(username);
    anotacao.setTexto(texto);
    anotacao.setVisibleInTca(false);
    anotacao.setVisibleInWebpage(Boolean.parseBoolean(visible));
    if (anotacao.getId() != null && anotacao.getId() > 0) {
        systemService.updateAnotacao(anotacao);
    } else {
        systemService.createAnotacao(anotacao);
    }
    return true;
}
Also used : AnotacaoDTO(com.tomasio.projects.trainning.dto.AnotacaoDTO) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 5 with AnotacaoDTO

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

the class AnotacoesController method getAnotacoes.

@RequestMapping("/ajax")
@ResponseBody
public List getAnotacoes(Model model, WebRequest request) {
    final InetOrgPerson user = (InetOrgPerson) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    String userLogin = user.getUid();
    List<Map> result = new ArrayList<Map>();
    String objectId = request.getParameter("objectId");
    AnotacaoDTO[] anotacoes = systemService.findAllAnotacoesByObjectId(objectId);
    for (AnotacaoDTO anotacao : anotacoes) {
        Map<Object, Object> item = new HashMap<>();
        item.put("user", anotacao.getUser());
        item.put("text", anotacao.getTexto());
        item.put("time", anotacao.getDataCriacaoFormatted());
        boolean editable = false;
        DateTime hoje = new DateTime();
        DateTime dataAnotacao = new DateTime(anotacao.getDataCriacao().getTime());
        Interval interval = new Interval(dataAnotacao, hoje);
        int intervaloEmDias = interval.toPeriod().getDays();
        if (anotacao.getUser().equals(userLogin) && intervaloEmDias == 0) {
            editable = true;
        }
        item.put("editable", editable);
        item.put("id", anotacao.getId());
        result.add(item);
    }
    return result;
}
Also used : HashMap(java.util.HashMap) InetOrgPerson(org.springframework.security.ldap.userdetails.InetOrgPerson) ArrayList(java.util.ArrayList) DateTime(org.joda.time.DateTime) AnotacaoDTO(com.tomasio.projects.trainning.dto.AnotacaoDTO) HashMap(java.util.HashMap) Map(java.util.Map) Interval(org.joda.time.Interval) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

AnotacaoDTO (com.tomasio.projects.trainning.dto.AnotacaoDTO)16 DAOException (com.tomasio.projects.trainning.exception.DAOException)9 AnotacaoDAO (com.tomasio.projects.trainning.dao.AnotacaoDAO)6 ArrayList (java.util.ArrayList)5 CoreException (com.tomasio.projects.trainning.exeption.CoreException)4 Date (java.util.Date)4 HashMap (java.util.HashMap)4 Transactional (org.springframework.transaction.annotation.Transactional)4 CursoDTO (com.tomasio.projects.trainning.dto.CursoDTO)3 FaseDTO (com.tomasio.projects.trainning.dto.FaseDTO)3 FolhaRostoDTO (com.tomasio.projects.trainning.dto.FolhaRostoDTO)3 TurmaDTO (com.tomasio.projects.trainning.dto.TurmaDTO)3 TurmaPlanejadaDTO (com.tomasio.projects.trainning.dto.TurmaPlanejadaDTO)3 Anotacao (com.tomasio.projects.trainning.model.Anotacao)3 Calendar (java.util.Calendar)3 List (java.util.List)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