Rev 989 | Rev 1918 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package org.tela_botanica.client.modeles.dao;
import org.tela_botanica.client.CarnetEnLigneModele;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.objets.Configuration;
import org.tela_botanica.client.util.Util;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.RequestException;
import com.google.gwt.http.client.Response;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONValue;
public class ListeUtilisateurAsynchroneDAO {
CarnetEnLigneModele cModele = null ;
public ListeUtilisateurAsynchroneDAO(CarnetEnLigneModele carnetEnLigneModele) {
cModele = carnetEnLigneModele ;
}
public final void obtenirListeUtilisateur(final Rafraichissable r,final String rech, final String utilisateur) {
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, Configuration.getServiceBaseUrl() + "/InventoryUserList/" + utilisateur+"/"+rech);
try {
rb.sendRequest(null, new RequestCallback() {
@Override
public void onError(final Request request, final Throwable exception) {
// TODO Auto-generated method stub
}
@Override
public void onResponseReceived(final Request request,
final Response response) {
String[][] util ;
final JSONValue responseValue = JSONParser.parse(response.getText());
JSONArray reponse = responseValue.isArray();
if(reponse != null) {
util = new String[reponse.size()][2];
for(int i = 0; i < reponse.size() ; i++) {
JSONObject item = reponse.get(i).isObject();
util[i][0] = Util.getValeurJsonOuVide(item, "id_utilisateur");
util[i][1] = Util.getValeurJsonOuVide(item, "courriel");
}
}
else {
util = new String[0][2];
}
r.rafraichir(util, true);
}
});
} catch (RequestException e) {
e.printStackTrace();
}
}
}