Line 41... |
Line 41... |
41 |
}
|
41 |
}
|
Line 42... |
Line 42... |
42 |
|
42 |
|
Line 43... |
Line 43... |
43 |
public static Observation parserObservationJSON(JSONObject observationJson) {
|
43 |
public static Observation parserObservationJSON(JSONObject observationJson) {
|
44 |
|
44 |
|
45 |
Observation observation = new Observation();
|
- |
|
46 |
observation.setAuteur(getValeurOuVide(observationJson, "auteur.prenom")+
|
45 |
Observation observation = new Observation();
|
47 |
" "+getValeurOuVide(observationJson,"auteur.nom"));
|
46 |
observation.setAuteur(getValeurOuVide(observationJson, "auteur.prenom") + " " + getValeurOuVide(observationJson, "auteur.nom"));
|
48 |
observation.setNomAuteur(getValeurOuVide(observationJson,"auteur.nom"));
|
47 |
observation.setNomAuteur(getValeurOuVide(observationJson, "auteur.nom"));
|
49 |
observation.setPrenomAuteur(getValeurOuVide(observationJson,"auteur.nom"));
|
48 |
observation.setPrenomAuteur(getValeurOuVide(observationJson, "auteur.nom"));
|
50 |
observation.setIdAuteur(getValeurOuVide(observationJson,"auteur.id"));
|
49 |
observation.setIdAuteur(getValeurOuVide(observationJson, "auteur.id"));
|
Line 59... |
Line 58... |
59 |
observation.setNomRetenu(getValeurOuVide(observationJson, "determination.ns"));
|
58 |
observation.setNomRetenu(getValeurOuVide(observationJson, "determination.ns"));
|
60 |
observation.setMilieu(getValeurOuVide(observationJson, "milieu"));
|
59 |
observation.setMilieu(getValeurOuVide(observationJson, "milieu"));
|
61 |
observation.setLieuDit(getValeurOuVide(observationJson, "lieudit"));
|
60 |
observation.setLieuDit(getValeurOuVide(observationJson, "lieudit"));
|
62 |
observation.setNumNomenclatural(getValeurOuVide(observationJson, "determination.nn"));
|
61 |
observation.setNumNomenclatural(getValeurOuVide(observationJson, "determination.nn"));
|
63 |
//TODO: renvoyer les mots clés des observations
|
62 |
// TODO: renvoyer les mots clés des observations
|
64 |
//observation.setMotsClefs(parserMotsCles(UtilitairesServiceResultat.getValeurOuVide(observationJson, "mots_cles_texte")));
|
63 |
// observation.setMotsClefs(parserMotsCles(UtilitairesServiceResultat.getValeurOuVide(observationJson,
|
- |
|
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(), observation);
|
68 |
List<InterventionForum> interventions = parserInterventions(propositions.isObject(), observation);
|
Line 71... |
Line 71... |
71 |
observation.ajouterPropositionDetermination(creerPropositionDeterminationAPartirObservation(observation));
|
71 |
observation.ajouterPropositionDetermination(creerPropositionDeterminationAPartirObservation(observation));
|
72 |
}
|
72 |
}
|
73 |
return observation;
|
73 |
return observation;
|
74 |
}
|
74 |
}
|
Line -... |
Line 75... |
- |
|
75 |
|
- |
|
76 |
public static List<Commentaire> parserCommentaires(JSONObject commentaires, Observation observation) {
|
- |
|
77 |
List<InterventionForum> interventionForums = parserInterventions(commentaires, observation);
|
- |
|
78 |
List<Commentaire> commentairesListe = new ArrayList<Commentaire>();
|
- |
|
79 |
for (InterventionForum interventionForum : interventionForums) {
|
- |
|
80 |
if (interventionForum instanceof Commentaire) {
|
- |
|
81 |
commentairesListe.add((Commentaire) interventionForum);
|
- |
|
82 |
}
|
- |
|
83 |
}
|
- |
|
84 |
return commentairesListe;
|
- |
|
85 |
|
- |
|
86 |
}
|
75 |
|
87 |
|
76 |
public static List<InterventionForum> parserInterventions(JSONObject interventions, Observation observation) {
|
88 |
public static List<InterventionForum> parserInterventions(JSONObject interventions, Observation observation) {
|
Line -... |
Line 89... |
- |
|
89 |
HashMap<String, InterventionForum> interventionsNonTypees = new HashMap<String, InterventionForum>();
|
- |
|
90 |
|
77 |
HashMap<String, InterventionForum> interventionsNonTypees = new HashMap<String, InterventionForum>();
|
91 |
List<InterventionForum> retour = new ArrayList<InterventionForum>();
|
- |
|
92 |
|
- |
|
93 |
// parcourir les interventions et en faire un tableau
|
- |
|
94 |
if(interventions==null){
|
78 |
|
95 |
return retour;
|
79 |
//parcourir les interventions et en faire un tableau
|
96 |
}
|
80 |
Iterator<String> itInterventions = interventions.keySet().iterator();
|
97 |
Iterator<String> itInterventions = interventions.keySet().iterator();
|
81 |
while (itInterventions.hasNext()) {
|
98 |
while (itInterventions.hasNext()) {
|
Line 122... |
Line 139... |
122 |
}
|
139 |
}
|
Line 123... |
Line 140... |
123 |
|
140 |
|
124 |
intervention.setDate(date);
|
141 |
intervention.setDate(date);
|
Line 125... |
Line -... |
125 |
interventionsNonTypees.put(intervention.getId(), intervention);
|
- |
|
126 |
|
142 |
interventionsNonTypees.put(intervention.getId(), intervention);
|
127 |
|
143 |
|
128 |
} else {
|
144 |
} else {
|
129 |
Commentaire intervention = new Commentaire(contributeur, date, texte);
|
145 |
Commentaire intervention = new Commentaire(contributeur, date, texte);
|
130 |
intervention.setId(id);
|
146 |
intervention.setId(id);
|
Line 145... |
Line 161... |
145 |
InterventionForum parent = interventionsNonTypees.get(idParent);
|
161 |
InterventionForum parent = interventionsNonTypees.get(idParent);
|
146 |
intervention.setParent(parent);
|
162 |
intervention.setParent(parent);
|
147 |
}
|
163 |
}
|
148 |
}
|
164 |
}
|
Line 149... |
Line -... |
149 |
|
- |
|
- |
|
165 |
|
150 |
List<InterventionForum> retour = new ArrayList<InterventionForum>();
|
166 |
|
151 |
retour.addAll(interventionsNonTypees.values());
|
167 |
retour.addAll(interventionsNonTypees.values());
|
152 |
return retour;
|
168 |
return retour;
|
Line 153... |
Line 169... |
153 |
}
|
169 |
}
|
Line 203... |
Line 219... |
203 |
vd.setId(getValeurOuVide(vote, "vote.id"));
|
219 |
vd.setId(getValeurOuVide(vote, "vote.id"));
|
204 |
vd.setPropositionDetermination(proposition);
|
220 |
vd.setPropositionDetermination(proposition);
|
205 |
vd.setVote(Integer.parseInt(getValeurOuVide(vote, "vote")));
|
221 |
vd.setVote(Integer.parseInt(getValeurOuVide(vote, "vote")));
|
206 |
vd.setContributeur(getValeurOuVide(vote, "auteur.id"));
|
222 |
vd.setContributeur(getValeurOuVide(vote, "auteur.id"));
|
Line 207... |
Line -... |
207 |
|
- |
|
208 |
if(vote.get("auteur.nom") != null &&
|
- |
|
209 |
vote.get("auteur.nom") != null &&
|
223 |
|
210 |
vote.get("auteur.courriel") != null) {
|
224 |
if (vote.get("auteur.nom") != null && vote.get("auteur.nom") != null && vote.get("auteur.courriel") != null) {
|
211 |
Contributeur auteur = new Contributeur(getValeurOuVide(vote, "auteur.id"),
|
- |
|
212 |
getValeurOuVide(vote, "auteur.nom"),
|
- |
|
213 |
getValeurOuVide(vote, "auteur.prenom"),
|
- |
|
214 |
getValeurOuVide(vote, "auteur.courriel"));
|
225 |
Contributeur auteur = new Contributeur(getValeurOuVide(vote, "auteur.id"), getValeurOuVide(vote, "auteur.nom"), getValeurOuVide(vote, "auteur.prenom"), getValeurOuVide(vote, "auteur.courriel"));
|
215 |
vd.setAuteur(auteur);
|
226 |
vd.setAuteur(auteur);
|
Line 216... |
Line 227... |
216 |
}
|
227 |
}
|
217 |
|
228 |
|