| Line 1... |
Line 1... |
| 1 |
package org.tela_botanica.del.client.modeles;
|
1 |
package org.tela_botanica.del.client.modeles;
|
| Line 2... |
Line 2... |
| 2 |
|
2 |
|
| 3 |
import java.util.ArrayList;
|
- |
|
| 4 |
import java.util.Date;
|
3 |
import java.util.ArrayList;
|
| Line -... |
Line 4... |
| - |
|
4 |
import java.util.List;
|
| 5 |
import java.util.List;
|
5 |
|
| Line 6... |
Line -... |
| 6 |
|
- |
|
| 7 |
import org.tela_botanica.del.client.utils.UtilitairesServiceResultat;
|
6 |
import org.tela_botanica.del.client.cache.CacheClient;
|
| 8 |
|
7 |
import org.tela_botanica.del.client.utils.UtilitairesServiceResultat;
|
| 9 |
import com.google.gwt.i18n.client.DateTimeFormat;
|
8 |
|
| 10 |
import com.google.gwt.json.client.JSONArray;
|
- |
|
| Line 11... |
Line 9... |
| 11 |
import com.google.gwt.json.client.JSONObject;
|
9 |
import com.google.gwt.json.client.JSONArray;
|
| Line 12... |
Line 10... |
| 12 |
import com.google.gwt.json.client.JSONValue;
|
10 |
import com.google.gwt.json.client.JSONObject;
|
| Line 13... |
Line 11... |
| 13 |
import com.google.gwt.user.client.Window;
|
11 |
import com.google.gwt.json.client.JSONValue;
|
| Line 14... |
Line 12... |
| 14 |
|
12 |
|
| 15 |
public class ObservationServiceResultat {
|
- |
|
| 16 |
|
- |
|
| 17 |
private List<Observation> observations;
|
- |
|
| 18 |
|
- |
|
| Line 19... |
Line 13... |
| 19 |
private int nbTotalObservationsPourLaRecherche;
|
13 |
public class ObservationServiceResultat {
|
| Line 20... |
Line 14... |
| 20 |
|
14 |
|
| 21 |
public ObservationServiceResultat(JSONValue retourJson) {
|
15 |
private List<Observation> observations;
|
| 22 |
//TODO ajouter vérifications plus précises
|
16 |
|
| 23 |
double total = retourJson.isObject().get("entete").isObject().get("total").isNumber().doubleValue();
|
- |
|
| 24 |
nbTotalObservationsPourLaRecherche = (int) total;
|
17 |
private int nbTotalObservationsPourLaRecherche;
|
| 25 |
JSONObject tableauObs = retourJson.isObject().get("resultats").isObject();
|
18 |
|
| 26 |
|
19 |
public ObservationServiceResultat(JSONValue retourJson) {
|
| 27 |
observations = new ArrayList<Observation>();
|
- |
|
| 28 |
|
20 |
|
| 29 |
if(tableauObs != null) {
|
- |
|
| 30 |
java.util.Iterator<String> it = tableauObs.keySet().iterator();
|
21 |
observations = new ArrayList<Observation>();
|
| 31 |
while (it.hasNext()) {
|
22 |
|
| 32 |
|
23 |
if(retourJson.isObject().get("entete") != null) {
|
| 33 |
JSONObject observationJson = tableauObs.get(it.next()).isObject();
|
- |
|
| 34 |
Observation observation = UtilitairesServiceResultat.parserObservationEtCreerPropositionDetermination(observationJson);
|
24 |
//TODO ajouter vérifications plus précises
|
| 35 |
|
25 |
double total = retourJson.isObject().get("entete").isObject().get("total").isNumber().doubleValue();
|
| 36 |
JSONArray tableauImagesObs = observationJson.get("images").isArray();
|
- |
|
| 37 |
List<Image> imagesPourObs = new ArrayList<Image>();
|
26 |
nbTotalObservationsPourLaRecherche = (int) total;
|
| 38 |
|
- |
|
| 39 |
int nbImages = tableauImagesObs.size();
|
- |
|
| 40 |
for (int j = 0; j < nbImages; j++) {
|
- |
|
| 41 |
JSONObject imageJson = tableauImagesObs.get(j).isObject();
|
27 |
JSONObject tableauObs = retourJson.isObject().get("resultats").isObject();
|
| - |
|
28 |
|
| - |
|
29 |
if(tableauObs != null) {
|
| - |
|
30 |
java.util.Iterator<String> it = tableauObs.keySet().iterator();
|
| - |
|
31 |
while (it.hasNext()) {
|
| - |
|
32 |
JSONObject observationJson = tableauObs.get(it.next()).isObject();
|
| 42 |
|
33 |
Observation observation = analyserObservation(observationJson);
|
| 43 |
Image image = UtilitairesServiceResultat.parserImageJSON(imageJson);
|
34 |
observations.add(observation);
|
| - |
|
35 |
}
|
| - |
|
36 |
}
|
| - |
|
37 |
} else {
|
| - |
|
38 |
JSONObject observationJson = retourJson.isObject();
|
| - |
|
39 |
Observation observation = analyserObservation(observationJson);
|
| - |
|
40 |
observations.add(observation);
|
| - |
|
41 |
CacheClient.getInstance().setObservationCourante(observation);
|
| - |
|
42 |
}
|
| - |
|
43 |
}
|
| - |
|
44 |
|
| - |
|
45 |
private Observation analyserObservation(JSONObject observationJson) {
|
| - |
|
46 |
Observation observation = UtilitairesServiceResultat.parserObservationEtCreerPropositionDetermination(observationJson);
|
| - |
|
47 |
JSONArray tableauImagesObs = observationJson.get("images").isArray();
|
| - |
|
48 |
List<Image> imagesPourObs = new ArrayList<Image>();
|
| - |
|
49 |
|
| - |
|
50 |
int nbImages = tableauImagesObs.size();
|
| - |
|
51 |
for (int j = 0; j < nbImages; j++) {
|
| - |
|
52 |
JSONObject imageJson = tableauImagesObs.get(j).isObject();
|
| - |
|
53 |
|
| - |
|
54 |
Image image = UtilitairesServiceResultat.parserImageJSON(imageJson);
|
| - |
|
55 |
if (imageJson.get("protocoles_votes") != null && imageJson.get("protocoles_votes").isObject() != null) {
|
| - |
|
56 |
JSONObject votes = imageJson.get("protocoles_votes").isObject();
|
| - |
|
57 |
image.setVoteProtocoles(UtilitairesServiceResultat.parserVotesProtocoles(votes));
|
| Line 44... |
Line 58... |
| 44 |
image.setObservation(observation);
|
58 |
}
|
| 45 |
imagesPourObs.add(image);
|
59 |
image.setObservation(observation);
|
| 46 |
}
|
60 |
imagesPourObs.add(image);
|