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 {
|
445 |
benjamin |
9 |
|
425 |
benjamin |
10 |
private String serverUrl = "/del/jrest/";
|
346 |
aurelien |
11 |
|
|
|
12 |
@Override
|
|
|
13 |
public void getImagesEfloreParTaxon(String taxon, ImagesParTaxonCallback callback) {
|
445 |
benjamin |
14 |
|
|
|
15 |
// RequestBuilder rb = new RequestBuilder(RequestBuilder.GET,
|
|
|
16 |
// serverUrl+"ImagesEflore");
|
|
|
17 |
// adresse ajoutee temporairement le temps de faire fonctionner le
|
|
|
18 |
// service d'images eflore
|
|
|
19 |
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, serverUrl + "Images?nom_taxon=" + taxon);
|
346 |
aurelien |
20 |
try {
|
382 |
aurelien |
21 |
rb.sendRequest(null, callback);
|
346 |
aurelien |
22 |
} catch (Exception e) {
|
|
|
23 |
// TODO: handle exception
|
|
|
24 |
}
|
|
|
25 |
}
|
|
|
26 |
|
|
|
27 |
@Override
|
|
|
28 |
public void getImagesParTaxon(InformationsRecherche infos, int debut, int fin, ImagesParTaxonCallback callback) {
|
445 |
benjamin |
29 |
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, serverUrl + "Images" + assemblerChaineRequete(infos, debut, fin));
|
346 |
aurelien |
30 |
try {
|
382 |
aurelien |
31 |
rb.sendRequest(null, callback);
|
346 |
aurelien |
32 |
} catch (Exception e) {
|
|
|
33 |
// TODO: handle exception
|
|
|
34 |
}
|
|
|
35 |
}
|
445 |
benjamin |
36 |
|
|
|
37 |
public void getImagesParObservation(String observationId, ImagesParTaxonCallback callback) {
|
|
|
38 |
// TODO implementer avec une methode realiste
|
466 |
aurelien |
39 |
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, serverUrl + "ImagesPourObservation/"+observationId);
|
|
|
40 |
try {
|
|
|
41 |
rb.sendRequest(null, callback);
|
|
|
42 |
} catch (Exception e) {
|
|
|
43 |
// TODO: handle exception
|
|
|
44 |
}
|
445 |
benjamin |
45 |
}
|
|
|
46 |
|
346 |
aurelien |
47 |
private String assemblerChaineRequete(InformationsRecherche infos, int debut, int fin) {
|
445 |
benjamin |
48 |
|
|
|
49 |
String chaineRequete = "?debut=" + debut + "&limite=" + (fin - debut);
|
|
|
50 |
if (infos != null && infos.getTaxon() != null && !infos.getTaxon().trim().isEmpty()) {
|
|
|
51 |
chaineRequete += "nom_taxon=" + infos.getTaxon() + chaineRequete;
|
346 |
aurelien |
52 |
}
|
466 |
aurelien |
53 |
|
|
|
54 |
if(infos != null && infos.getTriParDate() != null) {
|
|
|
55 |
chaineRequete += "&tri=date_observation&ordre="+infos.getTriParDate().toString();
|
|
|
56 |
}
|
445 |
benjamin |
57 |
|
346 |
aurelien |
58 |
return chaineRequete;
|
|
|
59 |
}
|
|
|
60 |
}
|