Subversion Repositories eFlore/Applications.del

Rev

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

Rev 954 Rev 965
Line 179... Line 179...
179
			String nom = getValeurOuVide(jsonIntervention, "auteur.nom");
179
			String nom = getValeurOuVide(jsonIntervention, "auteur.nom");
180
			String prenom = getValeurOuVide(jsonIntervention, "auteur.prenom");
180
			String prenom = getValeurOuVide(jsonIntervention, "auteur.prenom");
181
			String courriel = getValeurOuVide(jsonIntervention, "auteur.courriel");
181
			String courriel = getValeurOuVide(jsonIntervention, "auteur.courriel");
182
			Contributeur contributeur = new Contributeur(idUtilisateur, nom, prenom, courriel);
182
			Contributeur contributeur = new Contributeur(idUtilisateur, nom, prenom, courriel);
Line 183... Line -...
183
 
-
 
184
			// TODO : parser date
183
 
Line 185... Line 184...
185
			Date date = new Date();
184
			Date date = parserDateObservation(getValeurOuVide(jsonIntervention, "date"));
186
 
185
 
187
			if (!nomSel.equals("")) {
186
			if (!nomSel.equals("")) {
188
				String nom_sel = getValeurOuVide(jsonIntervention, "nom_sel");
187
				String nom_sel = getValeurOuVide(jsonIntervention, "nom_sel");
Line 302... Line 301...
302
		java.util.Iterator<String> itVotes = votes.keySet().iterator();
301
		java.util.Iterator<String> itVotes = votes.keySet().iterator();
303
		while (itVotes.hasNext()) {
302
		while (itVotes.hasNext()) {
304
			JSONObject vote = votes.get(itVotes.next()).isObject();
303
			JSONObject vote = votes.get(itVotes.next()).isObject();
305
			VoteDetermination vd = new VoteDetermination();
304
			VoteDetermination vd = new VoteDetermination();
306
			vd.setContributeur(getValeurOuVide(vote, "auteur.id"));
305
			vd.setContributeur(getValeurOuVide(vote, "auteur.id"));
307
			vd.setDate(new Date());
306
			vd.setDate(parserDateObservation(getValeurOuVide(vote, "date")));
308
			vd.setId(getValeurOuVide(vote, "vote.id"));
307
			vd.setId(getValeurOuVide(vote, "vote.id"));
309
			vd.setVote(Integer.parseInt(getValeurOuVide(vote, "vote")));
308
			vd.setVote(Integer.parseInt(getValeurOuVide(vote, "vote")));
310
			vd.setContributeur(getValeurOuVide(vote, "auteur.id"));
309
			vd.setContributeur(getValeurOuVide(vote, "auteur.id"));
Line 311... Line 310...
311
 
310
 
Line 337... Line 336...
337
			while (itVotes.hasNext()) {
336
			while (itVotes.hasNext()) {
338
				JSONObject voteEnCours = votesPourCeProtocoles.get(itVotes.next()).isObject();
337
				JSONObject voteEnCours = votesPourCeProtocoles.get(itVotes.next()).isObject();
339
				VoteProtocole vd = new VoteProtocole();
338
				VoteProtocole vd = new VoteProtocole();
340
				vd.setContributeur(voteEnCours.get("auteur.id").isString().stringValue());
339
				vd.setContributeur(voteEnCours.get("auteur.id").isString().stringValue());
341
				// TODO récupérer la date du vote et la parser
340
				// TODO récupérer la date du vote et la parser
342
				vd.setDate(new Date());
341
				vd.setDate(parserDateObservation(getValeurOuVide(voteEnCours, "date")));
343
				int valeurVote = Integer.parseInt(voteEnCours.get("vote").isString().stringValue());
342
				int valeurVote = Integer.parseInt(voteEnCours.get("vote").isString().stringValue());
344
				vd.setVote(valeurVote);
343
				vd.setVote(valeurVote);
345
				if (!votesProtocoles.containsKey(idProtocoleVote)) {
344
				if (!votesProtocoles.containsKey(idProtocoleVote)) {
346
					votesProtocoles.put(idProtocoleVote, new HashMap<String, VoteProtocole>());
345
					votesProtocoles.put(idProtocoleVote, new HashMap<String, VoteProtocole>());
347
				}
346
				}
Line 358... Line 357...
358
	 * @param imageJson
357
	 * @param imageJson
359
	 * @return
358
	 * @return
360
	 */
359
	 */
361
	public static Date parserDateObservation(String date) {
360
	public static Date parserDateObservation(String date) {
362
		Date dateParsee = new Date();
361
		Date dateParsee = new Date();
363
		DateTimeFormat formatDateObs = DateTimeFormat.getFormat("dd/MM/yyyy");
362
		DateTimeFormat formatDateObs = DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss");
364
		try {
363
		try {
365
			dateParsee = formatDateObs.parse(date);
364
			dateParsee = formatDateObs.parse(date);
366
		} catch (IllegalArgumentException e) {
365
		} catch (IllegalArgumentException e) {
367
			dateParsee = new java.sql.Date(0);
366
			dateParsee = new java.sql.Date(0);
368
		}
367
		}