Subversion Repositories eFlore/Archives.cel-v2

Rev

Rev 12 | Rev 18 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 12 Rev 16
1
package org.tela_botanica.client.modeles;
1
package org.tela_botanica.client.modeles;
2
 
2
 
3
import org.tela_botanica.client.interfaces.Rafraichissable;
3
import org.tela_botanica.client.interfaces.Rafraichissable;
4
 
4
 
5
import com.google.gwt.json.client.JSONArray;
5
import com.google.gwt.json.client.JSONArray;
6
import com.google.gwt.json.client.JSONObject;
6
import com.google.gwt.json.client.JSONObject;
7
import com.google.gwt.json.client.JSONParser;
7
import com.google.gwt.json.client.JSONParser;
8
import com.google.gwt.json.client.JSONString;
8
import com.google.gwt.json.client.JSONString;
9
import com.google.gwt.json.client.JSONValue;
9
import com.google.gwt.json.client.JSONValue;
10
import com.google.gwt.user.client.HTTPRequest;
10
import com.google.gwt.user.client.HTTPRequest;
11
import com.google.gwt.user.client.ResponseTextHandler;
11
import com.google.gwt.user.client.ResponseTextHandler;
12
import com.gwtext.client.data.ArrayReader;
12
import com.gwtext.client.data.ArrayReader;
13
import com.gwtext.client.data.FieldDef;
13
import com.gwtext.client.data.FieldDef;
14
import com.gwtext.client.data.MemoryProxy;
14
import com.gwtext.client.data.MemoryProxy;
15
import com.gwtext.client.data.RecordDef;
15
import com.gwtext.client.data.RecordDef;
16
import com.gwtext.client.data.Store;
16
import com.gwtext.client.data.Store;
17
import com.gwtext.client.data.StringFieldDef;
17
import com.gwtext.client.data.StringFieldDef;
18
 
18
 
19
/**
19
/**
20
 * Data Object Access communiquant avec le serveur jrest fournissant la liste des images
20
 * Data Object Access communiquant avec le serveur jrest fournissant la liste des images
21
 * répondant à des critères donné
21
 * répondant à des critères donné
22
 * @author aurelien
22
 * @author aurelien
23
 *
23
 *
24
 */
24
 */
25
public class ListeImageAsynchroneDAO {
25
public class ListeImageAsynchroneDAO {
26
	
26
	
27
	public void ObtenirListeImages(final Rafraichissable r)
27
	public void ObtenirListeImages(final Rafraichissable r)
28
	{
28
	{
29
		HTTPRequest.asyncGet("jrest/inventoryImageList/1/ci_publiable_eflore=0", new ResponseTextHandler() {
29
		HTTPRequest.asyncGet("jrest/inventoryImageList/1/ci_publiable_eflore=0", new ResponseTextHandler() {
30
			public void onCompletion(String responseText) {
30
			public void onCompletion(String responseText) {
31
				
31
				
32
				final ListeImage photoData ;
32
				final ListeImage photoData ;
33
 
33
 
34
				final JSONValue responseValue = JSONParser.parse(responseText);
34
				final JSONValue responseValue = JSONParser.parse(responseText);
35
				if (responseValue.isArray() != null) {
35
				if (responseValue.isArray() != null) {
36
					
36
					
37
					final JSONArray reponse = responseValue.isArray();
37
					final JSONArray reponse = responseValue.isArray();
38
 
38
 
39
					final int taillemax = reponse.size();
39
					final int taillemax = reponse.size();
40
					photoData = new ListeImage(taillemax);
40
					photoData = new ListeImage(taillemax);
41
					
41
					
42
					
42
					
43
					for (int j = 0; j < taillemax ; j++) {
43
					for (int j = 0; j < taillemax ; j++) {
44
						
44
						
45
						JSONObject image = (JSONObject)reponse.get(j) ;
45
						JSONObject image = (JSONObject)reponse.get(j) ;
46
						
46
						
47
						photoData.add(new ImageCarnet(image)) ;
47
						photoData.add(new ImageCarnet(image)) ;
48
						
48
						
49
					}
49
					}
50
				}
50
				}
51
				else
51
				else
52
				{
52
				{
53
					if(responseValue.isObject() != null)
53
					if(responseValue.isObject() != null)
54
					{
54
					{
55
						photoData = new ListeImage(1);
55
						photoData = new ListeImage(1);
56
						photoData.add(new ImageCarnet(responseValue.isObject())) ;
56
						photoData.add(new ImageCarnet(responseValue.isObject())) ;
57
					}
57
					}
58
					else
58
					else
59
					{
59
					{
60
						photoData = null ;
60
						photoData = null ;
61
					}
61
					}
62
				}
62
				}
63
				
63
				
64
				r.rafraichir(photoData);
64
				r.rafraichir(photoData,true);
65
			}
65
			}
66
		});
66
		});
67
	}
67
	}
68
 
68
 
69
}
69
}