346 |
aurelien |
1 |
package org.tela_botanica.del.client.services.rest;
|
|
|
2 |
|
|
|
3 |
import org.tela_botanica.del.client.modeles.InformationsRecherche;
|
|
|
4 |
import org.tela_botanica.del.client.services.rest.async.ImagesParTaxonCallback;
|
|
|
5 |
|
|
|
6 |
import com.google.gwt.http.client.RequestBuilder;
|
|
|
7 |
|
|
|
8 |
public class ImageServiceConcret implements ImageService {
|
|
|
9 |
|
|
|
10 |
private String serverUrl = "../jrest/";
|
|
|
11 |
|
|
|
12 |
@Override
|
|
|
13 |
public void getImagesEfloreParTaxon(String taxon, ImagesParTaxonCallback callback) {
|
|
|
14 |
|
|
|
15 |
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, serverUrl+"ImagesEflore");
|
|
|
16 |
try {
|
|
|
17 |
rb.sendRequest("nom_taxon="+taxon, callback);
|
|
|
18 |
} catch (Exception e) {
|
|
|
19 |
// TODO: handle exception
|
|
|
20 |
}
|
|
|
21 |
}
|
|
|
22 |
|
|
|
23 |
@Override
|
|
|
24 |
public void getImagesParTaxon(InformationsRecherche infos, int debut, int fin, ImagesParTaxonCallback callback) {
|
|
|
25 |
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, serverUrl+"Observations");
|
|
|
26 |
try {
|
|
|
27 |
rb.sendRequest(assemblerChaineRequete(infos, debut, fin), callback);
|
|
|
28 |
} catch (Exception e) {
|
|
|
29 |
// TODO: handle exception
|
|
|
30 |
}
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
private String assemblerChaineRequete(InformationsRecherche infos, int debut, int fin) {
|
|
|
34 |
|
|
|
35 |
String chaineRequete = "&debut="+debut+"&limite="+(fin-debut);
|
|
|
36 |
if(infos != null && infos.getTaxon() != null && !infos.getTaxon().trim().isEmpty()) {
|
|
|
37 |
chaineRequete = "nom_taxon="+infos.getTaxon()+chaineRequete;
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
return chaineRequete;
|
|
|
41 |
}
|
|
|
42 |
}
|