Search in sources :

Example 11 with TelefoneDTO

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

the class ContatosController method saveTelefone.

@RequestMapping("/save_telefone")
@ResponseBody
public boolean saveTelefone(Model model, WebRequest request) {
    String pessoaIdParam = request.getParameter("pessoaId");
    String numero = request.getParameter("numero");
    Long pessoaId = Long.parseLong(pessoaIdParam);
    PessoaDTO pessoa = organizationalService.findPessoa(pessoaId);
    List<TelefoneDTO> telefones = new ArrayList<TelefoneDTO>();
    if (pessoa.getTelefones() != null) {
        telefones.addAll(Arrays.asList(pessoa.getTelefones()));
    }
    TelefoneDTO telefone = new TelefoneDTO();
    telefone.setNumero(numero);
    telefone.setDdd("99");
    telefones.add(telefone);
    TelefoneDTO[] telefonesArray = new TelefoneDTO[telefones.size()];
    telefones.toArray(telefonesArray);
    pessoa.setTelefones(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) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 12 with TelefoneDTO

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

Example 13 with TelefoneDTO

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

the class ContatosController method listTelefones.

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

Example 14 with TelefoneDTO

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

the class Telefone method createDTOMinimal.

public TelefoneDTO createDTOMinimal() {
    TelefoneDTO dto = new TelefoneDTO();
    dto.setDdd(ddd);
    dto.setLabel(label);
    dto.setNumero(numero);
    dto.setPrivativo(privativo);
    dto.setRamal(ramal);
    dto.setPreference(preference);
    return dto;
}
Also used : TelefoneDTO(com.tomasio.projects.trainning.dto.TelefoneDTO)

Example 15 with TelefoneDTO

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

the class Pessoa method createDTO.

@Override
public PessoaDTO createDTO() {
    PessoaDTO dto = createDTOWithoutDependencies();
    if (organizacao != null) {
        dto.setOrganizacao(organizacao.createDTOWithoutDependencies());
    }
    if (telefones != null) {
        TelefoneDTO[] dtoArray = new TelefoneDTO[telefones.size()];
        Object[] modelArray = telefones.toArray();
        for (int i = 0; i < modelArray.length; i++) {
            Telefone telefone = (Telefone) modelArray[i];
            dtoArray[i] = telefone.createDTOWithoutDependencies();
        }
        dto.setTelefones(dtoArray);
    }
    if (emails != null) {
        EmailDTO[] dtoArray = new EmailDTO[emails.size()];
        Object[] modelArray = emails.toArray();
        for (int i = 0; i < modelArray.length; i++) {
            Email email = (Email) modelArray[i];
            dtoArray[i] = email.createDTOWithoutDependencies();
        }
        dto.setEmails(dtoArray);
    }
    if (enderecos != null) {
        EnderecoDTO[] dtoArray = new EnderecoDTO[enderecos.size()];
        Object[] modelArray = enderecos.toArray();
        for (int i = 0; i < modelArray.length; i++) {
            Endereco endereco = (Endereco) modelArray[i];
            dtoArray[i] = endereco.createDTOWithoutDependencies();
        }
        dto.setEnderecos(dtoArray);
    }
    return dto;
}
Also used : TelefoneDTO(com.tomasio.projects.trainning.dto.TelefoneDTO) PessoaDTO(com.tomasio.projects.trainning.dto.PessoaDTO) EmailDTO(com.tomasio.projects.trainning.dto.EmailDTO) EnderecoDTO(com.tomasio.projects.trainning.dto.EnderecoDTO)

Aggregations

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