1 |
package org.tela_botanica.del.client.utils;
|
1 |
package org.tela_botanica.del.client.utils;
|
2 |
|
2 |
|
3 |
import java.util.ArrayList;
|
3 |
import java.util.ArrayList;
|
4 |
import java.util.Date;
|
4 |
import java.util.Date;
|
5 |
import java.util.HashMap;
|
5 |
import java.util.HashMap;
|
6 |
import java.util.Iterator;
|
6 |
import java.util.Iterator;
|
7 |
import java.util.List;
|
7 |
import java.util.List;
|
8 |
|
8 |
|
9 |
import org.tela_botanica.del.client.cache.CacheClient;
|
9 |
import org.tela_botanica.del.client.cache.CacheClient;
|
10 |
import org.tela_botanica.del.client.config.Config;
|
10 |
import org.tela_botanica.del.client.config.Config;
|
11 |
import org.tela_botanica.del.client.modeles.Commentaire;
|
11 |
import org.tela_botanica.del.client.modeles.Commentaire;
|
12 |
import org.tela_botanica.del.client.modeles.Contributeur;
|
12 |
import org.tela_botanica.del.client.modeles.Contributeur;
|
13 |
import org.tela_botanica.del.client.modeles.Image;
|
13 |
import org.tela_botanica.del.client.modeles.Image;
|
14 |
import org.tela_botanica.del.client.modeles.ImageServiceResultat;
|
14 |
import org.tela_botanica.del.client.modeles.ImageServiceResultat;
|
15 |
import org.tela_botanica.del.client.modeles.InterventionForum;
|
15 |
import org.tela_botanica.del.client.modeles.InterventionForum;
|
16 |
import org.tela_botanica.del.client.modeles.MotCle;
|
16 |
import org.tela_botanica.del.client.modeles.MotCle;
|
17 |
import org.tela_botanica.del.client.modeles.Observation;
|
17 |
import org.tela_botanica.del.client.modeles.Observation;
|
18 |
import org.tela_botanica.del.client.modeles.ObservationServiceResultat;
|
18 |
import org.tela_botanica.del.client.modeles.ObservationServiceResultat;
|
19 |
import org.tela_botanica.del.client.modeles.PropositionDetermination;
|
19 |
import org.tela_botanica.del.client.modeles.PropositionDetermination;
|
20 |
import org.tela_botanica.del.client.modeles.Protocole;
|
20 |
import org.tela_botanica.del.client.modeles.Protocole;
|
21 |
import org.tela_botanica.del.client.modeles.ProtocoleServiceResultat;
|
21 |
import org.tela_botanica.del.client.modeles.ProtocoleServiceResultat;
|
22 |
import org.tela_botanica.del.client.modeles.Utilisateur;
|
22 |
import org.tela_botanica.del.client.modeles.Utilisateur;
|
23 |
import org.tela_botanica.del.client.modeles.VoteDetermination;
|
23 |
import org.tela_botanica.del.client.modeles.VoteDetermination;
|
24 |
import org.tela_botanica.del.client.modeles.VoteProtocole;
|
24 |
import org.tela_botanica.del.client.modeles.VoteProtocole;
|
25 |
|
25 |
|
26 |
import com.google.gwt.core.shared.GWT;
|
26 |
import com.google.gwt.core.shared.GWT;
|
27 |
import com.google.gwt.i18n.client.DateTimeFormat;
|
27 |
import com.google.gwt.i18n.client.DateTimeFormat;
|
28 |
import com.google.gwt.json.client.JSONArray;
|
28 |
import com.google.gwt.json.client.JSONArray;
|
29 |
import com.google.gwt.json.client.JSONObject;
|
29 |
import com.google.gwt.json.client.JSONObject;
|
30 |
import com.google.gwt.json.client.JSONParser;
|
30 |
import com.google.gwt.json.client.JSONParser;
|
31 |
import com.google.gwt.json.client.JSONValue;
|
31 |
import com.google.gwt.json.client.JSONValue;
|
32 |
import com.google.gwt.user.client.Window;
|
32 |
import com.google.gwt.user.client.Window;
|
33 |
|
33 |
|
34 |
/**
|
34 |
/**
|
35 |
* Centralisation des methodes de parsing du code JSON retourné par les
|
35 |
* Centralisation des methodes de parsing du code JSON retourné par les
|
36 |
* webservices
|
36 |
* webservices
|
37 |
*
|
37 |
*
|
38 |
* @author LIENS
|
38 |
* @author LIENS
|
39 |
*
|
39 |
*
|
40 |
*/
|
40 |
*/
|
41 |
public class UtilitairesServiceResultat {
|
41 |
public class UtilitairesServiceResultat {
|
42 |
|
42 |
|
43 |
/**
|
43 |
/**
|
44 |
* Recupere un objet Image à partir du JSON
|
44 |
* Recupere un objet Image à partir du JSON
|
45 |
*
|
45 |
*
|
46 |
* @param imageJson
|
46 |
* @param imageJson
|
47 |
* @return
|
47 |
* @return
|
48 |
*/
|
48 |
*/
|
49 |
public static Image parserImageJSON(JSONObject imageJson) {
|
49 |
public static Image parserImageJSON(JSONObject imageJson) {
|
50 |
|
50 |
|
51 |
Image image = new Image();
|
51 |
Image image = new Image();
|
52 |
Config config = new Config();
|
52 |
Config config = new Config();
|
53 |
String urlImages = config.getUrl("images");
|
53 |
String urlImages = config.getUrl("images");
|
54 |
String idImage = imageJson.get("id_image").isString().stringValue();
|
54 |
String idImage = imageJson.get("id_image").isString().stringValue();
|
55 |
image.setIdImage(idImage);
|
55 |
image.setIdImage(idImage);
|
56 |
image.setUrlFormat(urlImages + getIdAvecPadding(idImage) + "%s%.jpg");
|
56 |
image.setUrlFormat(urlImages + getIdAvecPadding(idImage) + "%s%.jpg");
|
57 |
image.setUrl(urlImages + getIdAvecPadding(idImage) + "CRS.jpg");
|
57 |
image.setUrl(urlImages + getIdAvecPadding(idImage) + "CRS.jpg");
|
58 |
image.setMiniature(urlImages + getIdAvecPadding(idImage) + "XS.jpg");
|
58 |
image.setMiniature(urlImages + getIdAvecPadding(idImage) + "XS.jpg");
|
59 |
image.setMotsClefs(parserMotsCles(UtilitairesServiceResultat.getValeurOuVide(imageJson, "mots_cles_texte")));
|
59 |
image.setMotsClefs(parserMotsCles(UtilitairesServiceResultat.getValeurOuVide(imageJson, "mots_cles_texte")));
|
60 |
|
60 |
|
61 |
return image;
|
61 |
return image;
|
62 |
}
|
62 |
}
|
63 |
|
63 |
|
64 |
/**
|
64 |
/**
|
65 |
* Recupere un objet Observation à partir du JSON
|
65 |
* Recupere un objet Observation à partir du JSON
|
66 |
*
|
66 |
*
|
67 |
* @param imageJson
|
67 |
* @param imageJson
|
68 |
* @return
|
68 |
* @return
|
69 |
*/
|
69 |
*/
|
70 |
public static Observation parserObservationJSON(JSONObject observationJson) {
|
70 |
public static Observation parserObservationJSON(JSONObject observationJson) {
|
71 |
|
71 |
|
72 |
Observation observation = new Observation();
|
72 |
Observation observation = new Observation();
|
73 |
observation.setAuteur(getValeurOuVide(observationJson, "auteur.prenom") + " " + getValeurOuVide(observationJson, "auteur.nom"));
|
73 |
observation.setAuteur(getValeurOuVide(observationJson, "auteur.prenom") + " " + getValeurOuVide(observationJson, "auteur.nom"));
|
74 |
observation.setNomAuteur(getValeurOuVide(observationJson, "auteur.nom"));
|
74 |
observation.setNomAuteur(getValeurOuVide(observationJson, "auteur.nom"));
|
75 |
observation.setPrenomAuteur(getValeurOuVide(observationJson, "auteur.prenom"));
|
75 |
observation.setPrenomAuteur(getValeurOuVide(observationJson, "auteur.prenom"));
|
76 |
observation.setIdAuteur(getValeurOuVide(observationJson, "auteur.id"));
|
76 |
observation.setIdAuteur(getValeurOuVide(observationJson, "auteur.id"));
|
77 |
// TODO: renvoyer le courriel de l'auteur dans les obs
|
77 |
// TODO: renvoyer le courriel de l'auteur dans les obs
|
78 |
observation.setCourrielAuteur(getValeurOuVide(observationJson, "auteur.courriel"));
|
78 |
observation.setCourrielAuteur(getValeurOuVide(observationJson, "auteur.courriel"));
|
79 |
observation.setDateTransmission(getValeurOuVide(observationJson, "date_transmission"));
|
79 |
observation.setDateTransmission(getValeurOuVide(observationJson, "date_transmission"));
|
80 |
observation.setDateReleve(getValeurOuVide(observationJson, "date_observation"));
|
80 |
observation.setDateReleve(getValeurOuVide(observationJson, "date_observation"));
|
81 |
observation.setFamille(getValeurOuVide(observationJson, "determination.famille"));
|
81 |
observation.setFamille(getValeurOuVide(observationJson, "determination.famille"));
|
82 |
observation.setId(getValeurOuVide(observationJson, "id_observation"));
|
82 |
observation.setId(getValeurOuVide(observationJson, "id_observation"));
|
83 |
observation.setIdLocalite(getValeurOuVide(observationJson, "id_zone_geo"));
|
83 |
observation.setIdLocalite(getValeurOuVide(observationJson, "id_zone_geo"));
|
84 |
observation.setLocalite(getValeurOuVide(observationJson, "zone_geo"));
|
84 |
observation.setLocalite(getValeurOuVide(observationJson, "zone_geo"));
|
85 |
|
85 |
|
86 |
String nomRetenu = getValeurOuVide(observationJson, "determination.ns");
|
86 |
String nomRetenu = getValeurOuVide(observationJson, "determination.ns");
|
87 |
observation.setNomRetenu(getValeurOuVide(observationJson, "determination.ns"));
|
87 |
observation.setNomRetenu(getValeurOuVide(observationJson, "determination.ns"));
|
88 |
observation.setMilieu(getValeurOuVide(observationJson, "milieu"));
|
88 |
observation.setMilieu(getValeurOuVide(observationJson, "milieu"));
|
89 |
observation.setLieuDit(getValeurOuVide(observationJson, "lieudit"));
|
89 |
observation.setLieuDit(getValeurOuVide(observationJson, "lieudit"));
|
90 |
observation.setStation(getValeurOuVide(observationJson, "station"));
|
90 |
observation.setStation(getValeurOuVide(observationJson, "station"));
|
91 |
observation.setCommentaire(getValeurOuVide(observationJson, "commentaire"));
|
91 |
observation.setCommentaire(getValeurOuVide(observationJson, "commentaire"));
|
92 |
observation.setNumNomenclatural(getValeurOuVide(observationJson, "determination.nn"));
|
92 |
observation.setNumNomenclatural(getValeurOuVide(observationJson, "determination.nn"));
|
93 |
observation.setReferentiel(getValeurOuVide(observationJson, "determination.referentiel"));
|
93 |
observation.setReferentiel(getValeurOuVide(observationJson, "determination.referentiel"));
|
94 |
String nbCom = getValeurOuVide(observationJson, "nb_commentaires");
|
94 |
String nbCom = getValeurOuVide(observationJson, "nb_commentaires");
|
95 |
nbCom = nbCom.equals("") ? "0" : nbCom;
|
95 |
nbCom = nbCom.equals("") ? "0" : nbCom;
|
96 |
observation.setNbCommentaires(nbCom);
|
96 |
observation.setNbCommentaires(nbCom);
|
97 |
observation.setMotsClefs(parserMotsCles(UtilitairesServiceResultat.getValeurOuVide(observationJson, "mots_cles_texte")));
|
97 |
observation.setMotsClefs(parserMotsCles(UtilitairesServiceResultat.getValeurOuVide(observationJson, "mots_cles_texte")));
|
98 |
JSONValue propositions = observationJson.get("commentaires");
|
98 |
JSONValue propositions = observationJson.get("commentaires");
|
99 |
|
99 |
|
100 |
boolean creerPropositionAPartirObs = true;
|
100 |
boolean creerPropositionAPartirObs = true;
|
101 |
boolean propositionInitialeExiste = false;
|
101 |
boolean propositionInitialeExiste = false;
|
102 |
PropositionDetermination propositionPotentiellementInitiale = null;
|
102 |
PropositionDetermination propositionPotentiellementInitiale = null;
|
103 |
if (propositions != null && propositions.isObject() != null) {
|
103 |
if (propositions != null && propositions.isObject() != null) {
|
104 |
List<InterventionForum> interventions = parserInterventions(propositions.isObject());
|
104 |
List<InterventionForum> interventions = parserInterventions(propositions.isObject());
|
105 |
|
105 |
|
106 |
for (InterventionForum interventionForum : interventions) {
|
106 |
for (InterventionForum interventionForum : interventions) {
|
107 |
interventionForum.setObservation(observation);
|
107 |
interventionForum.setObservation(observation);
|
108 |
// Si une proposition avec le même nom retenu que l'observation
|
108 |
// Si une proposition avec le même nom retenu que l'observation
|
109 |
// est déjà présente,
|
109 |
// est déjà présente,
|
110 |
// alors il n'est pas nécessaire de créer la proposition
|
110 |
// alors il n'est pas nécessaire de créer la proposition
|
111 |
// "factice"
|
111 |
// "factice"
|
112 |
if (interventionForum instanceof PropositionDetermination) {
|
112 |
if (interventionForum instanceof PropositionDetermination) {
|
113 |
PropositionDetermination proposition = (PropositionDetermination) interventionForum;
|
113 |
PropositionDetermination proposition = (PropositionDetermination) interventionForum;
|
114 |
// Si la proposition correspond au nom retenu (non vide) en cours
|
114 |
// Si la proposition correspond au nom retenu (non vide) en cours
|
115 |
if (!nomRetenu.equals("") && proposition.getEspece().equals(nomRetenu)) {
|
115 |
if (!nomRetenu.equals("") && proposition.getEspece().equals(nomRetenu)) {
|
116 |
creerPropositionAPartirObs = false;
|
116 |
creerPropositionAPartirObs = false;
|
117 |
//proposition.setDate(parserDateObservation(observation.getDateReleve()));
|
117 |
//proposition.setDate(parserDateObservation(observation.getDateReleve()));
|
118 |
}
|
118 |
}
|
119 |
|
119 |
|
120 |
if (proposition.getEspece().equals(observation.getNomRetenu()) && proposition.getContributeur().getNomComplet().equals(observation.getAuteur())) {
|
120 |
if (proposition.getEspece().equals(observation.getNomRetenu()) && proposition.getContributeur().getNomComplet().equals(observation.getAuteur())) {
|
121 |
propositionPotentiellementInitiale = proposition;
|
121 |
propositionPotentiellementInitiale = proposition;
|
122 |
}
|
122 |
}
|
123 |
|
123 |
|
124 |
if (proposition.estPropositionInitiale()) {
|
124 |
if (proposition.estPropositionInitiale()) {
|
125 |
propositionInitialeExiste = true;
|
125 |
propositionInitialeExiste = true;
|
126 |
}
|
126 |
}
|
127 |
}
|
127 |
}
|
128 |
}
|
128 |
}
|
129 |
observation.setInterventionsForum(interventions);
|
129 |
observation.setInterventionsForum(interventions);
|
130 |
}
|
130 |
}
|
131 |
|
131 |
|
132 |
if (!propositionInitialeExiste && propositionPotentiellementInitiale != null) {
|
132 |
if (!propositionInitialeExiste && propositionPotentiellementInitiale != null) {
|
133 |
propositionPotentiellementInitiale.setEstPropositionInitiale(true);
|
133 |
propositionPotentiellementInitiale.setEstPropositionInitiale(true);
|
134 |
}
|
134 |
}
|
135 |
|
135 |
|
136 |
if (creerPropositionAPartirObs) {
|
136 |
if (creerPropositionAPartirObs) {
|
137 |
// Si elle est nécessaire, la proposition factice est ajoutée au
|
137 |
// Si elle est nécessaire, la proposition factice est ajoutée au
|
138 |
// début
|
138 |
// début
|
139 |
observation.getInterventionsForum().add(0, creerPropositionDeterminationAPartirObservation(observation, propositionInitialeExiste));
|
139 |
observation.getInterventionsForum().add(0, creerPropositionDeterminationAPartirObservation(observation, propositionInitialeExiste));
|
140 |
}
|
140 |
}
|
141 |
return observation;
|
141 |
return observation;
|
142 |
|
142 |
|
143 |
}
|
143 |
}
|
144 |
|
144 |
|
145 |
|
145 |
|
146 |
/**
|
146 |
/**
|
147 |
* Créée une proposition de determination à partir d'une observation
|
147 |
* Créée une proposition de determination à partir d'une observation
|
148 |
*
|
148 |
*
|
149 |
* @param observation
|
149 |
* @param observation
|
150 |
* @return
|
150 |
* @return
|
151 |
*/
|
151 |
*/
|
152 |
private static PropositionDetermination creerPropositionDeterminationAPartirObservation(Observation observation, boolean propositionInitialeExiste) {
|
152 |
private static PropositionDetermination creerPropositionDeterminationAPartirObservation(Observation observation, boolean propositionInitialeExiste) {
|
153 |
|
153 |
|
154 |
String utilisateurNom = observation.getNomAuteur();
|
154 |
String utilisateurNom = observation.getNomAuteur();
|
155 |
String utilisateurPrenom = observation.getPrenomAuteur();
|
155 |
String utilisateurPrenom = observation.getPrenomAuteur();
|
156 |
|
156 |
|
157 |
String utilisateurCourriel = observation.getCourrielAuteur();
|
157 |
String utilisateurCourriel = observation.getCourrielAuteur();
|
158 |
String utilisateurId = observation.getIdAuteur();
|
158 |
String utilisateurId = observation.getIdAuteur();
|
159 |
PropositionDetermination propositionDetermination = new PropositionDetermination(observation);
|
159 |
PropositionDetermination propositionDetermination = new PropositionDetermination(observation);
|
160 |
Contributeur contributeur = new Contributeur(utilisateurId, utilisateurNom, utilisateurPrenom, utilisateurCourriel);
|
160 |
Contributeur contributeur = new Contributeur(utilisateurId, utilisateurNom, utilisateurPrenom, utilisateurCourriel);
|
161 |
propositionDetermination.setContributeur(contributeur);
|
161 |
propositionDetermination.setContributeur(contributeur);
|
162 |
java.util.Date datePropDeter = parserDateObservation(observation.getDateTransmission());
|
162 |
java.util.Date datePropDeter = parserDateObservation(observation.getDateTransmission());
|
163 |
propositionDetermination.setDate(datePropDeter);
|
163 |
propositionDetermination.setDate(datePropDeter);
|
164 |
propositionDetermination.setEspece(observation.getNomRetenu());
|
164 |
propositionDetermination.setEspece(observation.getNomRetenu());
|
165 |
if (!propositionInitialeExiste) {
|
165 |
if (!propositionInitialeExiste) {
|
166 |
propositionDetermination.setEstPropositionInitiale(true);
|
166 |
propositionDetermination.setEstPropositionInitiale(true);
|
167 |
}
|
167 |
}
|
168 |
|
168 |
|
169 |
|
169 |
|
170 |
return propositionDetermination;
|
170 |
return propositionDetermination;
|
171 |
}
|
171 |
}
|
172 |
|
172 |
|
173 |
/**
|
173 |
/**
|
174 |
* Recupere une liste de commentaires à partir du JSON
|
174 |
* Recupere une liste de commentaires à partir du JSON
|
175 |
*
|
175 |
*
|
176 |
* @param imageJson
|
176 |
* @param imageJson
|
177 |
* @return
|
177 |
* @return
|
178 |
*/
|
178 |
*/
|
179 |
public static List<Commentaire> parserCommentaires(JSONObject commentaires) {
|
179 |
public static List<Commentaire> parserCommentaires(JSONObject commentaires) {
|
180 |
List<InterventionForum> interventionForums = parserInterventions(commentaires);
|
180 |
List<InterventionForum> interventionForums = parserInterventions(commentaires);
|
181 |
List<Commentaire> commentairesListe = new ArrayList<Commentaire>();
|
181 |
List<Commentaire> commentairesListe = new ArrayList<Commentaire>();
|
182 |
for (InterventionForum interventionForum : interventionForums) {
|
182 |
for (InterventionForum interventionForum : interventionForums) {
|
183 |
if (interventionForum instanceof Commentaire) {
|
183 |
if (interventionForum instanceof Commentaire) {
|
184 |
commentairesListe.add((Commentaire) interventionForum);
|
184 |
commentairesListe.add((Commentaire) interventionForum);
|
185 |
}
|
185 |
}
|
186 |
}
|
186 |
}
|
187 |
return commentairesListe;
|
187 |
return commentairesListe;
|
188 |
|
188 |
|
189 |
}
|
189 |
}
|
190 |
|
190 |
|
191 |
/**
|
191 |
/**
|
192 |
* Recupere une liste d'interventions à partir du JSON
|
192 |
* Recupere une liste d'interventions à partir du JSON
|
193 |
*
|
193 |
*
|
194 |
* @param imageJson
|
194 |
* @param imageJson
|
195 |
* @return
|
195 |
* @return
|
196 |
*/
|
196 |
*/
|
197 |
public static List<InterventionForum> parserInterventions(JSONObject interventions) {
|
197 |
public static List<InterventionForum> parserInterventions(JSONObject interventions) {
|
198 |
HashMap<String, InterventionForum> interventionsNonTypees = new HashMap<String, InterventionForum>();
|
198 |
HashMap<String, InterventionForum> interventionsNonTypees = new HashMap<String, InterventionForum>();
|
199 |
|
199 |
|
200 |
List<InterventionForum> retour = new ArrayList<InterventionForum>();
|
200 |
List<InterventionForum> retour = new ArrayList<InterventionForum>();
|
201 |
|
201 |
|
202 |
// parcourir les interventions et en faire un tableau
|
202 |
// parcourir les interventions et en faire un tableau
|
203 |
if (interventions == null) {
|
203 |
if (interventions == null) {
|
204 |
return retour;
|
204 |
return retour;
|
205 |
}
|
205 |
}
|
206 |
Iterator<String> itInterventions = interventions.keySet().iterator();
|
206 |
Iterator<String> itInterventions = interventions.keySet().iterator();
|
207 |
while (itInterventions.hasNext()) {
|
207 |
while (itInterventions.hasNext()) {
|
208 |
JSONObject jsonIntervention = interventions.get(itInterventions.next()).isObject();
|
208 |
JSONObject jsonIntervention = interventions.get(itInterventions.next()).isObject();
|
209 |
String nomSel = getValeurOuVide(jsonIntervention, "nom_sel");
|
209 |
String nomSel = getValeurOuVide(jsonIntervention, "nom_sel");
|
210 |
|
210 |
|
211 |
String id = getValeurOuVide(jsonIntervention, "id_commentaire");
|
211 |
String id = getValeurOuVide(jsonIntervention, "id_commentaire");
|
212 |
String idParent = getValeurOuVide(jsonIntervention, "id_parent");
|
212 |
String idParent = getValeurOuVide(jsonIntervention, "id_parent");
|
213 |
String texte = getValeurOuVide(jsonIntervention, "texte");
|
213 |
String texte = getValeurOuVide(jsonIntervention, "texte");
|
214 |
|
214 |
|
215 |
String idUtilisateur = getValeurOuVide(jsonIntervention, "auteur.id");
|
215 |
String idUtilisateur = getValeurOuVide(jsonIntervention, "auteur.id");
|
216 |
String nom = getValeurOuVide(jsonIntervention, "auteur.nom");
|
216 |
String nom = getValeurOuVide(jsonIntervention, "auteur.nom");
|
217 |
String prenom = getValeurOuVide(jsonIntervention, "auteur.prenom");
|
217 |
String prenom = getValeurOuVide(jsonIntervention, "auteur.prenom");
|
218 |
String courriel = getValeurOuVide(jsonIntervention, "auteur.courriel");
|
218 |
String courriel = getValeurOuVide(jsonIntervention, "auteur.courriel");
|
219 |
Contributeur contributeur = new Contributeur(idUtilisateur, nom, prenom, courriel);
|
219 |
Contributeur contributeur = new Contributeur(idUtilisateur, nom, prenom, courriel);
|
220 |
|
220 |
|
221 |
Date date = parserDateObservation(getValeurOuVide(jsonIntervention, "date"));
|
221 |
Date date = parserDateObservation(getValeurOuVide(jsonIntervention, "date"));
|
222 |
|
222 |
|
223 |
if (!nomSel.equals("")) {
|
223 |
if (!nomSel.equals("")) {
|
224 |
String nom_sel = getValeurOuVide(jsonIntervention, "nom_sel");
|
224 |
String nom_sel = getValeurOuVide(jsonIntervention, "nom_sel");
|
225 |
String nom_sel_nn = getValeurOuVide(jsonIntervention, "nom_sel_nn");
|
225 |
String nom_sel_nn = getValeurOuVide(jsonIntervention, "nom_sel_nn");
|
226 |
String nom_ret = getValeurOuVide(jsonIntervention, "nom_ret");
|
226 |
String nom_ret = getValeurOuVide(jsonIntervention, "nom_ret");
|
227 |
String nom_ret_nn = getValeurOuVide(jsonIntervention, "nom_ret_nn");
|
227 |
String nom_ret_nn = getValeurOuVide(jsonIntervention, "nom_ret_nn");
|
228 |
String famille = getValeurOuVide(jsonIntervention, "famille");
|
228 |
String famille = getValeurOuVide(jsonIntervention, "famille");
|
229 |
String nom_referentiel = getValeurOuVide(jsonIntervention, "nom_referentiel");
|
229 |
String nom_referentiel = getValeurOuVide(jsonIntervention, "nom_referentiel");
|
230 |
|
230 |
|
231 |
String nbCommentaires = getValeurOuVide(jsonIntervention, "nb_commentaires");
|
231 |
String nbCommentaires = getValeurOuVide(jsonIntervention, "nb_commentaires");
|
232 |
|
232 |
|
233 |
PropositionDetermination intervention = new PropositionDetermination(id, contributeur, texte);
|
233 |
PropositionDetermination intervention = new PropositionDetermination(id, contributeur, texte);
|
234 |
String proposition_initiale = getValeurOuVide(jsonIntervention, "proposition_initiale");
|
234 |
String proposition_initiale = getValeurOuVide(jsonIntervention, "proposition_initiale");
|
235 |
if (proposition_initiale != null && proposition_initiale.equals("1")) {
|
235 |
if (proposition_initiale != null && proposition_initiale.equals("1")) {
|
236 |
intervention.setEstPropositionInitiale(true);
|
236 |
intervention.setEstPropositionInitiale(true);
|
- |
|
237 |
}
|
- |
|
238 |
|
- |
|
239 |
String proposition_retenue = getValeurOuVide(jsonIntervention, "proposition_retenue");
|
- |
|
240 |
if (proposition_retenue != null && proposition_retenue.equals("1")) {
|
- |
|
241 |
intervention.setEstPropositionRetenue(true);
|
- |
|
242 |
}
|
- |
|
243 |
|
237 |
} /*else {
|
244 |
/*else {
|
238 |
String nomRetObs = intervention.getObservation().getNomRetenu();
|
245 |
String nomRetObs = intervention.getObservation().getNomRetenu();
|
239 |
String auteur = intervention.getObservation().getAuteur();
|
246 |
String auteur = intervention.getObservation().getAuteur();
|
240 |
boolean b = nom_ret.equals(nomRetObs) && intervention.getContributeur().getNomComplet().equals(auteur);
|
247 |
boolean b = nom_ret.equals(nomRetObs) && intervention.getContributeur().getNomComplet().equals(auteur);
|
241 |
intervention.setEstPropositionInitiale(b);
|
248 |
intervention.setEstPropositionInitiale(b);
|
242 |
}*/
|
249 |
}*/
|
243 |
|
250 |
|
244 |
// intervention.setObservation(observation);
|
251 |
// intervention.setObservation(observation);
|
245 |
intervention.setEspece(nom_sel);
|
252 |
intervention.setEspece(nom_sel);
|
246 |
|
253 |
|
247 |
if (!nbCommentaires.equals("")) {
|
254 |
if (!nbCommentaires.equals("")) {
|
248 |
int nbComm = Integer.parseInt(nbCommentaires);
|
255 |
int nbComm = Integer.parseInt(nbCommentaires);
|
249 |
intervention.setNbCommentaires(nbComm);
|
256 |
intervention.setNbCommentaires(nbComm);
|
250 |
}
|
257 |
}
|
251 |
|
258 |
|
252 |
if (nom_sel_nn != null && !nom_sel_nn.equals("")) {
|
259 |
if (nom_sel_nn != null && !nom_sel_nn.equals("")) {
|
253 |
intervention.setNumNomenclatural(nom_sel_nn);
|
260 |
intervention.setNumNomenclatural(nom_sel_nn);
|
254 |
}
|
261 |
}
|
255 |
|
262 |
|
256 |
if(nom_referentiel != null && !nom_referentiel.equals("")) {
|
263 |
if(nom_referentiel != null && !nom_referentiel.equals("")) {
|
257 |
intervention.setReferentiel(nom_referentiel);
|
264 |
intervention.setReferentiel(nom_referentiel);
|
258 |
}
|
265 |
}
|
259 |
|
266 |
|
260 |
if (!idParent.equals("")) {
|
267 |
if (!idParent.equals("")) {
|
261 |
intervention.setIdParent(idParent);
|
268 |
intervention.setIdParent(idParent);
|
262 |
}
|
269 |
}
|
263 |
|
270 |
|
264 |
if (jsonIntervention.get("votes") != null && jsonIntervention.get("votes").isObject() != null) {
|
271 |
if (jsonIntervention.get("votes") != null && jsonIntervention.get("votes").isObject() != null) {
|
265 |
intervention.setVotesDeterminations(parserVotesDetermination(jsonIntervention.get("votes").isObject()));
|
272 |
intervention.setVotesDeterminations(parserVotesDetermination(jsonIntervention.get("votes").isObject()));
|
266 |
}
|
273 |
}
|
267 |
|
274 |
|
268 |
intervention.setDate(date);
|
275 |
intervention.setDate(date);
|
269 |
interventionsNonTypees.put(intervention.getId(), intervention);
|
276 |
interventionsNonTypees.put(intervention.getId(), intervention);
|
270 |
|
277 |
|
271 |
} else {
|
278 |
} else {
|
272 |
Commentaire intervention = new Commentaire(contributeur, date, texte);
|
279 |
Commentaire intervention = new Commentaire(contributeur, date, texte);
|
273 |
intervention.setId(id);
|
280 |
intervention.setId(id);
|
274 |
intervention.setDate(date);
|
281 |
intervention.setDate(date);
|
275 |
interventionsNonTypees.put(intervention.getId(), intervention);
|
282 |
interventionsNonTypees.put(intervention.getId(), intervention);
|
276 |
if (!idParent.equals("")) {
|
283 |
if (!idParent.equals("")) {
|
277 |
intervention.setIdParent(idParent);
|
284 |
intervention.setIdParent(idParent);
|
278 |
}
|
285 |
}
|
279 |
}
|
286 |
}
|
280 |
}
|
287 |
}
|
281 |
|
288 |
|
282 |
Iterator<String> itIntervention = interventionsNonTypees.keySet().iterator();
|
289 |
Iterator<String> itIntervention = interventionsNonTypees.keySet().iterator();
|
283 |
while (itIntervention.hasNext()) {
|
290 |
while (itIntervention.hasNext()) {
|
284 |
String id = itIntervention.next();
|
291 |
String id = itIntervention.next();
|
285 |
InterventionForum intervention = interventionsNonTypees.get(id);
|
292 |
InterventionForum intervention = interventionsNonTypees.get(id);
|
286 |
String idParent = intervention.getIdParent();
|
293 |
String idParent = intervention.getIdParent();
|
287 |
if (idParent != null && !idParent.equals("") && !idParent.equals("0") && interventionsNonTypees.containsKey(idParent)) {
|
294 |
if (idParent != null && !idParent.equals("") && !idParent.equals("0") && interventionsNonTypees.containsKey(idParent)) {
|
288 |
InterventionForum parent = interventionsNonTypees.get(idParent);
|
295 |
InterventionForum parent = interventionsNonTypees.get(idParent);
|
289 |
intervention.setParent(parent);
|
296 |
intervention.setParent(parent);
|
290 |
parent.ajouterCommentaire((Commentaire) intervention);
|
297 |
parent.ajouterCommentaire((Commentaire) intervention);
|
291 |
} else {
|
298 |
} else {
|
292 |
retour.add(intervention);
|
299 |
retour.add(intervention);
|
293 |
}
|
300 |
}
|
294 |
}
|
301 |
}
|
295 |
|
302 |
|
296 |
return retour;
|
303 |
return retour;
|
297 |
}
|
304 |
}
|
298 |
|
305 |
|
299 |
/**
|
306 |
/**
|
300 |
* Recupere une liste de commentaires à partir du JSON
|
307 |
* Recupere une liste de commentaires à partir du JSON
|
301 |
*
|
308 |
*
|
302 |
* @param imageJson
|
309 |
* @param imageJson
|
303 |
* @return
|
310 |
* @return
|
304 |
*/
|
311 |
*/
|
305 |
public static String convertirEtParserRetourAjoutCommentaire(String retour) {
|
312 |
public static String convertirEtParserRetourAjoutCommentaire(String retour) {
|
306 |
JSONObject retourJson = JSONParser.parseStrict(retour).isObject();
|
313 |
JSONObject retourJson = JSONParser.parseStrict(retour).isObject();
|
307 |
return parserRetourAjoutCommentaire(retourJson);
|
314 |
return parserRetourAjoutCommentaire(retourJson);
|
308 |
}
|
315 |
}
|
309 |
|
316 |
|
310 |
/**
|
317 |
/**
|
311 |
* Recupere une liste de commentaires à partir d'un objet JSON
|
318 |
* Recupere une liste de commentaires à partir d'un objet JSON
|
312 |
*
|
319 |
*
|
313 |
* @param imageJson
|
320 |
* @param imageJson
|
314 |
* @return
|
321 |
* @return
|
315 |
*/
|
322 |
*/
|
316 |
public static String parserRetourAjoutCommentaire(JSONObject retour) {
|
323 |
public static String parserRetourAjoutCommentaire(JSONObject retour) {
|
317 |
String id = "";
|
324 |
String id = "";
|
318 |
if (retour != null) {
|
325 |
if (retour != null) {
|
319 |
id = getValeurOuVide(retour, "id_commentaire");
|
326 |
id = getValeurOuVide(retour, "id_commentaire");
|
320 |
}
|
327 |
}
|
321 |
return id;
|
328 |
return id;
|
322 |
}
|
329 |
}
|
323 |
|
330 |
|
324 |
public static String getValeurOuVide(JSONObject objet, String index) {
|
331 |
public static String getValeurOuVide(JSONObject objet, String index) {
|
325 |
return (objet.get(index) != null && objet.get(index).isString() != null) ? objet.get(index).isString().stringValue() : "";
|
332 |
return (objet.get(index) != null && objet.get(index).isString() != null) ? objet.get(index).isString().stringValue() : "";
|
326 |
}
|
333 |
}
|
327 |
|
334 |
|
328 |
/**
|
335 |
/**
|
329 |
* Recupere une liste de votes sur une determination à partir du JSON
|
336 |
* Recupere une liste de votes sur une determination à partir du JSON
|
330 |
*
|
337 |
*
|
331 |
* @param imageJson
|
338 |
* @param imageJson
|
332 |
* @return
|
339 |
* @return
|
333 |
*/
|
340 |
*/
|
334 |
public static HashMap<String, VoteDetermination> parserRetourListeVotesDetermination(String votesString) {
|
341 |
public static HashMap<String, VoteDetermination> parserRetourListeVotesDetermination(String votesString) {
|
335 |
|
342 |
|
336 |
HashMap<String, VoteDetermination> retour = null;
|
343 |
HashMap<String, VoteDetermination> retour = null;
|
337 |
|
344 |
|
338 |
JSONObject votes = JSONParser.parseStrict(votesString).isObject();
|
345 |
JSONObject votes = JSONParser.parseStrict(votesString).isObject();
|
339 |
if (votes != null && votes.get("resultats") != null && votes.get("resultats").isObject() != null) {
|
346 |
if (votes != null && votes.get("resultats") != null && votes.get("resultats").isObject() != null) {
|
340 |
JSONObject resultat = votes.get("resultats").isObject();
|
347 |
JSONObject resultat = votes.get("resultats").isObject();
|
341 |
retour = parserVotesDetermination(resultat);
|
348 |
retour = parserVotesDetermination(resultat);
|
342 |
}
|
349 |
}
|
343 |
return retour;
|
350 |
return retour;
|
344 |
}
|
351 |
}
|
345 |
|
352 |
|
346 |
/**
|
353 |
/**
|
347 |
* Recupere une liste de votes sur une determination à partir d'un objet
|
354 |
* Recupere une liste de votes sur une determination à partir d'un objet
|
348 |
* JSON
|
355 |
* JSON
|
349 |
*
|
356 |
*
|
350 |
* @param imageJson
|
357 |
* @param imageJson
|
351 |
* @return
|
358 |
* @return
|
352 |
*/
|
359 |
*/
|
353 |
public static HashMap<String, VoteDetermination> parserVotesDetermination(JSONObject votes) {
|
360 |
public static HashMap<String, VoteDetermination> parserVotesDetermination(JSONObject votes) {
|
354 |
HashMap<String, VoteDetermination> votesDetermination = new HashMap<String, VoteDetermination>();
|
361 |
HashMap<String, VoteDetermination> votesDetermination = new HashMap<String, VoteDetermination>();
|
355 |
java.util.Iterator<String> itVotes = votes.keySet().iterator();
|
362 |
java.util.Iterator<String> itVotes = votes.keySet().iterator();
|
356 |
while (itVotes.hasNext()) {
|
363 |
while (itVotes.hasNext()) {
|
357 |
JSONObject vote = votes.get(itVotes.next()).isObject();
|
364 |
JSONObject vote = votes.get(itVotes.next()).isObject();
|
358 |
VoteDetermination vd = new VoteDetermination();
|
365 |
VoteDetermination vd = new VoteDetermination();
|
359 |
vd.setContributeur(getValeurOuVide(vote, "auteur.id"));
|
366 |
vd.setContributeur(getValeurOuVide(vote, "auteur.id"));
|
360 |
vd.setDate(parserDateObservation(getValeurOuVide(vote, "date")));
|
367 |
vd.setDate(parserDateObservation(getValeurOuVide(vote, "date")));
|
361 |
vd.setId(getValeurOuVide(vote, "vote.id"));
|
368 |
vd.setId(getValeurOuVide(vote, "vote.id"));
|
362 |
vd.setVote(Integer.parseInt(getValeurOuVide(vote, "vote")));
|
369 |
vd.setVote(Integer.parseInt(getValeurOuVide(vote, "vote")));
|
363 |
vd.setContributeur(getValeurOuVide(vote, "auteur.id"));
|
370 |
vd.setContributeur(getValeurOuVide(vote, "auteur.id"));
|
364 |
|
371 |
|
365 |
if (vote.get("auteur.nom") != null && vote.get("auteur.nom") != null && vote.get("auteur.courriel") != null) {
|
372 |
if (vote.get("auteur.nom") != null && vote.get("auteur.nom") != null && vote.get("auteur.courriel") != null) {
|
366 |
Contributeur auteur = new Contributeur(getValeurOuVide(vote, "auteur.id"), getValeurOuVide(vote, "auteur.nom"), getValeurOuVide(vote, "auteur.prenom"), getValeurOuVide(vote, "auteur.courriel"));
|
373 |
Contributeur auteur = new Contributeur(getValeurOuVide(vote, "auteur.id"), getValeurOuVide(vote, "auteur.nom"), getValeurOuVide(vote, "auteur.prenom"), getValeurOuVide(vote, "auteur.courriel"));
|
367 |
vd.setAuteur(auteur);
|
374 |
vd.setAuteur(auteur);
|
368 |
}
|
375 |
}
|
369 |
|
376 |
|
370 |
votesDetermination.put(getValeurOuVide(vote, "auteur.id"), vd);
|
377 |
votesDetermination.put(getValeurOuVide(vote, "auteur.id"), vd);
|
371 |
}
|
378 |
}
|
372 |
return votesDetermination;
|
379 |
return votesDetermination;
|
373 |
}
|
380 |
}
|
374 |
|
381 |
|
375 |
/**
|
382 |
/**
|
376 |
* Recupere une liste de votes sur des images à partir d'un objet JSON
|
383 |
* Recupere une liste de votes sur des images à partir d'un objet JSON
|
377 |
*
|
384 |
*
|
378 |
* @param imageJson
|
385 |
* @param imageJson
|
379 |
* @return
|
386 |
* @return
|
380 |
*/
|
387 |
*/
|
381 |
public static HashMap<String, HashMap<String, VoteProtocole>> parserVotesProtocoles(JSONObject votes) {
|
388 |
public static HashMap<String, HashMap<String, VoteProtocole>> parserVotesProtocoles(JSONObject votes) {
|
382 |
|
389 |
|
383 |
HashMap<String, HashMap<String, VoteProtocole>> votesProtocoles = new HashMap<String, HashMap<String, VoteProtocole>>();
|
390 |
HashMap<String, HashMap<String, VoteProtocole>> votesProtocoles = new HashMap<String, HashMap<String, VoteProtocole>>();
|
384 |
java.util.Iterator<String> itProtocoles = votes.keySet().iterator();
|
391 |
java.util.Iterator<String> itProtocoles = votes.keySet().iterator();
|
385 |
while (itProtocoles.hasNext()) {
|
392 |
while (itProtocoles.hasNext()) {
|
386 |
JSONObject protocole = votes.get(itProtocoles.next()).isObject();
|
393 |
JSONObject protocole = votes.get(itProtocoles.next()).isObject();
|
387 |
JSONObject votesPourCeProtocoles = protocole.get("votes").isObject();
|
394 |
JSONObject votesPourCeProtocoles = protocole.get("votes").isObject();
|
388 |
String idProtocoleVote = protocole.get("protocole.id").isString().stringValue();
|
395 |
String idProtocoleVote = protocole.get("protocole.id").isString().stringValue();
|
389 |
java.util.Iterator<String> itVotes = votesPourCeProtocoles.keySet().iterator();
|
396 |
java.util.Iterator<String> itVotes = votesPourCeProtocoles.keySet().iterator();
|
390 |
while (itVotes.hasNext()) {
|
397 |
while (itVotes.hasNext()) {
|
391 |
JSONObject voteEnCours = votesPourCeProtocoles.get(itVotes.next()).isObject();
|
398 |
JSONObject voteEnCours = votesPourCeProtocoles.get(itVotes.next()).isObject();
|
392 |
VoteProtocole vd = new VoteProtocole();
|
399 |
VoteProtocole vd = new VoteProtocole();
|
393 |
vd.setContributeur(voteEnCours.get("auteur.id").isString().stringValue());
|
400 |
vd.setContributeur(voteEnCours.get("auteur.id").isString().stringValue());
|
394 |
vd.setId(voteEnCours.get("vote.id").isString().stringValue());
|
401 |
vd.setId(voteEnCours.get("vote.id").isString().stringValue());
|
395 |
// TODO récupérer la date du vote et la parser
|
402 |
// TODO récupérer la date du vote et la parser
|
396 |
vd.setDate(parserDateObservation(getValeurOuVide(voteEnCours, "date")));
|
403 |
vd.setDate(parserDateObservation(getValeurOuVide(voteEnCours, "date")));
|
397 |
int valeurVote = Integer.parseInt(voteEnCours.get("vote").isString().stringValue());
|
404 |
int valeurVote = Integer.parseInt(voteEnCours.get("vote").isString().stringValue());
|
398 |
vd.setVote(valeurVote);
|
405 |
vd.setVote(valeurVote);
|
399 |
if (!votesProtocoles.containsKey(idProtocoleVote)) {
|
406 |
if (!votesProtocoles.containsKey(idProtocoleVote)) {
|
400 |
votesProtocoles.put(idProtocoleVote, new HashMap<String, VoteProtocole>());
|
407 |
votesProtocoles.put(idProtocoleVote, new HashMap<String, VoteProtocole>());
|
401 |
}
|
408 |
}
|
402 |
// un seul vote par utilisateur - garde le premier pour être cohérent avec commun/Stats (PHP)
|
409 |
// un seul vote par utilisateur - garde le premier pour être cohérent avec commun/Stats (PHP)
|
403 |
if (! votesProtocoles.get(idProtocoleVote).containsKey(vd.getContributeur())) {
|
410 |
if (! votesProtocoles.get(idProtocoleVote).containsKey(vd.getContributeur())) {
|
404 |
votesProtocoles.get(idProtocoleVote).put(vd.getContributeur(), vd);
|
411 |
votesProtocoles.get(idProtocoleVote).put(vd.getContributeur(), vd);
|
405 |
}
|
412 |
}
|
406 |
}
|
413 |
}
|
407 |
}
|
414 |
}
|
408 |
|
415 |
|
409 |
return votesProtocoles;
|
416 |
return votesProtocoles;
|
410 |
}
|
417 |
}
|
411 |
|
418 |
|
412 |
/**
|
419 |
/**
|
413 |
* Recupere une date à partir du JSON
|
420 |
* Recupere une date à partir du JSON
|
414 |
*
|
421 |
*
|
415 |
* @param imageJson
|
422 |
* @param imageJson
|
416 |
* @return
|
423 |
* @return
|
417 |
*/
|
424 |
*/
|
418 |
public static Date parserDateObservation(String date) {
|
425 |
public static Date parserDateObservation(String date) {
|
419 |
Date dateParsee = new Date();
|
426 |
Date dateParsee = new Date();
|
420 |
DateTimeFormat formatDateObs = DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss");
|
427 |
DateTimeFormat formatDateObs = DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss");
|
421 |
try {
|
428 |
try {
|
422 |
dateParsee = formatDateObs.parse(date);
|
429 |
dateParsee = formatDateObs.parse(date);
|
423 |
} catch (IllegalArgumentException e) {
|
430 |
} catch (IllegalArgumentException e) {
|
424 |
dateParsee = new java.sql.Date(0);
|
431 |
dateParsee = new java.sql.Date(0);
|
425 |
}
|
432 |
}
|
426 |
return dateParsee;
|
433 |
return dateParsee;
|
427 |
}
|
434 |
}
|
428 |
|
435 |
|
429 |
/**
|
436 |
/**
|
430 |
* Recupere des mots-clefs à partir du JSON
|
437 |
* Recupere des mots-clefs à partir du JSON
|
431 |
*
|
438 |
*
|
432 |
* @param imageJson
|
439 |
* @param imageJson
|
433 |
* @return
|
440 |
* @return
|
434 |
*/
|
441 |
*/
|
435 |
public static List<String> parserMotsCles(String motsClesTexte) {
|
442 |
public static List<String> parserMotsCles(String motsClesTexte) {
|
436 |
String[] tabMotsCle = motsClesTexte.split(",");
|
443 |
String[] tabMotsCle = motsClesTexte.split(",");
|
437 |
List<String> motsClesParses = new ArrayList<String>();
|
444 |
List<String> motsClesParses = new ArrayList<String>();
|
438 |
for (int i = 0; i < tabMotsCle.length; i++) {
|
445 |
for (int i = 0; i < tabMotsCle.length; i++) {
|
439 |
motsClesParses.add(tabMotsCle[i].trim());
|
446 |
motsClesParses.add(tabMotsCle[i].trim());
|
440 |
}
|
447 |
}
|
441 |
|
448 |
|
442 |
return motsClesParses;
|
449 |
return motsClesParses;
|
443 |
}
|
450 |
}
|
444 |
|
451 |
|
445 |
public static String getIdAvecPadding(String id) {
|
452 |
public static String getIdAvecPadding(String id) {
|
446 |
int maxZeros = 9 - id.length();
|
453 |
int maxZeros = 9 - id.length();
|
447 |
for (int i = 0; i < maxZeros; i++) {
|
454 |
for (int i = 0; i < maxZeros; i++) {
|
448 |
id = "0" + id;
|
455 |
id = "0" + id;
|
449 |
}
|
456 |
}
|
450 |
return id;
|
457 |
return id;
|
451 |
}
|
458 |
}
|
452 |
|
459 |
|
453 |
/**
|
460 |
/**
|
454 |
* Recupere un utilisateur à partir du JSON
|
461 |
* Recupere un utilisateur à partir du JSON
|
455 |
*
|
462 |
*
|
456 |
* @param imageJson
|
463 |
* @param imageJson
|
457 |
* @return
|
464 |
* @return
|
458 |
*/
|
465 |
*/
|
459 |
public static Utilisateur parserUtilisateurJson(JSONValue valeurJson) {
|
466 |
public static Utilisateur parserUtilisateurJson(JSONValue valeurJson) {
|
460 |
JSONObject utilisateurJson = valeurJson.isObject();
|
467 |
JSONObject utilisateurJson = valeurJson.isObject();
|
461 |
boolean connecteUtilisateur = utilisateurJson.get("connecte").isBoolean().booleanValue();
|
468 |
boolean connecteUtilisateur = utilisateurJson.get("connecte").isBoolean().booleanValue();
|
462 |
String idUtilisateur = utilisateurJson.get("id_utilisateur").isString().stringValue();
|
469 |
String idUtilisateur = utilisateurJson.get("id_utilisateur").isString().stringValue();
|
463 |
String sessionId = utilisateurJson.get("session_id").isString().stringValue();
|
470 |
String sessionId = utilisateurJson.get("session_id").isString().stringValue();
|
464 |
GWT.log(valeurJson.toString());
|
471 |
GWT.log(valeurJson.toString());
|
465 |
|
472 |
|
466 |
Utilisateur utilisateur;
|
473 |
Utilisateur utilisateur;
|
467 |
if (connecteUtilisateur) {
|
474 |
if (connecteUtilisateur) {
|
468 |
String courrielUtilisateur = utilisateurJson.get("courriel").isString().stringValue();
|
475 |
String courrielUtilisateur = utilisateurJson.get("courriel").isString().stringValue();
|
469 |
String nomUtilisateur = utilisateurJson.get("nom").isString().stringValue();
|
476 |
String nomUtilisateur = utilisateurJson.get("nom").isString().stringValue();
|
470 |
String prenomUtilisateur = utilisateurJson.get("prenom").isString().stringValue();
|
477 |
String prenomUtilisateur = utilisateurJson.get("prenom").isString().stringValue();
|
471 |
String mdpHashUtilisateur = utilisateurJson.get("mot_de_passe").isString().stringValue();
|
478 |
String mdpHashUtilisateur = utilisateurJson.get("mot_de_passe").isString().stringValue();
|
472 |
|
479 |
|
473 |
String adminNiveau = "";
|
480 |
String adminNiveau = "";
|
474 |
if (utilisateurJson.get("admin").isString() != null) {
|
481 |
if (utilisateurJson.get("admin").isString() != null) {
|
475 |
adminNiveau = utilisateurJson.get("admin").isString().stringValue();
|
482 |
adminNiveau = utilisateurJson.get("admin").isString().stringValue();
|
476 |
}
|
483 |
}
|
477 |
|
484 |
|
478 |
utilisateur = new Utilisateur(sessionId, idUtilisateur, prenomUtilisateur, nomUtilisateur,
|
485 |
utilisateur = new Utilisateur(sessionId, idUtilisateur, prenomUtilisateur, nomUtilisateur,
|
479 |
courrielUtilisateur, mdpHashUtilisateur, adminNiveau);
|
486 |
courrielUtilisateur, mdpHashUtilisateur, adminNiveau);
|
480 |
} else {
|
487 |
} else {
|
481 |
utilisateur = new Utilisateur(sessionId, idUtilisateur);
|
488 |
utilisateur = new Utilisateur(sessionId, idUtilisateur);
|
482 |
}
|
489 |
}
|
483 |
return utilisateur;
|
490 |
return utilisateur;
|
484 |
}
|
491 |
}
|
485 |
|
492 |
|
486 |
/**
|
493 |
/**
|
487 |
* Recupere un utilisateur à partir du JSON
|
494 |
* Recupere un utilisateur à partir du JSON
|
488 |
*
|
495 |
*
|
489 |
* @param imageJson
|
496 |
* @param imageJson
|
490 |
* @return
|
497 |
* @return
|
491 |
*/
|
498 |
*/
|
492 |
public static HashMap<String, String> parserPreferencesUtilisateur(JSONValue valeurJson) {
|
499 |
public static HashMap<String, String> parserPreferencesUtilisateur(JSONValue valeurJson) {
|
493 |
|
500 |
|
494 |
JSONObject utilisateurJson = valeurJson.isObject();
|
501 |
JSONObject utilisateurJson = valeurJson.isObject();
|
495 |
HashMap<String, String> preferences = new HashMap<String, String>();
|
502 |
HashMap<String, String> preferences = new HashMap<String, String>();
|
496 |
JSONObject preferencesJson = utilisateurJson.get("preferences").isObject();
|
503 |
JSONObject preferencesJson = utilisateurJson.get("preferences").isObject();
|
497 |
|
504 |
|
498 |
java.util.Iterator<String> it = preferencesJson.keySet().iterator();
|
505 |
java.util.Iterator<String> it = preferencesJson.keySet().iterator();
|
499 |
while (it.hasNext()) {
|
506 |
while (it.hasNext()) {
|
500 |
String cle = it.next();
|
507 |
String cle = it.next();
|
501 |
preferences.put(cle, preferencesJson.get(cle).isString().stringValue());
|
508 |
preferences.put(cle, preferencesJson.get(cle).isString().stringValue());
|
502 |
}
|
509 |
}
|
503 |
return preferences;
|
510 |
return preferences;
|
504 |
}
|
511 |
}
|
505 |
|
512 |
|
506 |
/**
|
513 |
/**
|
507 |
* Retourne un objet {@link ProtocoleServiceResultat} à partir d'un objet
|
514 |
* Retourne un objet {@link ProtocoleServiceResultat} à partir d'un objet
|
508 |
* JSON
|
515 |
* JSON
|
509 |
*
|
516 |
*
|
510 |
* @param retourJson
|
517 |
* @param retourJson
|
511 |
* @return
|
518 |
* @return
|
512 |
*/
|
519 |
*/
|
513 |
public static ProtocoleServiceResultat parserProtocoleServiceResultat(JSONValue retourJson) {
|
520 |
public static ProtocoleServiceResultat parserProtocoleServiceResultat(JSONValue retourJson) {
|
514 |
List<Protocole> protocoles = new ArrayList<Protocole>();
|
521 |
List<Protocole> protocoles = new ArrayList<Protocole>();
|
515 |
JSONObject tableauProto = retourJson.isObject().get("resultats").isObject();
|
522 |
JSONObject tableauProto = retourJson.isObject().get("resultats").isObject();
|
516 |
|
523 |
|
517 |
if (tableauProto != null) {
|
524 |
if (tableauProto != null) {
|
518 |
java.util.Iterator<String> it = tableauProto.keySet().iterator();
|
525 |
java.util.Iterator<String> it = tableauProto.keySet().iterator();
|
519 |
while (it.hasNext()) {
|
526 |
while (it.hasNext()) {
|
520 |
|
527 |
|
521 |
JSONObject protocoleJSON = tableauProto.get(it.next()).isObject();
|
528 |
JSONObject protocoleJSON = tableauProto.get(it.next()).isObject();
|
522 |
Protocole protocole = new Protocole();
|
529 |
Protocole protocole = new Protocole();
|
523 |
String idProtocole = UtilitairesServiceResultat.getValeurOuVide(protocoleJSON, "protocole.id");
|
530 |
String idProtocole = UtilitairesServiceResultat.getValeurOuVide(protocoleJSON, "protocole.id");
|
524 |
protocole.setId(Integer.parseInt(idProtocole));
|
531 |
protocole.setId(Integer.parseInt(idProtocole));
|
525 |
protocole.setNom(UtilitairesServiceResultat.getValeurOuVide(protocoleJSON, "protocole.intitule"));
|
532 |
protocole.setNom(UtilitairesServiceResultat.getValeurOuVide(protocoleJSON, "protocole.intitule"));
|
526 |
protocole.setDescription(UtilitairesServiceResultat.getValeurOuVide(protocoleJSON, "protocole.descriptif"));
|
533 |
protocole.setDescription(UtilitairesServiceResultat.getValeurOuVide(protocoleJSON, "protocole.descriptif"));
|
527 |
protocole.setTag(UtilitairesServiceResultat.getValeurOuVide(protocoleJSON, "protocole.tag"));
|
534 |
protocole.setTag(UtilitairesServiceResultat.getValeurOuVide(protocoleJSON, "protocole.tag"));
|
528 |
protocole.setMotsClesProtocole(UtilitairesServiceResultat.getValeurOuVide(protocoleJSON, "protocole.mots_cles"));
|
535 |
protocole.setMotsClesProtocole(UtilitairesServiceResultat.getValeurOuVide(protocoleJSON, "protocole.mots_cles"));
|
529 |
protocoles.add(protocole);
|
536 |
protocoles.add(protocole);
|
530 |
}
|
537 |
}
|
531 |
}
|
538 |
}
|
532 |
|
539 |
|
533 |
return new ProtocoleServiceResultat(protocoles);
|
540 |
return new ProtocoleServiceResultat(protocoles);
|
534 |
}
|
541 |
}
|
535 |
|
542 |
|
536 |
/**
|
543 |
/**
|
537 |
* Retourne un objet {@link ImageServiceResultat} à partir du JSON
|
544 |
* Retourne un objet {@link ImageServiceResultat} à partir du JSON
|
538 |
*
|
545 |
*
|
539 |
* @param retourJson
|
546 |
* @param retourJson
|
540 |
* @return
|
547 |
* @return
|
541 |
*/
|
548 |
*/
|
542 |
public static ImageServiceResultat parserImageServiceResultat(JSONValue retourJson) {
|
549 |
public static ImageServiceResultat parserImageServiceResultat(JSONValue retourJson) {
|
543 |
|
550 |
|
544 |
ImageServiceResultat imageServiceResultat = new ImageServiceResultat();
|
551 |
ImageServiceResultat imageServiceResultat = new ImageServiceResultat();
|
545 |
int nbTotalImagesPourLaRecherche;
|
552 |
int nbTotalImagesPourLaRecherche;
|
546 |
|
553 |
|
547 |
List<Image> images = new ArrayList<Image>();
|
554 |
List<Image> images = new ArrayList<Image>();
|
548 |
// TODO ajouter vérifications plus précises
|
555 |
// TODO ajouter vérifications plus précises
|
549 |
if (retourJson.isObject().get("entete") != null) {
|
556 |
if (retourJson.isObject().get("entete") != null) {
|
550 |
double total = retourJson.isObject().get("entete").isObject().get("total").isNumber().doubleValue();
|
557 |
double total = retourJson.isObject().get("entete").isObject().get("total").isNumber().doubleValue();
|
551 |
nbTotalImagesPourLaRecherche = (int) total;
|
558 |
nbTotalImagesPourLaRecherche = (int) total;
|
552 |
// ATTENTION : "resultats" devrait contenir un array car il garantit l'ordre ce qui est important pour
|
559 |
// ATTENTION : "resultats" devrait contenir un array car il garantit l'ordre ce qui est important pour
|
553 |
// résultat de recherche. Migration progressive des ws pour qu'ils retourne un array et non un objet.
|
560 |
// résultat de recherche. Migration progressive des ws pour qu'ils retourne un array et non un objet.
|
554 |
if (retourJson.isObject().get("resultats").isObject() != null) {
|
561 |
if (retourJson.isObject().get("resultats").isObject() != null) {
|
555 |
// TODO : supprimer cette condition quand tous les ws seront migrés vers array.
|
562 |
// TODO : supprimer cette condition quand tous les ws seront migrés vers array.
|
556 |
JSONObject tableauImg = retourJson.isObject().get("resultats").isObject();
|
563 |
JSONObject tableauImg = retourJson.isObject().get("resultats").isObject();
|
557 |
if (tableauImg != null) {
|
564 |
if (tableauImg != null) {
|
558 |
java.util.Iterator<String> it = tableauImg.keySet().iterator();
|
565 |
java.util.Iterator<String> it = tableauImg.keySet().iterator();
|
559 |
while (it.hasNext()) {
|
566 |
while (it.hasNext()) {
|
560 |
JSONObject imageJson = tableauImg.get(it.next()).isObject();
|
567 |
JSONObject imageJson = tableauImg.get(it.next()).isObject();
|
561 |
Image image = parserRetourImage(imageJson);
|
568 |
Image image = parserRetourImage(imageJson);
|
562 |
images.add(image);
|
569 |
images.add(image);
|
563 |
}
|
570 |
}
|
564 |
}
|
571 |
}
|
565 |
} else if (retourJson.isObject().get("resultats").isArray() != null) {
|
572 |
} else if (retourJson.isObject().get("resultats").isArray() != null) {
|
566 |
JSONArray tableauImg = retourJson.isObject().get("resultats").isArray();
|
573 |
JSONArray tableauImg = retourJson.isObject().get("resultats").isArray();
|
567 |
if (tableauImg != null) {
|
574 |
if (tableauImg != null) {
|
568 |
int nbInfosImagesRetournees = (int) tableauImg.size();
|
575 |
int nbInfosImagesRetournees = (int) tableauImg.size();
|
569 |
for (int i = 0; i < nbInfosImagesRetournees; i++) {
|
576 |
for (int i = 0; i < nbInfosImagesRetournees; i++) {
|
570 |
JSONObject imageJson = tableauImg.get(i).isObject();
|
577 |
JSONObject imageJson = tableauImg.get(i).isObject();
|
571 |
Image image = parserRetourImage(imageJson);
|
578 |
Image image = parserRetourImage(imageJson);
|
572 |
images.add(image);
|
579 |
images.add(image);
|
573 |
}
|
580 |
}
|
574 |
}
|
581 |
}
|
575 |
}
|
582 |
}
|
576 |
} else {
|
583 |
} else {
|
577 |
JSONArray tableauImg = retourJson.isObject().get("images").isArray();
|
584 |
JSONArray tableauImg = retourJson.isObject().get("images").isArray();
|
578 |
nbTotalImagesPourLaRecherche = (int) tableauImg.size();
|
585 |
nbTotalImagesPourLaRecherche = (int) tableauImg.size();
|
579 |
for (int i = 0; i < nbTotalImagesPourLaRecherche; i++) {
|
586 |
for (int i = 0; i < nbTotalImagesPourLaRecherche; i++) {
|
580 |
JSONObject imageJson = tableauImg.get(i).isObject();
|
587 |
JSONObject imageJson = tableauImg.get(i).isObject();
|
581 |
Image image = parserRetourImage(imageJson);
|
588 |
Image image = parserRetourImage(imageJson);
|
582 |
images.add(image);
|
589 |
images.add(image);
|
583 |
}
|
590 |
}
|
584 |
}
|
591 |
}
|
585 |
|
592 |
|
586 |
imageServiceResultat.setImages(images);
|
593 |
imageServiceResultat.setImages(images);
|
587 |
imageServiceResultat.setNbTotalImagesPourLaRecherche(nbTotalImagesPourLaRecherche);
|
594 |
imageServiceResultat.setNbTotalImagesPourLaRecherche(nbTotalImagesPourLaRecherche);
|
588 |
|
595 |
|
589 |
return imageServiceResultat;
|
596 |
return imageServiceResultat;
|
590 |
|
597 |
|
591 |
}
|
598 |
}
|
592 |
|
599 |
|
593 |
/**
|
600 |
/**
|
594 |
* Retourne un objet {@link Image} à partir du JSON
|
601 |
* Retourne un objet {@link Image} à partir du JSON
|
595 |
*
|
602 |
*
|
596 |
* @param retourJson
|
603 |
* @param retourJson
|
597 |
* @return
|
604 |
* @return
|
598 |
*/
|
605 |
*/
|
599 |
public static Image parserRetourImage(JSONObject imageJson) {
|
606 |
public static Image parserRetourImage(JSONObject imageJson) {
|
600 |
Image image = UtilitairesServiceResultat.parserImageJSON(imageJson);
|
607 |
Image image = UtilitairesServiceResultat.parserImageJSON(imageJson);
|
601 |
|
608 |
|
602 |
if (imageJson.get("observation") != null && imageJson.get("observation").isObject() != null) {
|
609 |
if (imageJson.get("observation") != null && imageJson.get("observation").isObject() != null) {
|
603 |
JSONObject observationJson = imageJson.get("observation").isObject();
|
610 |
JSONObject observationJson = imageJson.get("observation").isObject();
|
604 |
image.setObservation(UtilitairesServiceResultat.parserObservationJSON(observationJson));
|
611 |
image.setObservation(UtilitairesServiceResultat.parserObservationJSON(observationJson));
|
605 |
}
|
612 |
}
|
606 |
|
613 |
|
607 |
if (imageJson.get("protocoles_votes") != null && imageJson.get("protocoles_votes").isObject() != null) {
|
614 |
if (imageJson.get("protocoles_votes") != null && imageJson.get("protocoles_votes").isObject() != null) {
|
608 |
JSONObject votes = imageJson.get("protocoles_votes").isObject();
|
615 |
JSONObject votes = imageJson.get("protocoles_votes").isObject();
|
609 |
image.setVoteProtocoles(UtilitairesServiceResultat.parserVotesProtocoles(votes));
|
616 |
image.setVoteProtocoles(UtilitairesServiceResultat.parserVotesProtocoles(votes));
|
610 |
}
|
617 |
}
|
611 |
|
618 |
|
612 |
return image;
|
619 |
return image;
|
613 |
}
|
620 |
}
|
614 |
|
621 |
|
615 |
/**
|
622 |
/**
|
616 |
* Retourne un objet {@link ObservationServiceResultat} à partir du JSON
|
623 |
* Retourne un objet {@link ObservationServiceResultat} à partir du JSON
|
617 |
*
|
624 |
*
|
618 |
* @param retourJson
|
625 |
* @param retourJson
|
619 |
* @return
|
626 |
* @return
|
620 |
*/
|
627 |
*/
|
621 |
public static ObservationServiceResultat parserObservationServiceResultat(JSONValue retourJson) {
|
628 |
public static ObservationServiceResultat parserObservationServiceResultat(JSONValue retourJson) {
|
622 |
|
629 |
|
623 |
ObservationServiceResultat observationServiceResultat = new ObservationServiceResultat();
|
630 |
ObservationServiceResultat observationServiceResultat = new ObservationServiceResultat();
|
624 |
|
631 |
|
625 |
List<Observation> observations = new ArrayList<Observation>();
|
632 |
List<Observation> observations = new ArrayList<Observation>();
|
626 |
int nbTotalObservationsPourLaRecherche = 0;
|
633 |
int nbTotalObservationsPourLaRecherche = 0;
|
627 |
|
634 |
|
628 |
if (retourJson.isObject().get("entete") != null) {
|
635 |
if (retourJson.isObject().get("entete") != null) {
|
629 |
// TODO ajouter vérifications plus précises
|
636 |
// TODO ajouter vérifications plus précises
|
630 |
double total = retourJson.isObject().get("entete").isObject().get("total").isNumber().doubleValue();
|
637 |
double total = retourJson.isObject().get("entete").isObject().get("total").isNumber().doubleValue();
|
631 |
nbTotalObservationsPourLaRecherche = (int) total;
|
638 |
nbTotalObservationsPourLaRecherche = (int) total;
|
632 |
JSONArray tableauObs = retourJson.isObject().get("resultats").isArray();
|
639 |
JSONArray tableauObs = retourJson.isObject().get("resultats").isArray();
|
633 |
|
640 |
|
634 |
if (tableauObs != null) {
|
641 |
if (tableauObs != null) {
|
635 |
for(int i = 0; i < tableauObs.size(); i++) {
|
642 |
for(int i = 0; i < tableauObs.size(); i++) {
|
636 |
JSONObject observationJson = tableauObs.get(i).isObject();
|
643 |
JSONObject observationJson = tableauObs.get(i).isObject();
|
637 |
Observation observation = analyserObservation(observationJson);
|
644 |
Observation observation = analyserObservation(observationJson);
|
638 |
observations.add(observation);
|
645 |
observations.add(observation);
|
639 |
}
|
646 |
}
|
640 |
}
|
647 |
}
|
641 |
} else {
|
648 |
} else {
|
642 |
JSONObject observationJson = retourJson.isObject();
|
649 |
JSONObject observationJson = retourJson.isObject();
|
643 |
Observation observation = analyserObservation(observationJson);
|
650 |
Observation observation = analyserObservation(observationJson);
|
644 |
observations.add(observation);
|
651 |
observations.add(observation);
|
645 |
CacheClient.getInstance().setObservationCourante(observation);
|
652 |
CacheClient.getInstance().setObservationCourante(observation);
|
646 |
}
|
653 |
}
|
647 |
|
654 |
|
648 |
observationServiceResultat.setObservations(observations);
|
655 |
observationServiceResultat.setObservations(observations);
|
649 |
observationServiceResultat.setNbTotalObservationsPourLaRecherche(nbTotalObservationsPourLaRecherche);
|
656 |
observationServiceResultat.setNbTotalObservationsPourLaRecherche(nbTotalObservationsPourLaRecherche);
|
650 |
|
657 |
|
651 |
return observationServiceResultat;
|
658 |
return observationServiceResultat;
|
652 |
}
|
659 |
}
|
653 |
|
660 |
|
654 |
/**
|
661 |
/**
|
655 |
* Retourne un objet {@link Observation} avec ses {@link Image} associées à
|
662 |
* Retourne un objet {@link Observation} avec ses {@link Image} associées à
|
656 |
* partir du JSON
|
663 |
* partir du JSON
|
657 |
*
|
664 |
*
|
658 |
* @param retourJson
|
665 |
* @param retourJson
|
659 |
* @return
|
666 |
* @return
|
660 |
*/
|
667 |
*/
|
661 |
private static Observation analyserObservation(JSONObject observationJson) {
|
668 |
private static Observation analyserObservation(JSONObject observationJson) {
|
662 |
Observation observation = UtilitairesServiceResultat.parserObservationJSON(observationJson);
|
669 |
Observation observation = UtilitairesServiceResultat.parserObservationJSON(observationJson);
|
663 |
JSONArray tableauImagesObs = observationJson.get("images").isArray();
|
670 |
JSONArray tableauImagesObs = observationJson.get("images").isArray();
|
664 |
List<Image> imagesPourObs = new ArrayList<Image>();
|
671 |
List<Image> imagesPourObs = new ArrayList<Image>();
|
665 |
|
672 |
|
666 |
int nbImages = tableauImagesObs.size();
|
673 |
int nbImages = tableauImagesObs.size();
|
667 |
for (int j = 0; j < nbImages; j++) {
|
674 |
for (int j = 0; j < nbImages; j++) {
|
668 |
JSONObject imageJson = tableauImagesObs.get(j).isObject();
|
675 |
JSONObject imageJson = tableauImagesObs.get(j).isObject();
|
669 |
|
676 |
|
670 |
Image image = UtilitairesServiceResultat.parserImageJSON(imageJson);
|
677 |
Image image = UtilitairesServiceResultat.parserImageJSON(imageJson);
|
671 |
if (imageJson.get("protocoles_votes") != null && imageJson.get("protocoles_votes").isObject() != null) {
|
678 |
if (imageJson.get("protocoles_votes") != null && imageJson.get("protocoles_votes").isObject() != null) {
|
672 |
JSONObject votes = imageJson.get("protocoles_votes").isObject();
|
679 |
JSONObject votes = imageJson.get("protocoles_votes").isObject();
|
673 |
image.setVoteProtocoles(UtilitairesServiceResultat.parserVotesProtocoles(votes));
|
680 |
image.setVoteProtocoles(UtilitairesServiceResultat.parserVotesProtocoles(votes));
|
674 |
}
|
681 |
}
|
675 |
image.setObservation(observation);
|
682 |
image.setObservation(observation);
|
676 |
imagesPourObs.add(image);
|
683 |
imagesPourObs.add(image);
|
677 |
}
|
684 |
}
|
678 |
|
685 |
|
679 |
observation.setImages(imagesPourObs);
|
686 |
observation.setImages(imagesPourObs);
|
680 |
|
687 |
|
681 |
return observation;
|
688 |
return observation;
|
682 |
}
|
689 |
}
|
683 |
|
690 |
|
684 |
public static List<MotCle> parserRetourListeMotsClesImage(JSONObject retourJson) {
|
691 |
public static List<MotCle> parserRetourListeMotsClesImage(JSONObject retourJson) {
|
685 |
List<MotCle> motsCles = new ArrayList<MotCle>();
|
692 |
List<MotCle> motsCles = new ArrayList<MotCle>();
|
686 |
JSONObject tableauMc = retourJson;
|
693 |
JSONObject tableauMc = retourJson;
|
687 |
if (tableauMc != null) {
|
694 |
if (tableauMc != null) {
|
688 |
java.util.Iterator<String> it = tableauMc.keySet().iterator();
|
695 |
java.util.Iterator<String> it = tableauMc.keySet().iterator();
|
689 |
while (it.hasNext()) {
|
696 |
while (it.hasNext()) {
|
690 |
JSONObject mc = tableauMc.get(it.next()).isObject();
|
697 |
JSONObject mc = tableauMc.get(it.next()).isObject();
|
691 |
MotCle motCle = new MotCle(getValeurOuVide(mc, "id_mot_cle"), getValeurOuVide(mc, "image"), getValeurOuVide(mc, "mot_cle"));
|
698 |
MotCle motCle = new MotCle(getValeurOuVide(mc, "id_mot_cle"), getValeurOuVide(mc, "image"), getValeurOuVide(mc, "mot_cle"));
|
692 |
motsCles.add(motCle);
|
699 |
motsCles.add(motCle);
|
693 |
}
|
700 |
}
|
694 |
}
|
701 |
}
|
695 |
return motsCles;
|
702 |
return motsCles;
|
696 |
}
|
703 |
}
|
697 |
|
704 |
|
698 |
public static String parserRetourAjoutVoteProtocole(JSONObject retour) {
|
705 |
public static String parserRetourAjoutVoteProtocole(JSONObject retour) {
|
699 |
String id = "";
|
706 |
String id = "";
|
700 |
if (retour != null) {
|
707 |
if (retour != null) {
|
701 |
id = getValeurOuVide(retour, "id_vote");
|
708 |
id = getValeurOuVide(retour, "id_vote");
|
702 |
}
|
709 |
}
|
703 |
return id;
|
710 |
return id;
|
704 |
}
|
711 |
}
|
705 |
}
|
712 |
}
|