346 |
aurelien |
1 |
package org.tela_botanica.del.client.services.rest;
|
|
|
2 |
|
530 |
jpm |
3 |
import org.tela_botanica.del.client.config.Config;
|
346 |
aurelien |
4 |
import org.tela_botanica.del.client.modeles.InformationsRecherche;
|
|
|
5 |
import org.tela_botanica.del.client.services.rest.async.ImagesParTaxonCallback;
|
|
|
6 |
|
|
|
7 |
import com.google.gwt.http.client.RequestBuilder;
|
|
|
8 |
|
|
|
9 |
public class ImageServiceConcret implements ImageService {
|
445 |
benjamin |
10 |
|
530 |
jpm |
11 |
private String baseUrl;
|
|
|
12 |
|
|
|
13 |
public ImageServiceConcret() {
|
|
|
14 |
Config config = new Config();
|
|
|
15 |
this.baseUrl = config.getServiceBaseUrl();
|
|
|
16 |
}
|
|
|
17 |
|
|
|
18 |
public ImageServiceConcret(Config config) {
|
|
|
19 |
this.baseUrl = config.getServiceBaseUrl();
|
|
|
20 |
}
|
|
|
21 |
|
346 |
aurelien |
22 |
@Override
|
|
|
23 |
public void getImagesEfloreParTaxon(String taxon, ImagesParTaxonCallback callback) {
|
445 |
benjamin |
24 |
|
|
|
25 |
// RequestBuilder rb = new RequestBuilder(RequestBuilder.GET,
|
|
|
26 |
// serverUrl+"ImagesEflore");
|
|
|
27 |
// adresse ajoutee temporairement le temps de faire fonctionner le
|
|
|
28 |
// service d'images eflore
|
765 |
aurelien |
29 |
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, baseUrl + "images?nom_taxon=" + taxon);
|
346 |
aurelien |
30 |
try {
|
382 |
aurelien |
31 |
rb.sendRequest(null, callback);
|
346 |
aurelien |
32 |
} catch (Exception e) {
|
|
|
33 |
// TODO: handle exception
|
|
|
34 |
}
|
|
|
35 |
}
|
|
|
36 |
|
|
|
37 |
@Override
|
|
|
38 |
public void getImagesParTaxon(InformationsRecherche infos, int debut, int fin, ImagesParTaxonCallback callback) {
|
765 |
aurelien |
39 |
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, baseUrl + "images" + assemblerChaineRequete(infos, debut, fin));
|
346 |
aurelien |
40 |
try {
|
382 |
aurelien |
41 |
rb.sendRequest(null, callback);
|
346 |
aurelien |
42 |
} catch (Exception e) {
|
|
|
43 |
// TODO: handle exception
|
|
|
44 |
}
|
|
|
45 |
}
|
445 |
benjamin |
46 |
|
|
|
47 |
public void getImagesParObservation(String observationId, ImagesParTaxonCallback callback) {
|
|
|
48 |
// TODO implementer avec une methode realiste
|
765 |
aurelien |
49 |
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, baseUrl + "observations/"+observationId);
|
466 |
aurelien |
50 |
try {
|
|
|
51 |
rb.sendRequest(null, callback);
|
|
|
52 |
} catch (Exception e) {
|
|
|
53 |
// TODO: handle exception
|
|
|
54 |
}
|
445 |
benjamin |
55 |
}
|
|
|
56 |
|
346 |
aurelien |
57 |
private String assemblerChaineRequete(InformationsRecherche infos, int debut, int fin) {
|
445 |
benjamin |
58 |
|
765 |
aurelien |
59 |
String chaineRequete = "?navigation.depart=" + debut + "&navigation.limite=" + (fin - debut);
|
474 |
aurelien |
60 |
chaineRequete+= infos.versChaineRequete();
|
445 |
benjamin |
61 |
|
346 |
aurelien |
62 |
return chaineRequete;
|
|
|
63 |
}
|
|
|
64 |
}
|