Search in sources :

Example 11 with NetworkUserDTO

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

the class LDAPNetworkUserDAO method findAll.

@Override
public List<NetworkUserDTO> findAll() throws DAOException {
    AndFilter filter = new AndFilter();
    filter.and(new EqualsFilter("objectclass", "inetOrgPerson"));
    // filter.and(new LikeFilter("uid", "fernandofot"));
    @SuppressWarnings({ "unchecked" }) List<NetworkUserDTO> users = ldapTemplate.search(DistinguishedName.EMPTY_PATH, "(objectclass=inetOrgPerson)", new UserAttributesMapper());
    Collections.sort(users, new Comparator<NetworkUserDTO>() {

        @Override
        public int compare(NetworkUserDTO o1, NetworkUserDTO o2) {
            // To change body of generated methods, choose Tools | Templates.
            return o1.getNome().compareTo(o2.getNome());
        }
    });
    return users;
}
Also used : AndFilter(org.springframework.ldap.filter.AndFilter) NetworkUserDTO(com.tomasio.projects.trainning.dto.NetworkUserDTO) EqualsFilter(org.springframework.ldap.filter.EqualsFilter)

Example 12 with NetworkUserDTO

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

the class LDAPNetworkUserDAO method remove.

@Override
public void remove(String uid) throws DAOException {
    NetworkUserDTO user = find(uid);
    Name dn = buildDn(user);
    ldapTemplate.unbind(dn);
}
Also used : NetworkUserDTO(com.tomasio.projects.trainning.dto.NetworkUserDTO) Name(javax.naming.Name) DistinguishedName(org.springframework.ldap.core.DistinguishedName)

Example 13 with NetworkUserDTO

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

the class MockNetworkUserDAO method find.

@Override
public NetworkUserDTO find(String uid) throws DAOException {
    NetworkUserDTO u = new NetworkUserDTO();
    if (uid.equals("fernandofot")) {
        u.setNome("Fernando de Oliveira Tomasio");
        u.setEmail("psoidfa@gmail.com");
        u.setLogin("fernandofot");
        u.setTarjeta("1S FERNANDO (DECEA)");
        u.setOrganizacao("DECEA");
        u.setNomeGuerra("teste");
    } else {
        u.setNome("Reinaldo Arantes");
        u.setEmail("psoidfa@gmail.com");
        u.setLogin("arantesrac");
        u.setTarjeta("SO ARANTES (COMGAP)");
        u.setOrganizacao("COMGAP");
        u.setNomeGuerra("ARANTES");
    }
    return u;
}
Also used : NetworkUserDTO(com.tomasio.projects.trainning.dto.NetworkUserDTO)

Example 14 with NetworkUserDTO

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

the class MockNetworkUserDAO method findAll.

@Override
public List<NetworkUserDTO> findAll() throws DAOException {
    List<NetworkUserDTO> users = new ArrayList<NetworkUserDTO>();
    NetworkUserDTO u = new NetworkUserDTO();
    u.setNome("aplsdjfkaf");
    u.setEmail("psoidfa@gmail.com");
    u.setLogin("reinald");
    u.setNome("teste");
    u.setOrganizacao("DECEA");
    u.setNomeGuerra("teste");
    NetworkUserDTO u2 = new NetworkUserDTO();
    u2.setNome("aplsdjfkaf");
    u2.setEmail("psoidfa@gmail.com");
    u2.setLogin("fernandofot");
    u2.setNome("teste");
    u2.setOrganizacao("DECEA");
    u2.setNomeGuerra("teste");
    NetworkUserDTO u3 = new NetworkUserDTO();
    u3.setNome("aplsdjfkaf");
    u3.setEmail("psoidfa@gmail.com");
    u2.setLogin("fernandofot");
    u3.setNome("teste");
    u3.setOrganizacao("DECEA");
    u3.setNomeGuerra("teste");
    users.add(u);
    users.add(u2);
    users.add(u3);
    return users;
}
Also used : NetworkUserDTO(com.tomasio.projects.trainning.dto.NetworkUserDTO) ArrayList(java.util.ArrayList)

Example 15 with NetworkUserDTO

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

the class EXC016CSV method makeReport.

@Override
public void makeReport() {
    UserService userService = (UserService) services.get("userService");
    Writer writter = null;
    try {
        writter = new OutputStreamWriter(os, "UTF-8");
    } catch (UnsupportedEncodingException ex) {
        Logger.getLogger(EXC016CSV.class.getName()).log(Level.SEVERE, null, ex);
    }
    BufferedWriter bufferedWriter = new BufferedWriter(writter);
    // recuperar paramentro
    String organizacao = "";
    organizacao += (String) params.get("organizacao");
    // busca todos usuários
    NetworkUserDTO[] usuarios = userService.findAllUsers();
    // jogo no ArrayList para trabalhar
    List<NetworkUserDTO> usuariosFiltrado = new ArrayList();
    usuariosFiltrado.addAll(Arrays.asList(usuarios));
    // verificar usuário filtrou por searchForm.getOrganizacaoId (OM)
    if (!(organizacao.equals(""))) {
        // corre os usuários verifcando se a OM igual a FILTRADA
        for (Iterator<NetworkUserDTO> iterator = usuariosFiltrado.iterator(); iterator.hasNext(); ) {
            NetworkUserDTO next = iterator.next();
            String usuarioOM = next.getOrganizacao();
            if (!(organizacao.equals(usuarioOM))) {
                // comparar se a OM é igual filtro passado
                iterator.remove();
            }
        }
    }
    // ordenar a lista de usuários
    Collections.sort(usuariosFiltrado, new Comparator<NetworkUserDTO>() {

        @Override
        public int compare(NetworkUserDTO o1, NetworkUserDTO o2) {
            return o1.getNome().compareTo(o2.getNome());
        }
    });
    Collections.sort(usuariosFiltrado, new Comparator<NetworkUserDTO>() {

        @Override
        public int compare(NetworkUserDTO o1, NetworkUserDTO o2) {
            return o1.getOrganizacao().compareTo(o2.getOrganizacao());
        }
    });
    // correr o ArrayList para montar o arquivo CSV
    for (NetworkUserDTO usuario : usuariosFiltrado) {
        try {
            // organizacao
            bufferedWriter.write(usuario.getOrganizacao());
            bufferedWriter.write("|");
            // nome
            bufferedWriter.write(usuario.getNome());
            bufferedWriter.write("|");
            // posto
            bufferedWriter.write(usuario.getPosto());
            bufferedWriter.write("|");
            // nomeGuerra
            bufferedWriter.write(usuario.getNomeGuerra());
            bufferedWriter.write("|");
            // email
            bufferedWriter.write(usuario.getEmail());
            bufferedWriter.write("|");
            // login
            bufferedWriter.write(usuario.getLogin());
            bufferedWriter.write("|");
            bufferedWriter.newLine();
        } catch (IOException ex) {
            Logger.getLogger(EXC016CSV.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    try {
        bufferedWriter.flush();
        bufferedWriter.close();
    } catch (IOException ex) {
        Logger.getLogger(EXC016CSV.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : UserService(com.tomasio.projects.trainning.interfaces.UserService) ArrayList(java.util.ArrayList) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter) NetworkUserDTO(com.tomasio.projects.trainning.dto.NetworkUserDTO) OutputStreamWriter(java.io.OutputStreamWriter) BufferedWriter(java.io.BufferedWriter) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter)

Aggregations

NetworkUserDTO (com.tomasio.projects.trainning.dto.NetworkUserDTO)29 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)11 DAOException (com.tomasio.projects.trainning.exception.DAOException)10 ArrayList (java.util.ArrayList)10 NetworkUserDAO (com.tomasio.projects.trainning.dao.NetworkUserDAO)9 NetworkGroupDTO (com.tomasio.projects.trainning.dto.NetworkGroupDTO)9 CoreException (com.tomasio.projects.trainning.exeption.CoreException)9 OrganizacaoDTO (com.tomasio.projects.trainning.dto.OrganizacaoDTO)4 NetworkGroupDAO (com.tomasio.projects.trainning.dao.NetworkGroupDAO)3 OrganizacaoDAO (com.tomasio.projects.trainning.dao.OrganizacaoDAO)3 CancelamentoMatriculaDTO (com.tomasio.projects.trainning.dto.CancelamentoMatriculaDTO)3 MatriculaDTO (com.tomasio.projects.trainning.dto.MatriculaDTO)3 NotificacaoMatriculaDTO (com.tomasio.projects.trainning.dto.NotificacaoMatriculaDTO)3 PreMatriculaDTO (com.tomasio.projects.trainning.dto.PreMatriculaDTO)3 Organizacao (com.tomasio.projects.trainning.model.Organizacao)3 ApresentacaoDTO (com.tomasio.projects.trainning.dto.ApresentacaoDTO)2 CertificadoConclusaoDTO (com.tomasio.projects.trainning.dto.CertificadoConclusaoDTO)2 ConclusaoDTO (com.tomasio.projects.trainning.dto.ConclusaoDTO)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2