| 31 |
aperonnet |
1 |
package org.tela_botanica.client.modeles;
|
|
|
2 |
|
|
|
3 |
import org.tela_botanica.client.image.ImageMediateur;
|
|
|
4 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
|
|
5 |
|
|
|
6 |
import com.google.gwt.json.client.JSONArray;
|
|
|
7 |
import com.google.gwt.json.client.JSONObject;
|
|
|
8 |
import com.google.gwt.json.client.JSONParser;
|
|
|
9 |
import com.google.gwt.json.client.JSONString;
|
|
|
10 |
import com.google.gwt.json.client.JSONValue;
|
|
|
11 |
import com.google.gwt.user.client.HTTPRequest;
|
|
|
12 |
import com.google.gwt.user.client.ResponseTextHandler;
|
|
|
13 |
import com.google.gwt.user.client.Window;
|
|
|
14 |
|
|
|
15 |
public class NombreImageAsynchroneDAO {
|
|
|
16 |
|
|
|
17 |
private ImageMediateur iMediateur = null ;
|
|
|
18 |
|
|
|
19 |
public void setImediateur(ImageMediateur im)
|
|
|
20 |
{
|
|
|
21 |
iMediateur = im ;
|
|
|
22 |
}
|
|
|
23 |
|
|
|
24 |
public void obtenirNombreImages(final Rafraichissable r, String[][] criteres)
|
|
|
25 |
{
|
|
|
26 |
String requete = "" ;
|
|
|
27 |
|
|
|
28 |
if(criteres != null)
|
|
|
29 |
{
|
|
|
30 |
for (int i = 0; i < criteres.length; i++) {
|
|
|
31 |
|
|
|
32 |
if(!criteres[i][0].equals("ci_ordre"))
|
|
|
33 |
{
|
|
|
34 |
if(i != 0)
|
|
|
35 |
{
|
|
|
36 |
requete += "&" ;
|
|
|
37 |
}
|
|
|
38 |
requete += criteres[i][0]+"="+criteres[i][1] ;
|
|
|
39 |
if(i != criteres.length - 1)
|
|
|
40 |
{
|
|
|
41 |
requete += "&" ;
|
|
|
42 |
}
|
|
|
43 |
}
|
|
|
44 |
}
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
HTTPRequest.asyncGet("jrest/InventoryImageCount/0/"+requete, new ResponseTextHandler() {
|
|
|
48 |
public void onCompletion(String responseText) {
|
|
|
49 |
|
|
|
50 |
final JSONValue responseValue = JSONParser.parse(responseText);
|
|
|
51 |
|
|
|
52 |
if(responseValue.isArray() != null)
|
|
|
53 |
{
|
|
|
54 |
JSONValue res = responseValue.isArray().get(0) ;
|
|
|
55 |
JSONString reponseNombre = res.isString() ;
|
|
|
56 |
int maxImages = (int)Integer.parseInt(reponseNombre.stringValue()) ;
|
|
|
57 |
int[] nbImages = {maxImages} ;
|
|
|
58 |
r.rafraichir(nbImages, true) ;
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
}) ;
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
}
|