43,7 → 43,8 |
public static Observation parserObservationJSON(JSONObject observationJson) { |
|
Observation observation = new Observation(); |
observation.setAuteur(getValeurOuVide(observationJson, "auteur.prenom") + " " + getValeurOuVide(observationJson, "auteur.nom")); |
observation.setAuteur(getValeurOuVide(observationJson, "auteur.prenom")+ |
" "+getValeurOuVide(observationJson,"auteur.nom")); |
observation.setNomAuteur(getValeurOuVide(observationJson, "auteur.nom")); |
observation.setPrenomAuteur(getValeurOuVide(observationJson, "auteur.nom")); |
observation.setIdAuteur(getValeurOuVide(observationJson, "auteur.id")); |
60,8 → 61,7 |
observation.setLieuDit(getValeurOuVide(observationJson, "lieudit")); |
observation.setNumNomenclatural(getValeurOuVide(observationJson, "determination.nn")); |
// TODO: renvoyer les mots clés des observations |
// observation.setMotsClefs(parserMotsCles(UtilitairesServiceResultat.getValeurOuVide(observationJson, |
// "mots_cles_texte"))); |
//observation.setMotsClefs(parserMotsCles(UtilitairesServiceResultat.getValeurOuVide(observationJson, "mots_cles_texte"))); |
JSONValue propositions = observationJson.get("commentaires"); |
|
if (propositions != null && propositions.isObject() != null) { |
73,27 → 73,10 |
return observation; |
} |
|
public static List<Commentaire> parserCommentaires(JSONObject commentaires, Observation observation) { |
List<InterventionForum> interventionForums = parserInterventions(commentaires, observation); |
List<Commentaire> commentairesListe = new ArrayList<Commentaire>(); |
for (InterventionForum interventionForum : interventionForums) { |
if (interventionForum instanceof Commentaire) { |
commentairesListe.add((Commentaire) interventionForum); |
} |
} |
return commentairesListe; |
|
} |
|
public static List<InterventionForum> parserInterventions(JSONObject interventions, Observation observation) { |
HashMap<String, InterventionForum> interventionsNonTypees = new HashMap<String, InterventionForum>(); |
|
List<InterventionForum> retour = new ArrayList<InterventionForum>(); |
|
// parcourir les interventions et en faire un tableau |
if(interventions==null){ |
return retour; |
} |
Iterator<String> itInterventions = interventions.keySet().iterator(); |
while (itInterventions.hasNext()) { |
JSONObject jsonIntervention = interventions.get(itInterventions.next()).isObject(); |
141,6 → 124,7 |
intervention.setDate(date); |
interventionsNonTypees.put(intervention.getId(), intervention); |
|
|
} else { |
Commentaire intervention = new Commentaire(contributeur, date, texte); |
intervention.setId(id); |
163,7 → 147,7 |
} |
} |
|
|
List<InterventionForum> retour = new ArrayList<InterventionForum>(); |
retour.addAll(interventionsNonTypees.values()); |
return retour; |
} |
221,8 → 205,13 |
vd.setVote(Integer.parseInt(getValeurOuVide(vote, "vote"))); |
vd.setContributeur(getValeurOuVide(vote, "auteur.id")); |
|
if (vote.get("auteur.nom") != null && vote.get("auteur.nom") != null && vote.get("auteur.courriel") != null) { |
Contributeur auteur = new Contributeur(getValeurOuVide(vote, "auteur.id"), getValeurOuVide(vote, "auteur.nom"), getValeurOuVide(vote, "auteur.prenom"), getValeurOuVide(vote, "auteur.courriel")); |
if(vote.get("auteur.nom") != null && |
vote.get("auteur.nom") != null && |
vote.get("auteur.courriel") != null) { |
Contributeur auteur = new Contributeur(getValeurOuVide(vote, "auteur.id"), |
getValeurOuVide(vote, "auteur.nom"), |
getValeurOuVide(vote, "auteur.prenom"), |
getValeurOuVide(vote, "auteur.courriel")); |
vd.setAuteur(auteur); |
} |
|