Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 989 Rev 1293
Line 61... Line 61...
61
	 * @param r le rafraichissable qui demande la mise à jour
61
	 * @param r le rafraichissable qui demande la mise à jour
62
	 * @param critere un string contenant le terme a rechercher
62
	 * @param critere un string contenant le terme a rechercher
63
	 */
63
	 */
Line -... Line 64...
-
 
64
	
64
	
65
	
Line 65... Line 66...
65
	
66
	@Override
Line 83... Line 84...
83
		
84
		
Line 84... Line 85...
84
		try {
85
		try {
Line -... Line 86...
-
 
86
			
85
			
87
			rb.sendRequest(null, new RequestCallback() {
86
			rb.sendRequest(null, new RequestCallback() {
88
 
Line 87... Line 89...
87
 
89
				@Override
Line -... Line 90...
-
 
90
				public void onError(final Request request, final Throwable exception) {
88
				public void onError(final Request request, final Throwable exception) {
91
					// TODO Auto-generated method stub
89
					// TODO Auto-generated method stub
92
					
Line 90... Line 93...
90
					
93
				}
91
				}
-
 
92
 
94
 
93
				public void onResponseReceived(final Request request,
-
 
94
						final Response response) {
95
				@Override
95
					
-
 
96
					final ListeReferentielCommune referentielCommuneData;
96
				public void onResponseReceived(final Request request,
97
					
97
						final Response response) {
98
					final JSONValue responseValue = JSONParser.parse(response.getText());
98
					
Line 99... Line 99...
99
					
99
					final ListeReferentielCommune referentielCommuneData;					
100
					JSONArray reponse = null;
100
					final JSONValue responseValue = JSONParser.parse(response.getText());					
Line 101... Line 101...
101
		
101
					JSONArray reponse = null;
Line 102... Line 102...
102
		
102
 
103
					// si c'est un tableau
103
					// si c'est un tableau
104
					if ((reponse = responseValue.isArray()) != null) {
-
 
105
						
104
					if ((reponse = responseValue.isArray()) != null) {
106
						JSONArray communes;
105
						
107
						final int taillemax = reponse.size();
-
 
108
						
-
 
109
						referentielCommuneData = new ListeReferentielCommune(taillemax);
106
						JSONArray communes;
110
						
-
 
111
						for (int i = 0; i < taillemax; i++) {
107
						final int taillemax = reponse.size();
112
							if ((communes = reponse.get(i).isArray()) != null) {
-
 
113
								
108
						
114
								String commune = ((JSONString) communes.get(0)).stringValue();
109
						referentielCommuneData = new ListeReferentielCommune(taillemax);
115
								String departement  = ((JSONString) communes.get(1)).stringValue();
110
						
116
								
-
 
117
								
111
						for (int i = 0; i < taillemax; i++) {
118
								ReferentielCommune com = new ReferentielCommune(commune, departement);
-
 
119
				
112
							if ((communes = reponse.get(i).isArray()) != null) {
120
								referentielCommuneData.put(com.getCommune() + com.getDepartement(), com);
-
 
121
										
-
 
122
							}	
-
 
123
						}
113
								String commune = ((JSONString) communes.get(0)).stringValue();
124
					} else {
114
								String departement  = ((JSONString) communes.get(1)).stringValue();
Line 125... Line 115...
125
						
115
								ReferentielCommune com = new ReferentielCommune(commune, departement);		
Line 148... Line 138...
148
	  private void addToCache(String query, ListeReferentielCommune result)	  {
138
	  private void addToCache(String query, ListeReferentielCommune result)	  {
149
		  cache.put(query.toLowerCase(),result);
139
		  cache.put(query.toLowerCase(),result);
150
	  }
140
	  }
Line 151... Line 141...
151
 
141
 
152
	  private ListeReferentielCommune getFromCache (String query) {
142
	  private ListeReferentielCommune getFromCache (String query) {
153
		  return (ListeReferentielCommune) cache.get(query.toLowerCase());
143
		  return cache.get(query.toLowerCase());
Line 154... Line 144...
154
	  }
144
	  }