Line 2... |
Line 2... |
2 |
|
2 |
|
3 |
import org.tela_botanica.client.Util;
|
3 |
import org.tela_botanica.client.Util;
|
4 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
4 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
Line -... |
Line 5... |
- |
|
5 |
import org.tela_botanica.client.observation.ObservationModele;
|
- |
|
6 |
|
- |
|
7 |
import com.google.gwt.http.client.Request;
|
- |
|
8 |
import com.google.gwt.http.client.RequestBuilder;
|
- |
|
9 |
import com.google.gwt.http.client.RequestCallback;
|
5 |
import org.tela_botanica.client.observation.ObservationModele;
|
10 |
import com.google.gwt.http.client.RequestException;
|
6 |
|
11 |
import com.google.gwt.http.client.Response;
|
7 |
import com.google.gwt.json.client.JSONArray;
|
12 |
import com.google.gwt.json.client.JSONArray;
|
8 |
import com.google.gwt.json.client.JSONParser;
|
13 |
import com.google.gwt.json.client.JSONParser;
|
9 |
import com.google.gwt.json.client.JSONString;
|
14 |
import com.google.gwt.json.client.JSONString;
|
Line 60... |
Line 65... |
60 |
requete += "&";
|
65 |
requete += "&";
|
61 |
}
|
66 |
}
|
62 |
requete += criteres[i][0]+"="+criteres[i][1] ;
|
67 |
requete += criteres[i][0]+"="+criteres[i][1] ;
|
63 |
}
|
68 |
}
|
64 |
}
|
69 |
}
|
65 |
}
|
70 |
}
|
66 |
|
- |
|
67 |
|
- |
|
Line 68... |
Line 71... |
68 |
|
71 |
|
69 |
// on envoie le get asynchrone
|
72 |
// on envoie le get asynchrone
|
70 |
HTTPRequest.asyncGet(observationModele.getConfig().getServiceBaseUrl()+"/InventoryObservationList/"+utilisateur+"/"+requete, new ResponseTextHandler() {
|
- |
|
71 |
|
- |
|
72 |
|
73 |
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET,observationModele.getConfig().getServiceBaseUrl()
|
73 |
// si tout se passe bien on reçoit une réponse JSON
|
- |
|
74 |
public void onCompletion(String responseText) {
|
74 |
+"/InventoryObservationList/"+utilisateur+"/"+requete) ;
|
75 |
|
- |
|
76 |
final ListeObservation observationData ;
|
- |
|
77 |
final JSONValue responseValue = JSONParser.parse(responseText);
|
75 |
|
78 |
|
76 |
try {
|
79 |
JSONArray reponse=null;
|
77 |
rb.sendRequest(null, new RequestCallback() {
|
80 |
|
78 |
|
81 |
// si c'est un tableau
|
79 |
public void onError(Request request, Throwable exception) {
|
Line -... |
Line 80... |
- |
|
80 |
// TODO Auto-generated method stub
|
- |
|
81 |
|
82 |
if ((reponse=responseValue.isArray()) != null) {
|
82 |
}
|
83 |
|
83 |
|
Line 84... |
Line 84... |
84 |
JSONArray observation;
|
84 |
public void onResponseReceived(Request request,
|
- |
|
85 |
Response response) {
|
- |
|
86 |
|
- |
|
87 |
final ListeObservation observationData ;
|
Line 85... |
Line 88... |
85 |
final int taillemax = reponse.size();
|
88 |
final JSONValue responseValue = JSONParser.parse(response.getText());
|
- |
|
89 |
|
Line -... |
Line 90... |
- |
|
90 |
JSONArray reponse=null;
|
86 |
|
91 |
|
87 |
observationData = new ListeObservation(taillemax);
|
92 |
// si c'est un tableau
|
88 |
|
- |
|
- |
|
93 |
if ((reponse=responseValue.isArray()) != null) {
|
89 |
for (int i = 0; i < taillemax; i++) {
|
94 |
|
90 |
|
- |
|
91 |
if ((observation=reponse.get(i).isArray()) != null) {
|
- |
|
92 |
|
- |
|
93 |
|
- |
|
94 |
|
- |
|
95 |
|
- |
|
96 |
String transmis=((JSONString) observation.get(13)).stringValue();
|
- |
|
97 |
String identifiantLocalite=((JSONString) observation.get(14)).toString();
|
- |
|
98 |
String nomSaisi=Util.toCelString(((JSONString) observation.get(0)).toString());
|
- |
|
99 |
String nomRetenu=Util.toCelString(((JSONString) observation.get(2)).toString());
|
- |
|
100 |
String numeroNomenclaturalSaisi=((JSONString) observation.get(1)).stringValue();
|
- |
|
101 |
String numeroNomenclaturalRetenu=((JSONString) observation.get(3)).stringValue();
|
- |
|
102 |
String numeroTaxonomique=((JSONString) observation.get(4)).stringValue();
|
- |
|
103 |
String famille=Util.toCelString(((JSONString) observation .get(5)).toString());
|
- |
|
104 |
String localite=Util.toCelString(((JSONString) observation .get(6)).toString());
|
95 |
JSONArray observation;
|
105 |
String lieudit=Util.toCelString(((JSONString) observation .get(9)).toString());
|
- |
|
Line 106... |
Line 96... |
106 |
String station=Util.toCelString(((JSONString) observation .get(10)).toString());
|
96 |
final int taillemax = reponse.size();
|
107 |
String milieu=Util.toCelString(((JSONString) observation .get(11)).toString());
|
97 |
|
- |
|
98 |
observationData = new ListeObservation(taillemax);
|
- |
|
99 |
|
- |
|
100 |
for (int i = 0; i < taillemax; i++) {
|
- |
|
101 |
|
- |
|
102 |
if ((observation=reponse.get(i).isArray()) != null) {
|
- |
|
103 |
|
- |
|
104 |
String transmis=((JSONString) observation.get(13)).stringValue();
|
- |
|
105 |
String identifiantLocalite=((JSONString) observation.get(14)).toString();
|
- |
|
106 |
String nomSaisi=Util.toCelString(((JSONString) observation.get(0)).toString());
|
- |
|
107 |
String nomRetenu=Util.toCelString(((JSONString) observation.get(2)).toString());
|
- |
|
108 |
String numeroNomenclaturalSaisi=((JSONString) observation.get(1)).stringValue();
|
- |
|
109 |
String numeroNomenclaturalRetenu=((JSONString) observation.get(3)).stringValue();
|
- |
|
110 |
String numeroTaxonomique=((JSONString) observation.get(4)).stringValue();
|
108 |
String commentaire=Util.toCelString(((JSONString) observation .get(12)).toString());
|
111 |
String famille=Util.toCelString(((JSONString) observation .get(5)).toString());
|
- |
|
112 |
String localite=Util.toCelString(((JSONString) observation .get(6)).toString());
|
109 |
String date=((JSONString) observation .get(8)).stringValue();
|
113 |
String lieudit=Util.toCelString(((JSONString) observation .get(9)).toString());
|
- |
|
114 |
String station=Util.toCelString(((JSONString) observation .get(10)).toString());
|
Line -... |
Line 115... |
- |
|
115 |
String milieu=Util.toCelString(((JSONString) observation .get(11)).toString());
|
- |
|
116 |
String commentaire=Util.toCelString(((JSONString) observation .get(12)).toString());
|
- |
|
117 |
String date=((JSONString) observation .get(8)).stringValue();
|
- |
|
118 |
String numeroOrdre=((JSONString) observation.get(7)).stringValue();
|
- |
|
119 |
|
- |
|
120 |
Observation obs=new Observation(transmis, nomSaisi, nomRetenu, numeroNomenclaturalSaisi, numeroNomenclaturalRetenu ,numeroTaxonomique, famille, localite, identifiantLocalite, lieudit, station, milieu, commentaire, date, numeroOrdre);
|
- |
|
121 |
|
110 |
String numeroOrdre=((JSONString) observation.get(7)).stringValue();
|
122 |
observationData.put(obs.getNumeroOrdre(),obs);
|
111 |
|
123 |
}
|
112 |
Observation obs=new Observation(transmis, nomSaisi, nomRetenu, numeroNomenclaturalSaisi, numeroNomenclaturalRetenu ,numeroTaxonomique, famille, localite, identifiantLocalite, lieudit, station, milieu, commentaire, date, numeroOrdre);
|
124 |
|
113 |
|
125 |
}
|
114 |
observationData.put(obs.getNumeroOrdre(),obs);
|
126 |
} else {
|
115 |
}
|
127 |
|
116 |
|
128 |
observationData = new ListeObservation(0) ;
|
- |
|
129 |
}
|
- |
|
130 |
|
- |
|
131 |
// dans tous les cas on transmet la liste crée au rafraichissable en lui demandant de répandre les données car il est
|
- |
|
132 |
// le premier à les recevoir
|
117 |
}
|
133 |
r.rafraichir(observationData,true);
|
118 |
|
134 |
}
|
Line 119... |
Line 135... |
119 |
// dans tous les cas on transmet la liste crée au rafraichissable en lui demandant de répandre les données car il est
|
135 |
}) ;
|