Subversion Repositories eFlore/Applications.coel

Compare Revisions

Ignore whitespace Rev 120 → Rev 121

/trunk/src/org/tela_botanica/client/modeles/StructureAsyncDao.java
New file
0,0 → 1,71
package org.tela_botanica.client.modeles;
 
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.interfaces.Rafraichissable;
 
import com.extjs.gxt.ui.client.Registry;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.RequestException;
import com.google.gwt.http.client.Response;
import com.google.gwt.http.client.URL;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONValue;
 
public class StructureAsyncDao {
 
public void ajouter(final Rafraichissable r, String utilisateurId, final Structure str) {
String url = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl();
RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, url+"CoelStructureListe/");
String postDonnees = "identifiant=" + utilisateurId +
"&ce_projet =" + URL.encodeComponent(str.getIdProjet()) +
"&ce_mere =" + URL.encodeComponent(str.getIdMere()) +
"&guid =" + URL.encodeComponent(str.getGuid()) +
"&truk_identifiant_alternatif =" + URL.encodeComponent(str.getIdAlternatif()) +
"&nom=" + URL.encodeComponent(str.getNom()) +
"&truk_nom_alternatif =" + URL.encodeComponent(str.getNomAlternatif()) +
"&ce_type =" + URL.encodeComponent(str.getType()) +
"&ce_truk_type_prive =" + URL.encodeComponent(str.getTypePrive()) +
"&ce_truk_type_public =" + URL.encodeComponent(str.getTypePublic()) +
"&adresse_01 =" + URL.encodeComponent(str.getAdresse()) +
"&adresse_02 =" + URL.encodeComponent(str.getAdresseComplement()) +
"&date_fondation =" + URL.encodeComponent(str.getDateFondation()) +
"&code_postal =" + URL.encodeComponent(str.getCodePostal()) +
"&ville =" + URL.encodeComponent(str.getVille()) +
"&region =" + URL.encodeComponent(str.getRegion()) +
"&pays =" + URL.encodeComponent(str.getPays()) +
"&telephone =" + URL.encodeComponent(str.getTelephone()) +
"&fax =" + URL.encodeComponent(str.getFax()) +
"&truk_url =" + URL.encodeComponent(str.getUrl()) +
"&nbre_personne =" + URL.encodeComponent(str.getNbrePersonne()) +
"";
 
try {
rb.sendRequest(postDonnees, new RequestCallback() {
 
public void onError(Request request, Throwable exception) {
// TODO Auto-generated method stub
}
 
public void onResponseReceived(Request request, Response response) {
if (response.getText().length() != 0 && response.getText() != null) {
final JSONValue responseValue = JSONParser.parse(response.getText());
// Si la requête est un succès, reception d'un tableau
if (responseValue.isString() != null) {
str.set("messages", responseValue.isString().stringValue());
r.rafraichir(str);
}
}
}
}) ;
} catch (RequestException e) {
}
}
}