Line 63... |
Line 63... |
63 |
// observation.setMotsClefs(parserMotsCles(UtilitairesServiceResultat.getValeurOuVide(observationJson,
|
63 |
// observation.setMotsClefs(parserMotsCles(UtilitairesServiceResultat.getValeurOuVide(observationJson,
|
64 |
// "mots_cles_texte")));
|
64 |
// "mots_cles_texte")));
|
65 |
JSONValue propositions = observationJson.get("commentaires");
|
65 |
JSONValue propositions = observationJson.get("commentaires");
|
Line 66... |
Line 66... |
66 |
|
66 |
|
67 |
if (propositions != null && propositions.isObject() != null) {
|
67 |
if (propositions != null && propositions.isObject() != null) {
|
- |
|
68 |
List<InterventionForum> interventions = parserInterventions(propositions.isObject());
|
- |
|
69 |
for (InterventionForum interventionForum : interventions) {
|
- |
|
70 |
interventionForum.setObservation(observation);
|
68 |
List<InterventionForum> interventions = parserInterventions(propositions.isObject(), observation);
|
71 |
}
|
69 |
observation.setInterventionsForum(interventions);
|
72 |
observation.setInterventionsForum(interventions);
|
70 |
} else {
|
73 |
} else {
|
71 |
observation.ajouterPropositionDetermination(creerPropositionDeterminationAPartirObservation(observation));
|
74 |
observation.ajouterPropositionDetermination(creerPropositionDeterminationAPartirObservation(observation));
|
72 |
}
|
75 |
}
|
73 |
return observation;
|
76 |
return observation;
|
Line 74... |
Line 77... |
74 |
}
|
77 |
}
|
75 |
|
78 |
|
76 |
public static List<Commentaire> parserCommentaires(JSONObject commentaires, Observation observation) {
|
79 |
public static List<Commentaire> parserCommentaires(JSONObject commentaires) {
|
77 |
List<InterventionForum> interventionForums = parserInterventions(commentaires, observation);
|
80 |
List<InterventionForum> interventionForums = parserInterventions(commentaires);
|
78 |
List<Commentaire> commentairesListe = new ArrayList<Commentaire>();
|
81 |
List<Commentaire> commentairesListe = new ArrayList<Commentaire>();
|
79 |
for (InterventionForum interventionForum : interventionForums) {
|
82 |
for (InterventionForum interventionForum : interventionForums) {
|
80 |
if (interventionForum instanceof Commentaire) {
|
83 |
if (interventionForum instanceof Commentaire) {
|
81 |
commentairesListe.add((Commentaire) interventionForum);
|
84 |
commentairesListe.add((Commentaire) interventionForum);
|
82 |
}
|
85 |
}
|
Line 83... |
Line 86... |
83 |
}
|
86 |
}
|
Line 84... |
Line 87... |
84 |
return commentairesListe;
|
87 |
return commentairesListe;
|
85 |
|
88 |
|
Line 86... |
Line 89... |
86 |
}
|
89 |
}
|
87 |
|
90 |
|
88 |
public static List<InterventionForum> parserInterventions(JSONObject interventions, Observation observation) {
|
91 |
public static List<InterventionForum> parserInterventions(JSONObject interventions) {
|
89 |
HashMap<String, InterventionForum> interventionsNonTypees = new HashMap<String, InterventionForum>();
|
92 |
HashMap<String, InterventionForum> interventionsNonTypees = new HashMap<String, InterventionForum>();
|
90 |
|
93 |
|
91 |
List<InterventionForum> retour = new ArrayList<InterventionForum>();
|
94 |
List<InterventionForum> retour = new ArrayList<InterventionForum>();
|
92 |
|
95 |
|
93 |
// parcourir les interventions et en faire un tableau
|
96 |
// parcourir les interventions et en faire un tableau
|
94 |
if(interventions==null){
|
97 |
if (interventions == null) {
|
Line 121... |
Line 124... |
121 |
String nom_referentiel = getValeurOuVide(jsonIntervention, "nom_referentiel");
|
124 |
String nom_referentiel = getValeurOuVide(jsonIntervention, "nom_referentiel");
|
Line 122... |
Line 125... |
122 |
|
125 |
|
Line 123... |
Line 126... |
123 |
String nbCommentaires = getValeurOuVide(jsonIntervention, "nb_commentaires");
|
126 |
String nbCommentaires = getValeurOuVide(jsonIntervention, "nb_commentaires");
|
124 |
|
127 |
|
125 |
PropositionDetermination intervention = new PropositionDetermination(id, contributeur, texte);
|
128 |
PropositionDetermination intervention = new PropositionDetermination(id, contributeur, texte);
|
Line 126... |
Line 129... |
126 |
intervention.setObservation(observation);
|
129 |
// intervention.setObservation(observation);
|
127 |
intervention.setEspece(nom_sel);
|
130 |
intervention.setEspece(nom_sel);
|
128 |
|
131 |
|
129 |
if (!nbCommentaires.equals("")) {
|
132 |
if (!nbCommentaires.equals("")) {
|
130 |
int nbComm = Integer.parseInt(nbCommentaires);
|
133 |
int nbComm = Integer.parseInt(nbCommentaires);
|
131 |
if(!texte.equals("")) {
|
134 |
if (!texte.equals("")) {
|
132 |
nbComm++;
|
135 |
nbComm++;
|
Line 133... |
Line 136... |
133 |
}
|
136 |
}
|
134 |
intervention.setNbCommentaires(nbComm);
|
137 |
intervention.setNbCommentaires(nbComm);
|
135 |
}
|
138 |
}
|
Line 136... |
Line 139... |
136 |
|
139 |
|
137 |
if (!idParent.equals("")) {
|
140 |
if (!idParent.equals("")) {
|
138 |
intervention.setIdParent(idParent);
|
141 |
intervention.setIdParent(idParent);
|
Line 139... |
Line 142... |
139 |
}
|
142 |
}
|
140 |
|
143 |
|
Line 165... |
Line 168... |
165 |
InterventionForum parent = interventionsNonTypees.get(idParent);
|
168 |
InterventionForum parent = interventionsNonTypees.get(idParent);
|
166 |
intervention.setParent(parent);
|
169 |
intervention.setParent(parent);
|
167 |
}
|
170 |
}
|
168 |
}
|
171 |
}
|
Line 169... |
Line -... |
169 |
|
- |
|
170 |
|
172 |
|
171 |
retour.addAll(interventionsNonTypees.values());
|
173 |
retour.addAll(interventionsNonTypees.values());
|
172 |
return retour;
|
174 |
return retour;
|
173 |
}
|
175 |
}
|
174 |
|
176 |
|
175 |
public static String convertirEtParserRetourAjoutCommentaire(String retour) {
|
177 |
public static String convertirEtParserRetourAjoutCommentaire(String retour) {
|
176 |
JSONObject retourJson = JSONParser.parseStrict(retour).isObject();
|
178 |
JSONObject retourJson = JSONParser.parseStrict(retour).isObject();
|
177 |
return parserRetourAjoutCommentaire(retourJson);
|
179 |
return parserRetourAjoutCommentaire(retourJson);
|
Line 203... |
Line 205... |
203 |
propositionDetermination.setEspece(observation.getNomRetenu());
|
205 |
propositionDetermination.setEspece(observation.getNomRetenu());
|
Line 204... |
Line 206... |
204 |
|
206 |
|
205 |
return propositionDetermination;
|
207 |
return propositionDetermination;
|
Line 206... |
Line 208... |
206 |
}
|
208 |
}
|
Line 207... |
Line 209... |
207 |
|
209 |
|
Line 208... |
Line 210... |
208 |
public static HashMap<String, VoteDetermination> parserRetourListeVotesDetermination(String votesString, PropositionDetermination proposition) {
|
210 |
public static HashMap<String, VoteDetermination> parserRetourListeVotesDetermination(String votesString) {
|
209 |
|
211 |
|
210 |
HashMap<String, VoteDetermination> retour = null;
|
212 |
HashMap<String, VoteDetermination> retour = null;
|
211 |
|
213 |
|
212 |
JSONObject votes = JSONParser.parseStrict(votesString).isObject();
|
214 |
JSONObject votes = JSONParser.parseStrict(votesString).isObject();
|
213 |
if (votes != null && votes.get("resultats") != null && votes.get("resultats").isObject() != null) {
|
215 |
if (votes != null && votes.get("resultats") != null && votes.get("resultats").isObject() != null) {
|
214 |
JSONObject resultat = votes.get("resultats").isObject();
|
216 |
JSONObject resultat = votes.get("resultats").isObject();
|
Line 215... |
Line 217... |
215 |
retour = parserVotesDetermination(resultat, proposition);
|
217 |
retour = parserVotesDetermination(resultat);
|
216 |
}
|
218 |
}
|
217 |
return retour;
|
219 |
return retour;
|
218 |
}
|
220 |
}
|
219 |
|
221 |
|
220 |
public static HashMap<String, VoteDetermination> parserVotesDetermination(JSONObject votes, PropositionDetermination proposition) {
|
222 |
public static HashMap<String, VoteDetermination> parserVotesDetermination(JSONObject votes) {
|
221 |
HashMap<String, VoteDetermination> votesDetermination = new HashMap<String, VoteDetermination>();
|
223 |
HashMap<String, VoteDetermination> votesDetermination = new HashMap<String, VoteDetermination>();
|
222 |
java.util.Iterator<String> itVotes = votes.keySet().iterator();
|
224 |
java.util.Iterator<String> itVotes = votes.keySet().iterator();
|
223 |
while (itVotes.hasNext()) {
|
225 |
while (itVotes.hasNext()) {
|
224 |
JSONObject vote = votes.get(itVotes.next()).isObject();
|
- |
|
225 |
VoteDetermination vd = new VoteDetermination();
|
226 |
JSONObject vote = votes.get(itVotes.next()).isObject();
|
226 |
vd.setContributeur(getValeurOuVide(vote, "auteur.id"));
|
227 |
VoteDetermination vd = new VoteDetermination();
|
Line 227... |
Line 228... |
227 |
vd.setDate(new Date());
|
228 |
vd.setContributeur(getValeurOuVide(vote, "auteur.id"));
|
228 |
vd.setId(getValeurOuVide(vote, "vote.id"));
|
229 |
vd.setDate(new Date());
|