Subversion Repositories eFlore/Applications.del

Rev

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