Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 1417 Rev 1468
Line 8... Line 8...
8
import org.tela_botanica.client.http.JsonRestRequestCallback;
8
import org.tela_botanica.client.http.JsonRestRequestCallback;
9
import org.tela_botanica.client.interfaces.Rafraichissable;
9
import org.tela_botanica.client.interfaces.Rafraichissable;
10
import org.tela_botanica.client.modeles.Information;
10
import org.tela_botanica.client.modeles.Information;
11
import org.tela_botanica.client.modeles.structure.StructureListe;
11
import org.tela_botanica.client.modeles.structure.StructureListe;
12
import org.tela_botanica.client.synchronisation.Reponse;
12
import org.tela_botanica.client.synchronisation.Reponse;
-
 
13
import org.tela_botanica.client.util.Debug;
13
import org.tela_botanica.client.util.UtilDAO;
14
import org.tela_botanica.client.util.UtilDAO;
Line 14... Line 15...
14
 
15
 
15
import com.extjs.gxt.ui.client.Registry;
16
import com.extjs.gxt.ui.client.Registry;
16
import com.extjs.gxt.ui.client.widget.Info;
17
import com.extjs.gxt.ui.client.widget.Info;
Line 38... Line 39...
38
	 * 						fur et à mesure de la consultation des données par l'utilisateur.
39
	 * 						fur et à mesure de la consultation des données par l'utilisateur.
39
	 * 			- False :	la consultation des données est classique : un seul appel à la base de données est effectué, le retour
40
	 * 			- False :	la consultation des données est classique : un seul appel à la base de données est effectué, le retour
40
	 * 						est renvoyé à l'appelant
41
	 * 						est renvoyé à l'appelant
41
	 * 			// FIXME : si la taille de la liste est supérieure à la limite du JREST (150), ce deuxieme mode ne fonctionne pas
42
	 * 			// FIXME : si la taille de la liste est supérieure à la limite du JREST (150), ce deuxieme mode ne fonctionne pas
42
	 */
43
	 */
43
	public void selectionner(final boolean paginationProgressive, final String projetId, final String nomProjet, final int start, final int nbElements, final Integer seqId) {
44
	public void selectionner(final boolean paginationProgressive, final String projetId, final String nomProjet, final int start, final int nbElements, final String formatRetour, final Integer seqId) {
Line 44... Line 45...
44
		
45
		
45
		String nom = (nomProjet == null) ? "%" : nomProjet+"%";
46
		String nom = (nomProjet == null) ? "%" : nomProjet+"%";
Line 46... Line 47...
46
		String[] param = {projetId, nom};
47
		String[] param = {projetId, nom};
Line 47... Line 48...
47
		
48
		
48
		HashMap<String, String> restrictions = new HashMap<String, String>();
49
		HashMap<String, String> restrictions = new HashMap<String, String>();
49
		
50
		
-
 
51
		if (nbElements != -1) {
-
 
52
			restrictions.put("limit", String.valueOf(nbElements));
-
 
53
		}
-
 
54
 
Line 50... Line 55...
50
		if (nbElements != -1)	{
55
		if ((formatRetour != null) && (formatRetour != "")) {
51
			restrictions.put("limit", String.valueOf(nbElements));
56
			restrictions.put("formatRetour", formatRetour);
Line 52... Line 57...
52
		}
57
		}
Line 87... Line 92...
87
			final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, param, restrictions);
92
			final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, param, restrictions);
Line 88... Line 93...
88
			
93
			
Line 89... Line 94...
89
			rb.envoyerRequete(null, new JsonRestRequestCallback() {
94
			rb.envoyerRequete(null, new JsonRestRequestCallback() {
90
				
95
				
91
				public void surReponse(JSONValue responseValue) {
96
				public void surReponse(JSONValue responseValue) {
Line 92... Line 97...
92
					
97
    				
Line 93... Line 98...
93
					if (responseValue != null) {
98
					if (responseValue != null) {
Line 102... Line 107...
102
								JSONArray reponse = responseObject.get("projets").isArray();
107
								JSONArray reponse = responseObject.get("projets").isArray();
103
								ProjetListe projets;
108
								ProjetListe projets;
104
								projets = new ProjetListe(reponse, responseObject.get("nbElements").isNumber(), vueARafraichir);
109
								projets = new ProjetListe(reponse, responseObject.get("nbElements").isNumber(), vueARafraichir);
105
								projets.setTaillePage(nbElements);
110
								projets.setTaillePage(nbElements);
106
								projets.setPageCourante(start);							
111
								projets.setPageCourante(start);							
107
								
112
 
108
								if (seqId != null)	{
113
								if (seqId != null) {
109
									Reponse retourRequete = new Reponse(projets, seqId);
114
									Reponse retourRequete = new Reponse(projets, seqId);
110
									vueARafraichir.rafraichir(retourRequete);
115
									vueARafraichir.rafraichir(retourRequete);
111
								} else {
116
								} else {
112
									vueARafraichir.rafraichir(projets);
117
									vueARafraichir.rafraichir(projets);
113
								}
118
								}
Line 114... Line 119...
114
							
119
							
115
							// Si la réponse est un objet, alors c'est un unique projet qui a été retournée
120
							// Si la réponse est un objet, alors c'est un unique projet qui a été retourné
Line 116... Line 121...
116
							} else if (responseObject.get("projets").isObject() != null) {
121
							} else if (responseObject.get("projets").isObject() != null) {
117
								
122
								
Line 118... Line 123...
118
								JSONObject reponse = responseObject.get("projets").isObject();
123
								JSONObject reponse = responseObject.get("projets").isObject();
119
								Projet projet = new Projet(reponse);
124
								Projet projet = new Projet(reponse);
120
								
125
								
121
								Information info = new Information("selection_projet");
126
								Information info = new Information("selection_projet");
122
								info.setDonnee(0, projet);
127
								info.setDonnee(0, projet);
123
								
128
 
124
								if (seqId != null)	{
129
								if (seqId != null) {
125
									Reponse reponseRequete = new Reponse(info, seqId);
130
									Reponse reponseRequete = new Reponse(info, seqId);
126
									vueARafraichir.rafraichir(reponseRequete);
131
									vueARafraichir.rafraichir(reponseRequete);
127
								}
132
								}
128
								else	{
133
								else {
129
									vueARafraichir.rafraichir(info);
134
									vueARafraichir.rafraichir(info);
130
								}
135
								}