| 339 |
benjamin |
1 |
package org.tela_botanica.del.client.modeles;
|
|
|
2 |
|
| 348 |
aurelien |
3 |
import java.util.ArrayList;
|
|
|
4 |
import java.util.Date;
|
| 443 |
aurelien |
5 |
import java.util.HashMap;
|
| 339 |
benjamin |
6 |
import java.util.List;
|
| 500 |
aurelien |
7 |
import java.util.Map;
|
| 339 |
benjamin |
8 |
|
| 500 |
aurelien |
9 |
import org.tela_botanica.del.client.utils.UtilitairesServiceResultat;
|
|
|
10 |
|
|
|
11 |
import com.google.gwt.core.client.GWT;
|
| 764 |
aurelien |
12 |
import com.google.gwt.dev.js.rhino.ObjToIntMap.Iterator;
|
| 348 |
aurelien |
13 |
import com.google.gwt.i18n.client.DateTimeFormat;
|
|
|
14 |
import com.google.gwt.json.client.JSONArray;
|
|
|
15 |
import com.google.gwt.json.client.JSONObject;
|
|
|
16 |
import com.google.gwt.json.client.JSONValue;
|
| 500 |
aurelien |
17 |
import com.google.gwt.user.client.Window;
|
| 348 |
aurelien |
18 |
|
| 340 |
benjamin |
19 |
public class ImageServiceResultat {
|
| 534 |
benjamin |
20 |
|
| 339 |
benjamin |
21 |
private List<Image> images;
|
| 534 |
benjamin |
22 |
|
| 339 |
benjamin |
23 |
private int nbTotalImagesPourLaRecherche;
|
| 534 |
benjamin |
24 |
|
| 348 |
aurelien |
25 |
public ImageServiceResultat(JSONValue retourJson) {
|
| 764 |
aurelien |
26 |
|
| 534 |
benjamin |
27 |
try {
|
|
|
28 |
// TODO ajouter vérifications plus précises
|
| 764 |
aurelien |
29 |
double total = retourJson.isObject().get("entete").isObject().get("total").isNumber().doubleValue();
|
| 534 |
benjamin |
30 |
nbTotalImagesPourLaRecherche = (int) total;
|
|
|
31 |
|
| 764 |
aurelien |
32 |
JSONObject tableauObs = retourJson.isObject().get("resultats").isObject();
|
| 534 |
benjamin |
33 |
images = new ArrayList<Image>();
|
| 764 |
aurelien |
34 |
|
|
|
35 |
java.util.Iterator<String> it = tableauObs.keySet().iterator();
|
| 534 |
benjamin |
36 |
|
| 764 |
aurelien |
37 |
while (it.hasNext()) {
|
|
|
38 |
JSONObject imageJson = tableauObs.get(it.next()).isObject();
|
| 534 |
benjamin |
39 |
Image image = UtilitairesServiceResultat.parserImageJSON(imageJson);
|
| 764 |
aurelien |
40 |
|
| 534 |
benjamin |
41 |
if (imageJson.get("observation") != null && imageJson.get("observation").isObject() != null) {
|
|
|
42 |
JSONObject observationJson = imageJson.get("observation").isObject();
|
|
|
43 |
image.setObservation(UtilitairesServiceResultat.parserObservationEtCreerPropositionDetermination(observationJson));
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
if (imageJson.get("votes") != null && imageJson.get("votes").isArray() != null) {
|
|
|
47 |
JSONArray votes = imageJson.get("votes").isArray();
|
|
|
48 |
image.setVoteProtocoles(UtilitairesServiceResultat.parserVotesProtocoles(votes));
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
images.add(image);
|
| 443 |
aurelien |
52 |
}
|
| 534 |
benjamin |
53 |
} catch (Exception e) {
|
|
|
54 |
|
| 348 |
aurelien |
55 |
}
|
|
|
56 |
}
|
| 534 |
benjamin |
57 |
|
| 339 |
benjamin |
58 |
public List<Image> getImages() {
|
|
|
59 |
return images;
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
public void setImages(List<Image> images) {
|
|
|
63 |
this.images = images;
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
public int getNbTotalImagesPourLaRecherche() {
|
|
|
67 |
return nbTotalImagesPourLaRecherche;
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
public void setNbTotalImagesPourLaRecherche(int nbTotalImagesPourLaRecherche) {
|
|
|
71 |
this.nbTotalImagesPourLaRecherche = nbTotalImagesPourLaRecherche;
|
|
|
72 |
}
|
|
|
73 |
}
|