Subversion Repositories eFlore/Applications.del

Rev

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

Rev 500 Rev 534
Line 14... Line 14...
14
import com.google.gwt.json.client.JSONObject;
14
import com.google.gwt.json.client.JSONObject;
15
import com.google.gwt.json.client.JSONValue;
15
import com.google.gwt.json.client.JSONValue;
16
import com.google.gwt.user.client.Window;
16
import com.google.gwt.user.client.Window;
Line 17... Line 17...
17
 
17
 
18
public class ImageServiceResultat {
18
public class ImageServiceResultat {
19
	
19
 
20
	private List<Image> images;
20
	private List<Image> images;
21
	
21
 
22
	private int nbTotalImagesPourLaRecherche;
22
	private int nbTotalImagesPourLaRecherche;
23
	
23
 
24
	public ImageServiceResultat(JSONValue retourJson) {
24
	public ImageServiceResultat(JSONValue retourJson) {
-
 
25
 
25
		
26
		try {
26
		//TODO ajouter vérifications plus précises
27
			// TODO ajouter vérifications plus précises
27
		double total = retourJson.isObject().get("total").isNumber().doubleValue();
28
			double total = retourJson.isObject().get("total").isNumber().doubleValue();
28
		nbTotalImagesPourLaRecherche = (int) total;
29
			nbTotalImagesPourLaRecherche = (int) total;
29
		
30
 
30
		JSONArray tableauObs = retourJson.isObject().get("contenu").isArray();
31
			JSONArray tableauObs = retourJson.isObject().get("contenu").isArray();
31
		images = new ArrayList<Image>();
32
			images = new ArrayList<Image>();
32
		
33
 
33
		int nbResultats = tableauObs.size();
34
			int nbResultats = tableauObs.size();
34
		for (int i = 0; i < nbResultats; i++) {
35
			for (int i = 0; i < nbResultats; i++) {
35
			
36
 
36
			JSONObject imageJson = tableauObs.get(i).isObject();
37
				JSONObject imageJson = tableauObs.get(i).isObject();
37
			Image image = UtilitairesServiceResultat.parserImageJSON(imageJson);
38
				Image image = UtilitairesServiceResultat.parserImageJSON(imageJson);
38
			
39
 
39
			if(imageJson.get("observation") != null && imageJson.get("observation").isObject() != null) {				
40
				if (imageJson.get("observation") != null && imageJson.get("observation").isObject() != null) {
40
				JSONObject observationJson = imageJson.get("observation").isObject();						
41
					JSONObject observationJson = imageJson.get("observation").isObject();
41
				image.setObservation(UtilitairesServiceResultat.parserObservationEtCreerPropositionDetermination(observationJson));	
42
					image.setObservation(UtilitairesServiceResultat.parserObservationEtCreerPropositionDetermination(observationJson));
42
			}
43
				}
43
			
44
 
44
			if(imageJson.get("votes") != null && imageJson.get("votes").isArray() != null) {					
45
				if (imageJson.get("votes") != null && imageJson.get("votes").isArray() != null) {
45
				JSONArray votes = imageJson.get("votes").isArray();						
46
					JSONArray votes = imageJson.get("votes").isArray();
-
 
47
					image.setVoteProtocoles(UtilitairesServiceResultat.parserVotesProtocoles(votes));
-
 
48
				}
-
 
49
 
46
				image.setVoteProtocoles(UtilitairesServiceResultat.parserVotesProtocoles(votes));
50
				images.add(image);
-
 
51
			}
47
			}
52
		} catch (Exception e) {
48
	
-
 
49
			images.add(image);
53
 
50
		}
54
		}
51
	}
55
	}
52
	
56
 
53
	public List<Image> getImages() {
57
	public List<Image> getImages() {
54
		return images;
58
		return images;
Line 55... Line 59...
55
	}
59
	}