Rev 769 | Rev 802 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package org.tela_botanica.del.client.modeles;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.tela_botanica.del.client.utils.UtilitairesServiceResultat;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONValue;
import com.google.gwt.user.client.Window;
public class ObservationServiceResultat {
private List<Observation> observations;
private int nbTotalObservationsPourLaRecherche;
public ObservationServiceResultat(JSONValue retourJson) {
//TODO ajouter vérifications plus précises
double total = retourJson.isObject().get("entete").isObject().get("total").isNumber().doubleValue();
nbTotalObservationsPourLaRecherche = (int) total;
JSONObject tableauObs = retourJson.isObject().get("resultats").isObject();
observations = new ArrayList<Observation>();
java.util.Iterator<String> it = tableauObs.keySet().iterator();
while (it.hasNext()) {
JSONObject observationJson = tableauObs.get(it.next()).isObject();
Observation observation = UtilitairesServiceResultat.parserObservationEtCreerPropositionDetermination(observationJson);
JSONArray tableauImagesObs = observationJson.get("images").isArray();
List<Image> imagesPourObs = new ArrayList<Image>();
int nbImages = tableauImagesObs.size();
for (int j = 0; j < nbImages; j++) {
JSONObject imageJson = tableauImagesObs.get(j).isObject();
Image image = UtilitairesServiceResultat.parserImageJSON(imageJson);
image.setObservation(observation);
imagesPourObs.add(image);
}
observation.setImages(imagesPourObs);
observations.add(observation);
}
}
public List<Observation> getObservations() {
return observations;
}
public void setObservations(List<Observation> observations) {
this.observations = observations;
}
public int getNbTotalObservationsPourLaRecherche() {
return nbTotalObservationsPourLaRecherche;
}
public void setNbTotalObservationsPourLaRecherche(int nbTotalObservationsPourLaRecherche) {
this.nbTotalObservationsPourLaRecherche = nbTotalObservationsPourLaRecherche;
}
}