Subversion Repositories eFlore/Archives.cel-v2

Rev

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

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