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;
}
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);
}
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;
}
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;
}
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);
}
}
Aggregations