Subversion Repositories eFlore/Archives.cel-v2

Rev

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

Rev 18 Rev 22
Line 10... Line 10...
10
import com.google.gwt.json.client.JSONParser;
10
import com.google.gwt.json.client.JSONParser;
11
import com.google.gwt.json.client.JSONString;
11
import com.google.gwt.json.client.JSONString;
12
import com.google.gwt.json.client.JSONValue;
12
import com.google.gwt.json.client.JSONValue;
13
import com.google.gwt.user.client.HTTPRequest;
13
import com.google.gwt.user.client.HTTPRequest;
14
import com.google.gwt.user.client.ResponseTextHandler;
14
import com.google.gwt.user.client.ResponseTextHandler;
-
 
15
import com.google.gwt.user.client.Window;
15
import com.gwtext.client.data.ArrayReader;
16
import com.gwtext.client.data.ArrayReader;
16
import com.gwtext.client.data.FieldDef;
17
import com.gwtext.client.data.FieldDef;
17
import com.gwtext.client.data.MemoryProxy;
18
import com.gwtext.client.data.MemoryProxy;
18
import com.gwtext.client.data.RecordDef;
19
import com.gwtext.client.data.RecordDef;
19
import com.gwtext.client.data.Store;
20
import com.gwtext.client.data.Store;
Line 37... Line 38...
37
	public void ObtenirListeImages(final Rafraichissable r)
38
	public void ObtenirListeImages(final Rafraichissable r)
38
	{
39
	{
39
		HTTPRequest.asyncGet("jrest/inventoryImageList/1/ci_publiable_eflore=0", new ResponseTextHandler() {
40
		HTTPRequest.asyncGet("jrest/inventoryImageList/1/ci_publiable_eflore=0", new ResponseTextHandler() {
40
			public void onCompletion(String responseText) {
41
			public void onCompletion(String responseText) {
Line 41... Line 42...
41
				
42
				
Line 42... Line 43...
42
				final ListeImage photoData ;
43
				final ListeImageCarnet photoData ;
43
 
44
 
Line 44... Line 45...
44
				final JSONValue responseValue = JSONParser.parse(responseText);
45
				final JSONValue responseValue = JSONParser.parse(responseText);
Line 45... Line 46...
45
				if (responseValue.isArray() != null) {
46
				if (responseValue.isArray() != null) {
46
					
47
					
Line 47... Line 48...
47
					final JSONArray reponse = responseValue.isArray();
48
					final JSONArray reponse = responseValue.isArray();
Line 48... Line 49...
48
 
49
 
Line 62... Line 63...
62
				}
63
				}
63
				else
64
				else
64
				{
65
				{
65
					if(responseValue.isObject() != null)
66
					if(responseValue.isObject() != null)
66
					{
67
					{
67
						photoData = new ListeImage(1);
68
						photoData = new ListeImageCarnet(1);
68
						ImageCarnet im = new ImageCarnet(responseValue.isObject()) ;
69
						ImageCarnet im = new ImageCarnet(responseValue.isObject()) ;
69
						photoData.put(im.getOrdre(),im) ;
70
						photoData.put(im.getOrdre(),im) ;
70
					}
71
					}
71
					else
72
					else
72
					{
73
					{
73
						photoData = null ;
74
						photoData = new ListeImageCarnet(0) ;
74
					}
75
					}
75
				}
76
				}
Line 76... Line 77...
76
				
77
				
77
				r.rafraichir(photoData,true);
78
				r.rafraichir(photoData,true);
78
			}
79
			}
79
		});
80
		});
Line 80... Line 81...
80
	}
81
	}
81
	
82
	
82
	public void SynchroniserBaseDeDonnees(ListeImage li)
83
	public void SynchroniserBaseDeDonnees(ListeImageCarnet li)
83
	{
84
	{
-
 
85
		for(Iterator listIt = li.keySet().iterator() ; listIt.hasNext() ;)
84
		for(Iterator it = li.keySet().iterator() ; it.hasNext() ;)
86
		{
-
 
87
			String postData = "" ;
-
 
88
			
-
 
89
			ImageCarnet enCours = (ImageCarnet)li.get(listIt.next()) ;
-
 
90
			
-
 
91
			System.out.println(enCours.toString()+"\n");
-
 
92
			
-
 
93
			for(Iterator imgIt = enCours.keySet().iterator();imgIt.hasNext();)
-
 
94
			{
-
 
95
				String key = (String)imgIt.next() ;
-
 
96
				String valeur = enCours.renvoyerValeurCorrecte(key) ;
-
 
97
				valeur.replaceAll("'", "\'") ;
-
 
98
					postData += "&"+key+"="+enCours.renvoyerValeurCorrecte(key) ;
-
 
99
			
-
 
100
			}
85
		{
101
			
-
 
102
			//System.out.println(postData);
-
 
103
					HTTPRequest.asyncPost("jrest/inventoryImage/0/", postData, new ResponseTextHandler() {
-
 
104
						public void onCompletion(String responseText) {
-
 
105
							
-
 
106
							
-
 
107
						}
-
 
108
						
-
 
109
					}) ;
-
 
110
		}
-
 
111
	}
-
 
112
	
-
 
113
	public void supprimerBaseDeDonnees(String[] ids)
-
 
114
	{
-
 
115
		String postData = "" ;
-
 
116
		postData += "&action=DELETE" ;
-
 
117
		
-
 
118
		String uid = "" ;
-
 
119
		
-
 
120
		for (int i = 0; i < ids.length; i++) {
86
					
121
			
-
 
122
			uid += ids[i]+"," ;
-
 
123
		}
-
 
124
		
-
 
125
		
-
 
126
		HTTPRequest.asyncPost("jrest/inventoryImageList/0/"+uid, postData, new ResponseTextHandler() {
-
 
127
			public void onCompletion(String responseText) {
-
 
128
				
-
 
129
				iMediateur.rafraichirToutesVues() ;
-
 
130
			}
87
		//	HTTPRequest.asyncPost("jrest/inventoryImageList/1/", postData, handler)
131
			
Line 88... Line 132...
88
		}
132
		}) ;