Line 5... |
Line 5... |
5 |
import java.util.HashMap;
|
5 |
import java.util.HashMap;
|
6 |
import java.util.List;
|
6 |
import java.util.List;
|
Line 7... |
Line 7... |
7 |
|
7 |
|
8 |
import org.tela_botanica.del.client.modeles.Contributeur;
|
8 |
import org.tela_botanica.del.client.modeles.Contributeur;
|
- |
|
9 |
import org.tela_botanica.del.client.modeles.Image;
|
9 |
import org.tela_botanica.del.client.modeles.Image;
|
10 |
import org.tela_botanica.del.client.modeles.InterventionForum;
|
10 |
import org.tela_botanica.del.client.modeles.Observation;
|
11 |
import org.tela_botanica.del.client.modeles.Observation;
|
11 |
import org.tela_botanica.del.client.modeles.PropositionDetermination;
|
12 |
import org.tela_botanica.del.client.modeles.PropositionDetermination;
|
- |
|
13 |
import org.tela_botanica.del.client.modeles.Utilisateur;
|
12 |
import org.tela_botanica.del.client.modeles.Utilisateur;
|
14 |
import org.tela_botanica.del.client.modeles.VoteDetermination;
|
Line 13... |
Line 15... |
13 |
import org.tela_botanica.del.client.modeles.VoteProtocole;
|
15 |
import org.tela_botanica.del.client.modeles.VoteProtocole;
|
14 |
|
16 |
|
15 |
import com.google.gwt.i18n.client.DateTimeFormat;
|
17 |
import com.google.gwt.i18n.client.DateTimeFormat;
|
Line 28... |
Line 30... |
28 |
image.setMiniature("http://www.tela-botanica.org/appli:cel-img:"+getIdAvecPadding(idImage)+"XS.jpg");
|
30 |
image.setMiniature("http://www.tela-botanica.org/appli:cel-img:"+getIdAvecPadding(idImage)+"XS.jpg");
|
Line 29... |
Line 31... |
29 |
|
31 |
|
30 |
return image;
|
32 |
return image;
|
Line 31... |
Line 33... |
31 |
}
|
33 |
}
|
32 |
|
- |
|
33 |
public static Observation parserObservationEtCreerPropositionDetermination(JSONObject observationJson) {
|
34 |
|
34 |
|
- |
|
35 |
Observation observation = parserObservationJSON(observationJson);
|
- |
|
36 |
observation.ajouterPropositionDetermination(creerPropositionDeterminationAPartirObservation(observation));
|
35 |
public static Observation parserObservationEtCreerPropositionDetermination(JSONObject observationJson) {
|
37 |
|
36 |
Observation observation = parserObservationJSON(observationJson);
|
Line 38... |
Line 37... |
38 |
return observation;
|
37 |
return observation;
|
Line 48... |
Line 47... |
48 |
//TODO: renvoyer le courriel de l'auteur dans les obs
|
47 |
//TODO: renvoyer le courriel de l'auteur dans les obs
|
49 |
observation.setCourrielAuteur("");
|
48 |
observation.setCourrielAuteur("");
|
50 |
observation.setDateTransmission(getValeurOuVide(observationJson,"date_observation"));
|
49 |
observation.setDateTransmission(getValeurOuVide(observationJson,"date_observation"));
|
51 |
observation.setDateReleve(getValeurOuVide(observationJson, "date_observation"));
|
50 |
observation.setDateReleve(getValeurOuVide(observationJson, "date_observation"));
|
52 |
observation.setFamille(getValeurOuVide(observationJson, "determination.famille"));
|
51 |
observation.setFamille(getValeurOuVide(observationJson, "determination.famille"));
|
53 |
observation.setId(UtilitairesServiceResultat.getValeurOuVide(observationJson, "id_observation"));
|
52 |
observation.setId(getValeurOuVide(observationJson, "id_observation"));
|
54 |
observation.setIdLocalite(UtilitairesServiceResultat.getValeurOuVide(observationJson, "id_zone_geo"));
|
53 |
observation.setIdLocalite(getValeurOuVide(observationJson, "id_zone_geo"));
|
55 |
observation.setLocalite(UtilitairesServiceResultat.getValeurOuVide(observationJson, "zone_geo"));
|
54 |
observation.setLocalite(getValeurOuVide(observationJson, "zone_geo"));
|
56 |
observation.setNomRetenu(UtilitairesServiceResultat.getValeurOuVide(observationJson, "determination.ns"));
|
55 |
observation.setNomRetenu(getValeurOuVide(observationJson, "determination.ns"));
|
57 |
observation.setMilieu(UtilitairesServiceResultat.getValeurOuVide(observationJson, "milieu"));
|
56 |
observation.setMilieu(getValeurOuVide(observationJson, "milieu"));
|
58 |
observation.setLieuDit(UtilitairesServiceResultat.getValeurOuVide(observationJson, "lieudit"));
|
57 |
observation.setLieuDit(getValeurOuVide(observationJson, "lieudit"));
|
59 |
observation.setNumNomenclatural(UtilitairesServiceResultat.getValeurOuVide(observationJson, "determination.nn"));
|
58 |
observation.setNumNomenclatural(getValeurOuVide(observationJson, "determination.nn"));
|
60 |
//TODO: renvoyer les mots clés des observations
|
59 |
//TODO: renvoyer les mots clés des observations
|
61 |
//observation.setMotsClefs(parserMotsCles(UtilitairesServiceResultat.getValeurOuVide(observationJson, "mots_cles_texte")));
|
60 |
//observation.setMotsClefs(parserMotsCles(UtilitairesServiceResultat.getValeurOuVide(observationJson, "mots_cles_texte")));
|
62 |
//TODO: renvoyer les commentaires des obs
|
61 |
//TODO: renvoyer les commentaires des obs
|
63 |
//observation.setCommentaire(UtilitairesServiceResultat.getValeurOuVide(observationJson, "commentaire"));
|
62 |
//observation.setCommentaire(UtilitairesServiceResultat.getValeurOuVide(observationJson, "commentaire"));
|
- |
|
63 |
JSONValue propositions = observationJson.get("commentaires");
|
- |
|
64 |
|
- |
|
65 |
if(propositions != null && propositions.isObject() != null) {
|
- |
|
66 |
observation.setInterventionsForum(parserInterventions(propositions.isObject(), observation));
|
- |
|
67 |
} else {
|
- |
|
68 |
observation.ajouterPropositionDetermination(creerPropositionDeterminationAPartirObservation(observation));
|
- |
|
69 |
}
|
64 |
return observation;
|
70 |
return observation;
|
65 |
}
|
71 |
}
|
Line 66... |
Line 72... |
66 |
|
72 |
|
67 |
public static String getValeurOuVide(JSONObject objet, String index) {
|
73 |
public static String getValeurOuVide(JSONObject objet, String index) {
|
Line 81... |
Line 87... |
81 |
propositionDetermination.setEspece(observation.getNomRetenu());
|
87 |
propositionDetermination.setEspece(observation.getNomRetenu());
|
Line 82... |
Line 88... |
82 |
|
88 |
|
83 |
return propositionDetermination;
|
89 |
return propositionDetermination;
|
Line -... |
Line 90... |
- |
|
90 |
}
|
- |
|
91 |
|
- |
|
92 |
public static List<InterventionForum> parserInterventions(JSONObject interventions, Observation observation) {
|
- |
|
93 |
List<InterventionForum> listeInterventions = new ArrayList<InterventionForum>();
|
- |
|
94 |
//TODO: ne faire ceci que si la proposition correspondant à la détermination originale n'a pas été créée
|
- |
|
95 |
PropositionDetermination determinationOriginale = creerPropositionDeterminationAPartirObservation(observation);
|
- |
|
96 |
listeInterventions.add(determinationOriginale);
|
- |
|
97 |
|
- |
|
98 |
java.util.Iterator<String> itInterventions = interventions.keySet().iterator();
|
- |
|
99 |
while (itInterventions.hasNext()) {
|
- |
|
100 |
JSONObject intervention = interventions.get(itInterventions.next()).isObject();
|
- |
|
101 |
String nomSel = getValeurOuVide(intervention, "nom_sel");
|
- |
|
102 |
if(!nomSel.equals("")) {
|
- |
|
103 |
PropositionDetermination propDeter = new PropositionDetermination(observation);
|
- |
|
104 |
Contributeur auteurProposition = new Contributeur(getValeurOuVide(intervention, "utilisateur_nom"),
|
- |
|
105 |
getValeurOuVide(intervention, "utilisateur_prenom"), getValeurOuVide(intervention, "utilisateur_courriel"));
|
- |
|
106 |
propDeter.setContributeur(auteurProposition);
|
- |
|
107 |
//TODO: parser date proposition
|
- |
|
108 |
propDeter.setDate(new Date());
|
- |
|
109 |
propDeter.setEspece(nomSel);
|
- |
|
110 |
propDeter.setId(getValeurOuVide(intervention, "id_commentaire"));
|
- |
|
111 |
if(intervention.get("votes") != null && intervention.get("votes").isObject() != null) {
|
- |
|
112 |
propDeter.setVotesDeterminations(parserVotesDetermination(intervention.get("votes").isObject(), propDeter));
|
- |
|
113 |
}
|
- |
|
114 |
listeInterventions.add(propDeter);
|
- |
|
115 |
}
|
- |
|
116 |
}
|
- |
|
117 |
|
- |
|
118 |
return listeInterventions;
|
- |
|
119 |
}
|
- |
|
120 |
|
- |
|
121 |
public static HashMap<String, VoteDetermination> parserVotesDetermination(JSONObject votes, PropositionDetermination proposition) {
|
- |
|
122 |
HashMap<String, VoteDetermination> votesDetermination = new HashMap<String, VoteDetermination>();
|
- |
|
123 |
java.util.Iterator<String> itVotes = votes.keySet().iterator();
|
- |
|
124 |
while (itVotes.hasNext()) {
|
- |
|
125 |
JSONObject vote = votes.get(itVotes.next()).isObject();
|
- |
|
126 |
VoteDetermination vd = new VoteDetermination();
|
- |
|
127 |
vd.setContributeur(getValeurOuVide(vote, "auteur.id"));
|
- |
|
128 |
vd.setDate(new Date());
|
- |
|
129 |
vd.setId(getValeurOuVide(vote, "vote.id"));
|
- |
|
130 |
vd.setPropositionDetermination(proposition);
|
- |
|
131 |
vd.setVote(Integer.parseInt(getValeurOuVide(vote, "vote")));
|
- |
|
132 |
|
- |
|
133 |
votesDetermination.put(getValeurOuVide(vote, "auteur.id"), vd);
|
- |
|
134 |
}
|
- |
|
135 |
return votesDetermination;
|
84 |
}
|
136 |
}
|
Line 85... |
Line 137... |
85 |
|
137 |
|
86 |
public static HashMap<String, HashMap<String,VoteProtocole>> parserVotesProtocoles(JSONObject votes) {
|
138 |
public static HashMap<String, HashMap<String,VoteProtocole>> parserVotesProtocoles(JSONObject votes) {
|
87 |
|
139 |
|