Subversion Repositories eFlore/Applications.del

Rev

Rev 491 | Rev 765 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
 
501 aurelien 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);
474 aurelien 50
		chaineRequete+= infos.versChaineRequete();
445 benjamin 51
 
346 aurelien 52
		return chaineRequete;
53
	}
54
}