Search in sources :

Example 11 with EmailDTO

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

the class PessoasController method showDetails.

@RequestMapping("/detail")
public String showDetails(Model model, WebRequest request) {
    String pessoaId = request.getParameter("pessoaId");
    PessoaDTO pessoa = organizationalService.findPessoa(Long.parseLong(pessoaId));
    model.addAttribute("pessoa", pessoa);
    model.addAttribute("importado", pessoa.isImported());
    TelefoneDTO[] telefones = pessoa.getTelefones();
    model.addAttribute("telefones", telefones);
    EmailDTO[] emails = pessoa.getEmails();
    model.addAttribute("emails", emails);
    return "pessoas/detail";
}
Also used : PessoaDTO(com.tomasio.projects.trainning.dto.PessoaDTO) TelefoneDTO(com.tomasio.projects.trainning.dto.TelefoneDTO) EmailDTO(com.tomasio.projects.trainning.dto.EmailDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with EmailDTO

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

the class ContatosController method removeEmail.

@RequestMapping("/remove_email")
@ResponseBody
public boolean removeEmail(Model model, WebRequest request, HttpServletResponse response) {
    String pessoaIdParam = request.getParameter("pessoaId");
    String descricao = request.getParameter("descricao");
    Long pessoaId = Long.parseLong(pessoaIdParam);
    PessoaDTO pessoa = organizationalService.findPessoa(pessoaId);
    List<EmailDTO> emails = new ArrayList<EmailDTO>();
    if (pessoa.getTelefones() != null) {
        emails.addAll(Arrays.asList(pessoa.getEmails()));
    }
    List<EmailDTO> result = new ArrayList<EmailDTO>();
    for (EmailDTO emailDTO : emails) {
        if (!emailDTO.getAddress().equals(descricao)) {
            result.add(emailDTO);
        }
    }
    EmailDTO[] emailsArray = new EmailDTO[result.size()];
    result.toArray(emailsArray);
    pessoa.setEmails(emailsArray);
    organizationalService.updatePessoa(pessoa);
    return true;
}
Also used : PessoaDTO(com.tomasio.projects.trainning.dto.PessoaDTO) ArrayList(java.util.ArrayList) EmailDTO(com.tomasio.projects.trainning.dto.EmailDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 13 with EmailDTO

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

the class ContatosController method saveContatos.

@RequestMapping("/save")
@ResponseBody
public boolean saveContatos(Model model, WebRequest request, HttpServletResponse response) {
    String[] emails = request.getParameterValues("contatos-form-email");
    String[] telefones = request.getParameterValues("contatos-form-telefone");
    String pessoaId = request.getParameter("pessoaId");
    if (pessoaId == null || pessoaId.equals("")) {
        return false;
    }
    PessoaDTO pessoa = organizationalService.findPessoa(Long.parseLong(pessoaId));
    ArrayList<EmailDTO> emailsArray = new ArrayList<EmailDTO>();
    for (String email : emails) {
        if (!email.trim().equals("")) {
            EmailDTO dto = new EmailDTO();
            dto.setAddress(email);
            emailsArray.add(dto);
        }
    }
    pessoa.setEmails(emailsArray.toArray(new EmailDTO[emailsArray.size()]));
    model.addAttribute("emails", emailsArray);
    ArrayList<TelefoneDTO> telefonesArray = new ArrayList<TelefoneDTO>();
    for (String tel : telefones) {
        if (!tel.trim().equals("")) {
            TelefoneDTO telefone = new TelefoneDTO();
            telefone.setNumero(tel);
            telefone.setDdd("99");
            telefonesArray.add(telefone);
        }
    }
    pessoa.setTelefones(telefonesArray.toArray(new TelefoneDTO[telefonesArray.size()]));
    model.addAttribute("telefones", telefonesArray);
    organizationalService.updatePessoa(pessoa);
    return true;
}
Also used : PessoaDTO(com.tomasio.projects.trainning.dto.PessoaDTO) ArrayList(java.util.ArrayList) TelefoneDTO(com.tomasio.projects.trainning.dto.TelefoneDTO) EmailDTO(com.tomasio.projects.trainning.dto.EmailDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 14 with EmailDTO

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

the class ContatosController method listEmails.

@RequestMapping("/emails")
@ResponseBody
public List listEmails(Model model, WebRequest request) {
    List<Map> result = new ArrayList<Map>();
    String pessoaId = request.getParameter("pessoaId");
    PessoaDTO pessoa = organizationalService.findPessoa(Long.parseLong(pessoaId));
    EmailDTO[] emails = pessoa.getEmails();
    for (EmailDTO emailDTO : emails) {
        Map item = new HashMap();
        item.put("descricao", emailDTO.getAddress());
        result.add(item);
    }
    return result;
}
Also used : PessoaDTO(com.tomasio.projects.trainning.dto.PessoaDTO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) EmailDTO(com.tomasio.projects.trainning.dto.EmailDTO) HashMap(java.util.HashMap) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 15 with EmailDTO

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

the class ContatosController method listContatos.

@RequestMapping({ "/", "/index", "" })
public String listContatos(Model model, WebRequest request) {
    String pessoaId = request.getParameter("pessoaId");
    PessoaDTO pessoa = organizationalService.findPessoa(Long.parseLong(pessoaId));
    TelefoneDTO[] telefones = pessoa.getTelefones();
    if (telefones == null || telefones.length == 0) {
        telefones = new TelefoneDTO[1];
        telefones[0] = new TelefoneDTO();
    }
    model.addAttribute("telefones", telefones);
    EmailDTO[] emails = pessoa.getEmails();
    if (emails == null || emails.length == 0) {
        emails = new EmailDTO[1];
        emails[0] = new EmailDTO();
    }
    model.addAttribute("emails", emails);
    model.addAttribute("pessoaId", pessoaId);
    return "contatos";
}
Also used : PessoaDTO(com.tomasio.projects.trainning.dto.PessoaDTO) TelefoneDTO(com.tomasio.projects.trainning.dto.TelefoneDTO) EmailDTO(com.tomasio.projects.trainning.dto.EmailDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

EmailDTO (com.tomasio.projects.trainning.dto.EmailDTO)17 PessoaDTO (com.tomasio.projects.trainning.dto.PessoaDTO)14 TelefoneDTO (com.tomasio.projects.trainning.dto.TelefoneDTO)11 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)10 ArrayList (java.util.ArrayList)7 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)4 HabilitacaoInstrutorEfetivaDTO (com.tomasio.projects.trainning.dto.HabilitacaoInstrutorEfetivaDTO)3 OrganizacaoDTO (com.tomasio.projects.trainning.dto.OrganizacaoDTO)3 PessoaForm (com.tomasio.projects.trainning.form.PessoaForm)3 CoreException (com.tomasio.projects.trainning.exeption.CoreException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 CursoDTO (com.tomasio.projects.trainning.dto.CursoDTO)1 EnderecoDTO (com.tomasio.projects.trainning.dto.EnderecoDTO)1 PeriodoDTO (com.tomasio.projects.trainning.dto.PeriodoDTO)1 HabilitacaoInstrutorForm (com.tomasio.projects.trainning.form.instrutores.HabilitacaoInstrutorForm)1 PropostaHabilitacaoInstrutorForm (com.tomasio.projects.trainning.form.instrutores.PropostaHabilitacaoInstrutorForm)1 ParseException (java.text.ParseException)1