4,6 → 4,11 |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.observation.ObservationModele; |
|
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.JSONParser; |
import com.google.gwt.json.client.JSONString; |
62,66 → 67,77 |
requete += criteres[i][0]+"="+criteres[i][1] ; |
} |
} |
} |
} |
|
|
// on envoie le get asynchrone |
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET,observationModele.getConfig().getServiceBaseUrl() |
+"/InventoryObservationList/"+utilisateur+"/"+requete) ; |
|
// on envoie le get asynchrone |
HTTPRequest.asyncGet(observationModele.getConfig().getServiceBaseUrl()+"/InventoryObservationList/"+utilisateur+"/"+requete, new ResponseTextHandler() { |
|
|
// si tout se passe bien on reçoit une réponse JSON |
public void onCompletion(String responseText) { |
|
final ListeObservation observationData ; |
final JSONValue responseValue = JSONParser.parse(responseText); |
|
JSONArray reponse=null; |
|
// si c'est un tableau |
if ((reponse=responseValue.isArray()) != null) { |
try { |
rb.sendRequest(null, new RequestCallback() { |
|
public void onError(Request request, Throwable exception) { |
// TODO Auto-generated method stub |
|
JSONArray observation; |
final int taillemax = reponse.size(); |
} |
|
public void onResponseReceived(Request request, |
Response response) { |
|
observationData = new ListeObservation(taillemax); |
final ListeObservation observationData ; |
final JSONValue responseValue = JSONParser.parse(response.getText()); |
|
JSONArray reponse=null; |
|
for (int i = 0; i < taillemax; i++) { |
// si c'est un tableau |
if ((reponse=responseValue.isArray()) != null) { |
|
if ((observation=reponse.get(i).isArray()) != null) { |
JSONArray observation; |
final int taillemax = reponse.size(); |
|
observationData = new ListeObservation(taillemax); |
|
for (int i = 0; i < taillemax; i++) { |
|
|
|
|
String transmis=((JSONString) observation.get(13)).stringValue(); |
String identifiantLocalite=((JSONString) observation.get(14)).toString(); |
String nomSaisi=Util.toCelString(((JSONString) observation.get(0)).toString()); |
String nomRetenu=Util.toCelString(((JSONString) observation.get(2)).toString()); |
String numeroNomenclaturalSaisi=((JSONString) observation.get(1)).stringValue(); |
String numeroNomenclaturalRetenu=((JSONString) observation.get(3)).stringValue(); |
String numeroTaxonomique=((JSONString) observation.get(4)).stringValue(); |
String famille=Util.toCelString(((JSONString) observation .get(5)).toString()); |
String localite=Util.toCelString(((JSONString) observation .get(6)).toString()); |
String lieudit=Util.toCelString(((JSONString) observation .get(9)).toString()); |
String station=Util.toCelString(((JSONString) observation .get(10)).toString()); |
String milieu=Util.toCelString(((JSONString) observation .get(11)).toString()); |
String commentaire=Util.toCelString(((JSONString) observation .get(12)).toString()); |
String date=((JSONString) observation .get(8)).stringValue(); |
String numeroOrdre=((JSONString) observation.get(7)).stringValue(); |
|
Observation obs=new Observation(transmis, nomSaisi, nomRetenu, numeroNomenclaturalSaisi, numeroNomenclaturalRetenu ,numeroTaxonomique, famille, localite, identifiantLocalite, lieudit, station, milieu, commentaire, date, numeroOrdre); |
|
observationData.put(obs.getNumeroOrdre(),obs); |
if ((observation=reponse.get(i).isArray()) != null) { |
|
String transmis=((JSONString) observation.get(13)).stringValue(); |
String identifiantLocalite=((JSONString) observation.get(14)).toString(); |
String nomSaisi=Util.toCelString(((JSONString) observation.get(0)).toString()); |
String nomRetenu=Util.toCelString(((JSONString) observation.get(2)).toString()); |
String numeroNomenclaturalSaisi=((JSONString) observation.get(1)).stringValue(); |
String numeroNomenclaturalRetenu=((JSONString) observation.get(3)).stringValue(); |
String numeroTaxonomique=((JSONString) observation.get(4)).stringValue(); |
String famille=Util.toCelString(((JSONString) observation .get(5)).toString()); |
String localite=Util.toCelString(((JSONString) observation .get(6)).toString()); |
String lieudit=Util.toCelString(((JSONString) observation .get(9)).toString()); |
String station=Util.toCelString(((JSONString) observation .get(10)).toString()); |
String milieu=Util.toCelString(((JSONString) observation .get(11)).toString()); |
String commentaire=Util.toCelString(((JSONString) observation .get(12)).toString()); |
String date=((JSONString) observation .get(8)).stringValue(); |
String numeroOrdre=((JSONString) observation.get(7)).stringValue(); |
|
Observation obs=new Observation(transmis, nomSaisi, nomRetenu, numeroNomenclaturalSaisi, numeroNomenclaturalRetenu ,numeroTaxonomique, famille, localite, identifiantLocalite, lieudit, station, milieu, commentaire, date, numeroOrdre); |
|
observationData.put(obs.getNumeroOrdre(),obs); |
} |
|
} |
|
} else { |
|
observationData = new ListeObservation(0) ; |
} |
|
// dans tous les cas on transmet la liste crée au rafraichissable en lui demandant de répandre les données car il est |
// le premier à les recevoir |
r.rafraichir(observationData,true); |
} |
} |
}); |
|
// dans tous les cas on transmet la liste crée au rafraichissable en lui demandant de répandre les données car il est |
// le premier à les recevoir |
r.rafraichir(observationData,true); |
} |
}) ; |
|
} catch (RequestException e) { |
// TODO Auto-generated catch block |
e.printStackTrace(); |
} |
} |
|
} |