63,6 → 63,7 |
*/ |
|
|
@Override |
public final void obtenirListeDonnees(final Rafraichissable r, final String critere) { |
|
|
85,21 → 86,20 |
|
rb.sendRequest(null, new RequestCallback() { |
|
@Override |
public void onError(final Request request, final Throwable exception) { |
// TODO Auto-generated method stub |
|
} |
|
@Override |
public void onResponseReceived(final Request request, |
final Response response) { |
|
final ListeReferentielCommune referentielCommuneData; |
|
final JSONValue responseValue = JSONParser.parse(response.getText()); |
|
final ListeReferentielCommune referentielCommuneData; |
final JSONValue responseValue = JSONParser.parse(response.getText()); |
JSONArray reponse = null; |
|
|
|
// si c'est un tableau |
if ((reponse = responseValue.isArray()) != null) { |
|
110,25 → 110,15 |
|
for (int i = 0; i < taillemax; i++) { |
if ((communes = reponse.get(i).isArray()) != null) { |
|
String commune = ((JSONString) communes.get(0)).stringValue(); |
String departement = ((JSONString) communes.get(1)).stringValue(); |
|
|
ReferentielCommune com = new ReferentielCommune(commune, departement); |
|
referentielCommuneData.put(com.getCommune() + com.getDepartement(), com); |
|
ReferentielCommune com = new ReferentielCommune(commune, departement); |
referentielCommuneData.put(com.getCommune() + com.getDepartement(), com); |
} |
} |
} else { |
|
} else { |
referentielCommuneData = new ListeReferentielCommune(0); |
|
} |
// dans tous les cas on transmet la liste crée au rafraichissable en lui demandant de répandre les données car il est |
// le premier à les recevoir |
|
} |
addToCache(critere, referentielCommuneData); |
r.rafraichir(referentielCommuneData, true); |
|
150,7 → 140,7 |
} |
|
private ListeReferentielCommune getFromCache (String query) { |
return (ListeReferentielCommune) cache.get(query.toLowerCase()); |
return cache.get(query.toLowerCase()); |
} |
|
|