Subversion Repositories eFlore/Applications.del

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
392 aurelien 1
package org.tela_botanica.del.client.services.rest;
2
 
530 jpm 3
import org.tela_botanica.del.client.config.Config;
392 aurelien 4
import org.tela_botanica.del.client.modeles.InformationsRecherche;
5
import org.tela_botanica.del.client.services.rest.async.ObservationsCallback;
939 benjamin 6
import org.tela_botanica.del.client.services.rest.async.PHPCallback.ModeRequete;
392 aurelien 7
 
8
import com.google.gwt.http.client.RequestBuilder;
9
 
10
public class ObservationServiceConcret implements ObservationService {
445 benjamin 11
 
530 jpm 12
	private String baseUrl;
392 aurelien 13
 
530 jpm 14
	public ObservationServiceConcret() {
15
		Config config = new Config();
16
		this.baseUrl = config.getServiceBaseUrl();
17
	}
18
 
19
	public ObservationServiceConcret(Config config) {
20
		this.baseUrl = config.getServiceBaseUrl();
21
	}
22
 
392 aurelien 23
	@Override
521 aurelien 24
	public void getObservations(InformationsRecherche infos, int debut, int fin, ObservationsCallback callback) {
768 aurelien 25
		RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, baseUrl + "observations" + assemblerChaineRequete(infos, debut, fin));
939 benjamin 26
		callback.setMode(ModeRequete.LECTURE);
392 aurelien 27
		try {
28
			rb.sendRequest(null, callback);
29
		} catch (Exception e) {
30
			// TODO: handle exception
31
		}
32
	}
445 benjamin 33
 
392 aurelien 34
	private String assemblerChaineRequete(InformationsRecherche infos, int debut, int fin) {
445 benjamin 35
 
768 aurelien 36
		String chaineRequete = "?navigation.depart=" + debut + "&navigation.limite=" + (fin - debut);
474 aurelien 37
		chaineRequete+= infos.versChaineRequete();
445 benjamin 38
 
392 aurelien 39
		return chaineRequete;
40
	}
845 aurelien 41
 
42
	@Override
43
	public void getObservation(String idObservation,
44
			ObservationsCallback callback) {
45
		RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, baseUrl + "observations/"+idObservation);
939 benjamin 46
		callback.setMode(ModeRequete.LECTURE);
845 aurelien 47
		try {
48
			rb.sendRequest(null, callback);
49
		} catch (Exception e) {
50
			// TODO: handle exception
51
		}
52
	}
392 aurelien 53
}