Subversion Repositories eFlore/Applications.del

Rev

Rev 763 | Rev 814 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 763 Rev 777
Line 10... Line 10...
10
import org.tela_botanica.del.client.modeles.Observation;
10
import org.tela_botanica.del.client.modeles.Observation;
11
import org.tela_botanica.del.client.modeles.PropositionDetermination;
11
import org.tela_botanica.del.client.modeles.PropositionDetermination;
12
import org.tela_botanica.del.client.modeles.Utilisateur;
12
import org.tela_botanica.del.client.modeles.Utilisateur;
13
import org.tela_botanica.del.client.modeles.VoteProtocole;
13
import org.tela_botanica.del.client.modeles.VoteProtocole;
Line -... Line 14...
-
 
14
 
14
 
15
import com.google.gwt.dev.js.rhino.ObjToIntMap.Iterator;
15
import com.google.gwt.i18n.client.DateTimeFormat;
16
import com.google.gwt.i18n.client.DateTimeFormat;
16
import com.google.gwt.json.client.JSONArray;
17
import com.google.gwt.json.client.JSONArray;
17
import com.google.gwt.json.client.JSONObject;
18
import com.google.gwt.json.client.JSONObject;
18
import com.google.gwt.json.client.JSONValue;
19
import com.google.gwt.json.client.JSONValue;
Line 79... Line 80...
79
		propositionDetermination.setEspece(UtilitairesServiceResultat.getValeurOuVide(observationJson,"determination.ns"));
80
		propositionDetermination.setEspece(UtilitairesServiceResultat.getValeurOuVide(observationJson,"determination.ns"));
Line 80... Line 81...
80
		
81
		
81
		return propositionDetermination;
82
		return propositionDetermination;
Line 82... Line 83...
82
	}
83
	}
Line 83... Line -...
83
	
-
 
84
	public static HashMap<String, HashMap<String,VoteProtocole>> parserVotesProtocoles(JSONArray votes) {
84
	
-
 
85
	public static HashMap<String, HashMap<String,VoteProtocole>> parserVotesProtocoles(JSONObject votes) {
85
		
86
		
86
		int nbVotes = votes.size();
87
		HashMap<String, HashMap<String,VoteProtocole>> votesProtocoles = new HashMap<String, HashMap<String,VoteProtocole>>();
87
		HashMap<String, HashMap<String,VoteProtocole>> votesProtocoles = new HashMap<String, HashMap<String,VoteProtocole>>();
88
		java.util.Iterator<String> itProtocoles = votes.keySet().iterator();
88
		for (int j = 0; j < nbVotes; j++) {
-
 
89
			JSONObject vote = votes.get(j).isObject();
89
		while(itProtocoles.hasNext()) {
-
 
90
			JSONObject protocole = votes.get(itProtocoles.next()).isObject();	
-
 
91
			JSONObject votesPourCeProtocoles = protocole.get("votes").isObject();
-
 
92
			String idProtocoleVote = protocole.get("protocole.id").isString().stringValue();
-
 
93
			java.util.Iterator<String> itVotes = votesPourCeProtocoles.keySet().iterator();
90
			VoteProtocole vd = new VoteProtocole();
94
			while(itVotes.hasNext()) {	
-
 
95
				JSONObject voteEnCours = votesPourCeProtocoles.get(itVotes.next()).isObject();
91
			
96
				VoteProtocole vd = new VoteProtocole();
92
			String idProtocoleVote = ""+Math.round((int)vote.get("id_protocole").isNumber().doubleValue());
97
				vd.setContributeur(voteEnCours.get("auteur.id").isString().stringValue());
93
			vd.setContributeur(vote.get("contributeur").isString().stringValue());
98
				// TODO récupérer la date du vote et la parser
94
			vd.setDate(new Date());
-
 
95
			int valeurVote = Math.round((int)vote.get("vote").isNumber().doubleValue());
99
				vd.setDate(new Date());
96
			vd.setVote(valeurVote);
100
				int valeurVote = Integer.parseInt(voteEnCours.get("vote").isString().stringValue());
-
 
101
				vd.setVote(valeurVote);
-
 
102
				if(!votesProtocoles.containsKey(idProtocoleVote)) {
97
			
103
					votesProtocoles.put(idProtocoleVote, new HashMap<String,VoteProtocole>());
98
			if(!votesProtocoles.containsKey(idProtocoleVote)) {
-
 
99
				votesProtocoles.put(idProtocoleVote, new HashMap<String,VoteProtocole>());
104
				}
Line 100... Line 105...
100
			}
105
				votesProtocoles.get(idProtocoleVote).put(vd.getContributeur(), vd);
101
			votesProtocoles.get(idProtocoleVote).put(vd.getContributeur(), vd);
106
			}