Line 1... |
Line 1... |
1 |
package org.tela_botanica.del.client.services.rest;
|
1 |
package org.tela_botanica.del.client.services.rest;
|
Line 2... |
Line 2... |
2 |
|
2 |
|
3 |
import org.tela_botanica.del.client.config.Config;
|
3 |
import org.tela_botanica.del.client.config.Config;
|
- |
|
4 |
import org.tela_botanica.del.client.modeles.InformationsRecherche;
|
- |
|
5 |
import org.tela_botanica.del.client.modeles.Observation;
|
- |
|
6 |
import org.tela_botanica.del.client.modeles.VoteDetermination;
|
4 |
import org.tela_botanica.del.client.modeles.InformationsRecherche;
|
7 |
import org.tela_botanica.del.client.services.rest.async.DepublicationObservationCallBack;
|
5 |
import org.tela_botanica.del.client.services.rest.async.ObservationsCallback;
|
8 |
import org.tela_botanica.del.client.services.rest.async.ObservationsCallback;
|
6 |
import org.tela_botanica.del.client.services.rest.async.PHPCallback.ModeRequete;
|
- |
|
7 |
|
9 |
import org.tela_botanica.del.client.services.rest.async.PHPCallback.ModeRequete;
|
Line 8... |
Line 10... |
8 |
import org.tela_botanica.del.client.services.RequestBuilderWithCredentials;
|
10 |
import org.tela_botanica.del.client.services.RequestBuilderWithCredentials;
|
Line 9... |
Line 11... |
9 |
|
11 |
|
Line 30... |
Line 32... |
30 |
// TODO: handle exception
|
32 |
// TODO: handle exception
|
31 |
}
|
33 |
}
|
32 |
}
|
34 |
}
|
Line 33... |
Line 35... |
33 |
|
35 |
|
34 |
private String assemblerChaineRequete(InformationsRecherche infos, int debut, int fin, String statut) {
|
- |
|
35 |
|
36 |
private String assemblerChaineRequete(InformationsRecherche infos, int debut, int fin, String statut) {
|
36 |
String chaineRequete = "?navigation.depart=" + debut + "&navigation.limite=" + (fin - debut);
|
37 |
String chaineRequete = "?navigation.depart=" + debut + "&navigation.limite=" + (fin - debut);
|
37 |
if (statut != null && !statut.equals("tous")) {
|
38 |
if (statut != null && !statut.equals("tous")) {
|
38 |
chaineRequete += "&masque.type=" + statut;
|
39 |
chaineRequete += "&masque.type=" + statut;
|
39 |
}
|
40 |
}
|
Line 40... |
Line 41... |
40 |
chaineRequete+= infos.versChaineRequete();
|
41 |
chaineRequete+= infos.versChaineRequete();
|
41 |
|
42 |
|
Line 42... |
Line 43... |
42 |
return chaineRequete;
|
43 |
return chaineRequete;
|
43 |
}
|
44 |
}
|
44 |
|
- |
|
45 |
@Override
|
45 |
|
46 |
public void getObservation(String idObservation,
|
46 |
@Override
|
47 |
ObservationsCallback callback) {
|
47 |
public void getObservation(String idObservation, ObservationsCallback callback) {
|
48 |
RequestBuilderWithCredentials rb = new RequestBuilderWithCredentials(RequestBuilderWithCredentials.GET, baseUrl + "observations/"+idObservation);
|
48 |
RequestBuilderWithCredentials rb = new RequestBuilderWithCredentials(RequestBuilderWithCredentials.GET, baseUrl + "observations/"+idObservation);
|
49 |
callback.setMode(ModeRequete.LECTURE);
|
49 |
callback.setMode(ModeRequete.LECTURE);
|
50 |
try {
|
50 |
try {
|
51 |
rb.sendRequest(null, callback);
|
51 |
rb.sendRequest(null, callback);
|
52 |
} catch (Exception e) {
|
52 |
} catch (Exception e) {
|
- |
|
53 |
// TODO: handle exception
|
- |
|
54 |
}
|
- |
|
55 |
}
|
- |
|
56 |
|
- |
|
57 |
public void depublier(Observation observation, DepublicationObservationCallBack callback) {
|
- |
|
58 |
String urlService = baseUrl+"observations/"+observation.getId();
|
- |
|
59 |
RequestBuilderWithCredentials rb = new RequestBuilderWithCredentials(RequestBuilderWithCredentials.POST, urlService);
|
- |
|
60 |
|
- |
|
61 |
callback.setMode(ModeRequete.MODIFICATION);
|
- |
|
62 |
String chainePost = "transmission=0";
|
- |
|
63 |
try {
|
- |
|
64 |
rb.sendRequest(chainePost, callback);
|
- |
|
65 |
} catch (Exception e) {
|
53 |
// TODO: handle exception
|
66 |
//TODO: quoi faire si la requete est mal formée coté client avant d'être envoyée ?
|