Line 24... |
Line 24... |
24 |
import com.google.gwt.i18n.client.DateTimeFormat;
|
24 |
import com.google.gwt.i18n.client.DateTimeFormat;
|
25 |
import com.google.gwt.json.client.JSONArray;
|
25 |
import com.google.gwt.json.client.JSONArray;
|
26 |
import com.google.gwt.json.client.JSONObject;
|
26 |
import com.google.gwt.json.client.JSONObject;
|
27 |
import com.google.gwt.json.client.JSONParser;
|
27 |
import com.google.gwt.json.client.JSONParser;
|
28 |
import com.google.gwt.json.client.JSONValue;
|
28 |
import com.google.gwt.json.client.JSONValue;
|
29 |
import com.google.gwt.user.client.Window;
|
- |
|
Line 30... |
Line 29... |
30 |
|
29 |
|
31 |
/**
|
30 |
/**
|
32 |
* Centralisation des methodes de parsing du code JSON retourné par les
|
31 |
* Centralisation des methodes de parsing du code JSON retourné par les
|
33 |
* webservices
|
32 |
* webservices
|
Line 75... |
Line 74... |
75 |
observation.setDateReleve(getValeurOuVide(observationJson, "date_observation"));
|
74 |
observation.setDateReleve(getValeurOuVide(observationJson, "date_observation"));
|
76 |
observation.setFamille(getValeurOuVide(observationJson, "determination.famille"));
|
75 |
observation.setFamille(getValeurOuVide(observationJson, "determination.famille"));
|
77 |
observation.setId(getValeurOuVide(observationJson, "id_observation"));
|
76 |
observation.setId(getValeurOuVide(observationJson, "id_observation"));
|
78 |
observation.setIdLocalite(getValeurOuVide(observationJson, "id_zone_geo"));
|
77 |
observation.setIdLocalite(getValeurOuVide(observationJson, "id_zone_geo"));
|
79 |
observation.setLocalite(getValeurOuVide(observationJson, "zone_geo"));
|
78 |
observation.setLocalite(getValeurOuVide(observationJson, "zone_geo"));
|
80 |
|
79 |
|
81 |
String nomRetenu = getValeurOuVide(observationJson, "determination.ns");
|
80 |
String nomRetenu = getValeurOuVide(observationJson, "determination.ns");
|
82 |
observation.setNomRetenu(getValeurOuVide(observationJson, "determination.ns"));
|
81 |
observation.setNomRetenu(getValeurOuVide(observationJson, "determination.ns"));
|
83 |
observation.setMilieu(getValeurOuVide(observationJson, "milieu"));
|
82 |
observation.setMilieu(getValeurOuVide(observationJson, "milieu"));
|
84 |
observation.setLieuDit(getValeurOuVide(observationJson, "lieudit"));
|
83 |
observation.setLieuDit(getValeurOuVide(observationJson, "lieudit"));
|
85 |
observation.setStation(getValeurOuVide(observationJson, "station"));
|
84 |
observation.setStation(getValeurOuVide(observationJson, "station"));
|
86 |
observation.setCommentaire(getValeurOuVide(observationJson, "commentaire"));
|
85 |
observation.setCommentaire(getValeurOuVide(observationJson, "commentaire"));
|
87 |
observation.setNumNomenclatural(getValeurOuVide(observationJson, "determination.nn"));
|
86 |
observation.setNumNomenclatural(getValeurOuVide(observationJson, "determination.nn"));
|
88 |
observation.setMotsClefs(parserMotsCles(UtilitairesServiceResultat.getValeurOuVide(observationJson, "mots_cles_texte")));
|
87 |
observation.setMotsClefs(parserMotsCles(UtilitairesServiceResultat.getValeurOuVide(observationJson, "mots_cles_texte")));
|
89 |
JSONValue propositions = observationJson.get("commentaires");
|
88 |
JSONValue propositions = observationJson.get("commentaires");
|
90 |
|
89 |
|
91 |
boolean creerPropositionAPartirObs = true;
|
90 |
boolean creerPropositionAPartirObs = true;
|
Line 92... |
Line 91... |
92 |
|
91 |
|
93 |
if (propositions != null && propositions.isObject() != null) {
|
92 |
if (propositions != null && propositions.isObject() != null) {
|
94 |
List<InterventionForum> interventions = parserInterventions(propositions.isObject());
|
93 |
List<InterventionForum> interventions = parserInterventions(propositions.isObject());
|
95 |
for (InterventionForum interventionForum : interventions) {
|
94 |
for (InterventionForum interventionForum : interventions) {
|
96 |
interventionForum.setObservation(observation);
|
95 |
interventionForum.setObservation(observation);
|
- |
|
96 |
// Si une proposition avec le même nom retenu que l'observation
|
97 |
// Si une proposition avec le même nom retenu que l'observation est déjà présente,
|
97 |
// est déjà présente,
|
- |
|
98 |
// alors il n'est pas nécessaire de créer la proposition
|
98 |
// alors il n'est pas nécessaire de créer la proposition "factice"
|
99 |
// "factice"
|
99 |
if(interventionForum instanceof PropositionDetermination) {
|
100 |
if (interventionForum instanceof PropositionDetermination) {
|
100 |
PropositionDetermination proposition = (PropositionDetermination)interventionForum;
|
101 |
PropositionDetermination proposition = (PropositionDetermination) interventionForum;
|
101 |
if(!nomRetenu.equals("") && proposition.getEspece().equals(nomRetenu)) {
|
102 |
if (!nomRetenu.equals("") && proposition.getEspece().equals(nomRetenu)) {
|
102 |
creerPropositionAPartirObs = false;
|
103 |
creerPropositionAPartirObs = false;
|
103 |
}
|
104 |
}
|
104 |
}
|
105 |
}
|
105 |
}
|
106 |
}
|
106 |
observation.setInterventionsForum(interventions);
|
107 |
observation.setInterventionsForum(interventions);
|
107 |
}
|
108 |
}
|
108 |
|
109 |
|
109 |
if(creerPropositionAPartirObs) {
|
110 |
if (creerPropositionAPartirObs) {
|
- |
|
111 |
// Si elle est nécessaire, la proposition factice est ajoutée au
|
110 |
// Si elle est nécessaire, la proposition factice est ajoutée au début
|
112 |
// début
|
111 |
observation.getInterventionsForum().add(0, creerPropositionDeterminationAPartirObservation(observation));
|
113 |
observation.getInterventionsForum().add(0, creerPropositionDeterminationAPartirObservation(observation));
|
112 |
}
|
114 |
}
|
113 |
return observation;
|
115 |
return observation;
|
Line 121... |
Line 123... |
121 |
*/
|
123 |
*/
|
122 |
private static PropositionDetermination creerPropositionDeterminationAPartirObservation(Observation observation) {
|
124 |
private static PropositionDetermination creerPropositionDeterminationAPartirObservation(Observation observation) {
|
Line 123... |
Line 125... |
123 |
|
125 |
|
124 |
String utilisateurNom = observation.getNomAuteur();
|
126 |
String utilisateurNom = observation.getNomAuteur();
|
125 |
String utilisateurPrenom = observation.getPrenomAuteur();
|
127 |
String utilisateurPrenom = observation.getPrenomAuteur();
|
126 |
|
128 |
|
127 |
String utilisateurCourriel = observation.getCourrielAuteur();
|
129 |
String utilisateurCourriel = observation.getCourrielAuteur();
|
128 |
String utilisateurId = observation.getIdAuteur();
|
130 |
String utilisateurId = observation.getIdAuteur();
|
129 |
PropositionDetermination propositionDetermination = new PropositionDetermination(observation);
|
131 |
PropositionDetermination propositionDetermination = new PropositionDetermination(observation);
|
130 |
Contributeur contributeur = new Contributeur(utilisateurId, utilisateurNom, utilisateurPrenom, utilisateurCourriel);
|
132 |
Contributeur contributeur = new Contributeur(utilisateurId, utilisateurNom, utilisateurPrenom, utilisateurCourriel);
|
Line 200... |
Line 202... |
200 |
// intervention.setObservation(observation);
|
202 |
// intervention.setObservation(observation);
|
201 |
intervention.setEspece(nom_sel);
|
203 |
intervention.setEspece(nom_sel);
|
Line 202... |
Line 204... |
202 |
|
204 |
|
203 |
if (!nbCommentaires.equals("")) {
|
205 |
if (!nbCommentaires.equals("")) {
|
204 |
int nbComm = Integer.parseInt(nbCommentaires);
|
206 |
int nbComm = Integer.parseInt(nbCommentaires);
|
205 |
// if (!texte.equals("")) {
|
207 |
// if (!texte.equals("")) {
|
206 |
// nbComm++;
|
208 |
// nbComm++;
|
207 |
// }
|
209 |
// }
|
208 |
intervention.setNbCommentaires(nbComm);
|
210 |
intervention.setNbCommentaires(nbComm);
|
Line 209... |
Line 211... |
209 |
}
|
211 |
}
|
210 |
|
212 |
|
Line 236... |
Line 238... |
236 |
InterventionForum intervention = interventionsNonTypees.get(id);
|
238 |
InterventionForum intervention = interventionsNonTypees.get(id);
|
237 |
String idParent = intervention.getIdParent();
|
239 |
String idParent = intervention.getIdParent();
|
238 |
if (idParent != null && !idParent.equals("") && !idParent.equals("0") && interventionsNonTypees.containsKey(idParent)) {
|
240 |
if (idParent != null && !idParent.equals("") && !idParent.equals("0") && interventionsNonTypees.containsKey(idParent)) {
|
239 |
InterventionForum parent = interventionsNonTypees.get(idParent);
|
241 |
InterventionForum parent = interventionsNonTypees.get(idParent);
|
240 |
intervention.setParent(parent);
|
242 |
intervention.setParent(parent);
|
241 |
parent.ajouterCommentaire((Commentaire)intervention);
|
243 |
parent.ajouterCommentaire((Commentaire) intervention);
|
242 |
}
|
- |
|
243 |
else{
|
244 |
} else {
|
244 |
retour.add(intervention);
|
245 |
retour.add(intervention);
|
245 |
}
|
246 |
}
|
246 |
}
|
247 |
}
|
Line 247... |
Line 248... |
247 |
|
248 |
|
Line 468... |
Line 469... |
468 |
// TODO ajouter vérifications plus précises
|
469 |
// TODO ajouter vérifications plus précises
|
469 |
if (retourJson.isObject().get("entete") != null) {
|
470 |
if (retourJson.isObject().get("entete") != null) {
|
470 |
double total = retourJson.isObject().get("entete").isObject().get("total").isNumber().doubleValue();
|
471 |
double total = retourJson.isObject().get("entete").isObject().get("total").isNumber().doubleValue();
|
471 |
nbTotalImagesPourLaRecherche = (int) total;
|
472 |
nbTotalImagesPourLaRecherche = (int) total;
|
472 |
JSONObject tableauImg = retourJson.isObject().get("resultats").isObject();
|
473 |
JSONObject tableauImg = retourJson.isObject().get("resultats").isObject();
|
- |
|
474 |
if (tableauImg != null) {
|
473 |
java.util.Iterator<String> it = tableauImg.keySet().iterator();
|
475 |
java.util.Iterator<String> it = tableauImg.keySet().iterator();
|
474 |
while (it.hasNext()) {
|
476 |
while (it.hasNext()) {
|
475 |
JSONObject imageJson = tableauImg.get(it.next()).isObject();
|
477 |
JSONObject imageJson = tableauImg.get(it.next()).isObject();
|
476 |
Image image = parserRetourImage(imageJson);
|
478 |
Image image = parserRetourImage(imageJson);
|
477 |
images.add(image);
|
479 |
images.add(image);
|
- |
|
480 |
}
|
478 |
}
|
481 |
}
|
Line 479... |
Line 482... |
479 |
|
482 |
|
480 |
} else {
|
483 |
} else {
|
481 |
JSONArray tableauImg = retourJson.isObject().get("images").isArray();
|
484 |
JSONArray tableauImg = retourJson.isObject().get("images").isArray();
|