Subversion Repositories eFlore/Applications.del

Rev

Rev 521 | Rev 845 | Go to most recent revision | Details | Compare with Previous | 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.modeles.ObservationServiceResultat;
6
import org.tela_botanica.del.client.services.rest.async.ObservationsCallback;
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) {
530 jpm 25
		RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, baseUrl + "Observations" + assemblerChaineRequete(infos, debut, fin));
392 aurelien 26
		try {
27
			rb.sendRequest(null, callback);
28
		} catch (Exception e) {
29
			// TODO: handle exception
30
		}
31
	}
445 benjamin 32
 
392 aurelien 33
	private String assemblerChaineRequete(InformationsRecherche infos, int debut, int fin) {
445 benjamin 34
 
35
		String chaineRequete = "?debut=" + debut + "&limite=" + (fin - debut);
474 aurelien 36
		chaineRequete+= infos.versChaineRequete();
445 benjamin 37
 
392 aurelien 38
		return chaineRequete;
39
	}
40
}