| 392 |
aurelien |
1 |
package org.tela_botanica.del.client.services.rest;
|
|
|
2 |
|
| 445 |
benjamin |
3 |
import org.tela_botanica.del.client.cache.CacheClient;
|
| 392 |
aurelien |
4 |
import org.tela_botanica.del.client.modeles.InformationsRecherche;
|
| 445 |
benjamin |
5 |
import org.tela_botanica.del.client.modeles.Observation;
|
| 392 |
aurelien |
6 |
import org.tela_botanica.del.client.modeles.ObservationServiceResultat;
|
|
|
7 |
import org.tela_botanica.del.client.services.rest.async.ObservationsCallback;
|
|
|
8 |
|
|
|
9 |
import com.google.gwt.http.client.RequestBuilder;
|
|
|
10 |
|
|
|
11 |
public class ObservationServiceConcret implements ObservationService {
|
| 445 |
benjamin |
12 |
|
| 425 |
benjamin |
13 |
private String serverUrl = "/del/jrest/";
|
| 392 |
aurelien |
14 |
|
|
|
15 |
@Override
|
| 445 |
benjamin |
16 |
public ObservationServiceResultat getObservations(InformationsRecherche infos, int debut, int fin, ObservationsCallback callback) {
|
|
|
17 |
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, serverUrl + "Observations" + assemblerChaineRequete(infos, debut, fin));
|
| 392 |
aurelien |
18 |
try {
|
|
|
19 |
rb.sendRequest(null, callback);
|
|
|
20 |
} catch (Exception e) {
|
|
|
21 |
// TODO: handle exception
|
|
|
22 |
}
|
|
|
23 |
return null;
|
|
|
24 |
}
|
| 445 |
benjamin |
25 |
|
| 392 |
aurelien |
26 |
private String assemblerChaineRequete(InformationsRecherche infos, int debut, int fin) {
|
| 445 |
benjamin |
27 |
|
|
|
28 |
String chaineRequete = "?debut=" + debut + "&limite=" + (fin - debut);
|
|
|
29 |
if (infos != null && infos.getTaxon() != null && !infos.getTaxon().trim().isEmpty()) {
|
|
|
30 |
chaineRequete += "nom_taxon=" + infos.getTaxon() + chaineRequete;
|
| 392 |
aurelien |
31 |
}
|
| 445 |
benjamin |
32 |
|
| 392 |
aurelien |
33 |
return chaineRequete;
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
}
|