12,6 → 12,7 |
import org.tela_botanica.del.client.modeles.Utilisateur; |
import org.tela_botanica.del.client.modeles.VoteProtocole; |
|
import com.google.gwt.dev.js.rhino.ObjToIntMap.Iterator; |
import com.google.gwt.i18n.client.DateTimeFormat; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONObject; |
81,24 → 82,28 |
return propositionDetermination; |
} |
|
public static HashMap<String, HashMap<String,VoteProtocole>> parserVotesProtocoles(JSONArray votes) { |
public static HashMap<String, HashMap<String,VoteProtocole>> parserVotesProtocoles(JSONObject votes) { |
|
int nbVotes = votes.size(); |
HashMap<String, HashMap<String,VoteProtocole>> votesProtocoles = new HashMap<String, HashMap<String,VoteProtocole>>(); |
for (int j = 0; j < nbVotes; j++) { |
JSONObject vote = votes.get(j).isObject(); |
VoteProtocole vd = new VoteProtocole(); |
|
String idProtocoleVote = ""+Math.round((int)vote.get("id_protocole").isNumber().doubleValue()); |
vd.setContributeur(vote.get("contributeur").isString().stringValue()); |
vd.setDate(new Date()); |
int valeurVote = Math.round((int)vote.get("vote").isNumber().doubleValue()); |
vd.setVote(valeurVote); |
|
if(!votesProtocoles.containsKey(idProtocoleVote)) { |
votesProtocoles.put(idProtocoleVote, new HashMap<String,VoteProtocole>()); |
java.util.Iterator<String> itProtocoles = votes.keySet().iterator(); |
while(itProtocoles.hasNext()) { |
JSONObject protocole = votes.get(itProtocoles.next()).isObject(); |
JSONObject votesPourCeProtocoles = protocole.get("votes").isObject(); |
String idProtocoleVote = protocole.get("protocole.id").isString().stringValue(); |
java.util.Iterator<String> itVotes = votesPourCeProtocoles.keySet().iterator(); |
while(itVotes.hasNext()) { |
JSONObject voteEnCours = votesPourCeProtocoles.get(itVotes.next()).isObject(); |
VoteProtocole vd = new VoteProtocole(); |
vd.setContributeur(voteEnCours.get("auteur.id").isString().stringValue()); |
// TODO récupérer la date du vote et la parser |
vd.setDate(new Date()); |
int valeurVote = Integer.parseInt(voteEnCours.get("vote").isString().stringValue()); |
vd.setVote(valeurVote); |
if(!votesProtocoles.containsKey(idProtocoleVote)) { |
votesProtocoles.put(idProtocoleVote, new HashMap<String,VoteProtocole>()); |
} |
votesProtocoles.get(idProtocoleVote).put(vd.getContributeur(), vd); |
} |
votesProtocoles.get(idProtocoleVote).put(vd.getContributeur(), vd); |
} |
|
return votesProtocoles; |