/trunk/src/org/tela_botanica/client/modeles/ListeReferentielNomAsynchroneDAO.java |
---|
5,6 → 5,11 |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.observation.ObservationModele; |
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.json.client.JSONArray; |
import com.google.gwt.json.client.JSONParser; |
import com.google.gwt.json.client.JSONString; |
43,59 → 48,72 |
public void obtenirListeDonnees(final Rafraichissable r, String critere) |
{ |
// on envoie le get asynchrone |
HTTPRequest.asyncGet(observationModele.getConfig().getServiceBaseUrl()+"/NameSearch/"+critere, new ResponseTextHandler() { |
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, observationModele.getConfig().getServiceBaseUrl()+"/NameSearch/"+critere) ; |
try { |
rb.sendRequest(null, new RequestCallback() { |
// si tout se passe bien on reçoit une réponse JSON |
public void onCompletion(String responseText) { |
public void onError(Request request, Throwable exception) { |
// TODO Auto-generated method stub |
} |
public void onResponseReceived(Request request, |
Response response) { |
final ListeReferentielNom referentielNomData ; |
final JSONValue responseValue = JSONParser.parse(responseText); |
JSONArray reponse=null; |
// si c'est un tableau |
if ((reponse=responseValue.isArray()) != null) { |
final ListeReferentielNom referentielNomData ; |
JSONArray noms; |
final int taillemax = reponse.size(); |
final JSONValue responseValue = JSONParser.parse(response.getText()); |
referentielNomData = new ListeReferentielNom(taillemax); |
for (int i = 0; i < taillemax; i++) { |
if ((noms=reponse.get(i).isArray()) != null) { |
String nom=Util.toCelString(((JSONString) noms.get(0)).toString()); |
String numeroNom=Util.toCelString(((JSONString) noms.get(1)).toString()); |
ReferentielNom nomScientifique=new ReferentielNom(nom, numeroNom); |
// FIXME : et si le numero de nom n'est pas unique ? (cas de multirefrentiel....) |
referentielNomData.put(nomScientifique.getNumeroNom(),nomScientifique); |
JSONArray reponse=null; |
// si c'est un tableau |
if ((reponse=responseValue.isArray()) != null) { |
JSONArray noms; |
final int taillemax = reponse.size(); |
referentielNomData = new ListeReferentielNom(taillemax); |
for (int i = 0; i < taillemax; i++) { |
if ((noms=reponse.get(i).isArray()) != null) { |
String nom=Util.toCelString(((JSONString) noms.get(0)).toString()); |
String numeroNom=Util.toCelString(((JSONString) noms.get(1)).toString()); |
ReferentielNom nomScientifique=new ReferentielNom(nom, numeroNom); |
// FIXME : et si le numero de nom n'est pas unique ? (cas de multirefrentiel....) |
referentielNomData.put(nomScientifique.getNumeroNom(),nomScientifique); |
} |
} |
} else { |
referentielNomData = new ListeReferentielNom(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 |
r.rafraichir(referentielNomData,true); |
} |
} |
}); |
}) ; |
} catch(RequestException e) { |
} |
} |
} |
/trunk/src/org/tela_botanica/client/modeles/ListeReferentielCommuneAsynchroneDAO.java |
---|
5,6 → 5,11 |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.observation.ObservationModele; |
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.json.client.JSONArray; |
import com.google.gwt.json.client.JSONParser; |
import com.google.gwt.json.client.JSONString; |
44,7 → 49,66 |
public void obtenirListeDonnees(final Rafraichissable r, String critere) |
{ |
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET,observationModele.getConfig().getServiceBaseUrl()+"/LocationSearch/"+critere) ; |
try { |
rb.sendRequest(null, new RequestCallback() { |
public void onError(Request request, Throwable exception) { |
// TODO Auto-generated method stub |
} |
public void onResponseReceived(Request request, |
Response response) { |
final ListeReferentielCommune referentielCommuneData ; |
final JSONValue responseValue = JSONParser.parse(response.getText()); |
JSONArray reponse=null; |
// si c'est un tableau |
if ((reponse=responseValue.isArray()) != null) { |
JSONArray communes; |
final int taillemax = reponse.size(); |
referentielCommuneData = new ListeReferentielCommune(taillemax); |
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); |
} |
} |
} 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 |
r.rafraichir(referentielCommuneData,true); |
} |
}) ; |
} catch (RequestException e) { |
e.printStackTrace() ; |
} |
// on envoie le get asynchrone |
HTTPRequest.asyncGet(observationModele.getConfig().getServiceBaseUrl()+"/LocationSearch/"+critere, new ResponseTextHandler() { |
54,43 → 118,7 |
public void onCompletion(String responseText) { |
final ListeReferentielCommune referentielCommuneData ; |
final JSONValue responseValue = JSONParser.parse(responseText); |
JSONArray reponse=null; |
// si c'est un tableau |
if ((reponse=responseValue.isArray()) != null) { |
JSONArray communes; |
final int taillemax = reponse.size(); |
referentielCommuneData = new ListeReferentielCommune(taillemax); |
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); |
} |
} |
// 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 |
r.rafraichir(referentielCommuneData,true); |
} |
} |
/trunk/src/org/tela_botanica/client/modeles/ObservationAsynchroneDAO.java |
---|
54,20 → 54,35 |
// private void addElement(String nom_sel, String num_nom_sel, String nom_ret, |
// String num_nom_ret, String num_taxon, String famille,final String loc, String id_location,String dat, String lieu, String sta, String mil, String comment) { |
RequestBuilder rb = new RequestBuilder(RequestBuilder.POST,oModele.getConfig().getServiceBaseUrl()+ "/Inventory/") ; |
String postData = "identifiant=" |
+ utilisateur + "&nom_sel=" + URL.encodeComponent(obs.getNomSaisi()) + "&num_nom_sel=" + obs.getNumeroNomenclaturalSaisi() |
+ "&nom_ret=" + URL.encodeComponent(obs.getNomRetenu()) + "&num_nom_ret=" + obs.getNumeroNomenclaturalRetenu() |
+ "&num_taxon=" + obs.getNumeroTaxonomique() + "&famille=" + URL.encodeComponent(obs.getFamille()) + "&location=" + URL.encodeComponent(obs.getLocalite()) + "&id_location=" + obs.getIdentifiantLocalite() + "&date_observation=" + obs.getDate() |
+ "&lieudit="+ URL.encodeComponent(obs.getLieudit()) + "&station="+ URL.encodeComponent(obs.getLieudit()) +"&milieu="+ URL.encodeComponent(obs.getMilieu()) + "&commentaire="+ URL.encodeComponent(obs.getCommentaire()) ; |
HTTPRequest.asyncPost(oModele.getConfig().getServiceBaseUrl()+ "/Inventory/", "identifiant=" |
+ utilisateur + "&nom_sel=" + URL.encodeComponent(obs.getNomSaisi()) + "&num_nom_sel=" + obs.getNumeroNomenclaturalSaisi() |
+ "&nom_ret=" + URL.encodeComponent(obs.getNomRetenu()) + "&num_nom_ret=" + obs.getNumeroNomenclaturalRetenu() |
+ "&num_taxon=" + obs.getNumeroTaxonomique() + "&famille=" + URL.encodeComponent(obs.getFamille()) + "&location=" + URL.encodeComponent(obs.getLocalite()) + "&id_location=" + obs.getIdentifiantLocalite() + "&date_observation=" + obs.getDate() |
+ "&lieudit="+ URL.encodeComponent(obs.getLieudit()) + "&station="+ URL.encodeComponent(obs.getLieudit()) +"&milieu="+ URL.encodeComponent(obs.getMilieu()) + "&commentaire="+ URL.encodeComponent(obs.getCommentaire()), |
try { |
rb.sendRequest(postData, new RequestCallback() { |
new ResponseTextHandler() { |
public void onError(Request request, Throwable exception) { |
// TODO Auto-generated method stub |
} |
public void onCompletion(String str) { |
public void onResponseReceived(Request request, |
Response response) { |
r.rafraichir(obs,true); |
} |
}); |
} |
}) ; |
} catch (RequestException e) { |
} |
} |
} |
/trunk/src/org/tela_botanica/client/modeles/ListeObservationAsynchroneDAO.java |
---|
4,6 → 4,11 |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.observation.ObservationModele; |
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.json.client.JSONArray; |
import com.google.gwt.json.client.JSONParser; |
import com.google.gwt.json.client.JSONString; |
62,66 → 67,77 |
requete += criteres[i][0]+"="+criteres[i][1] ; |
} |
} |
} |
} |
// on envoie le get asynchrone |
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET,observationModele.getConfig().getServiceBaseUrl() |
+"/InventoryObservationList/"+utilisateur+"/"+requete) ; |
// on envoie le get asynchrone |
HTTPRequest.asyncGet(observationModele.getConfig().getServiceBaseUrl()+"/InventoryObservationList/"+utilisateur+"/"+requete, new ResponseTextHandler() { |
// si tout se passe bien on reçoit une réponse JSON |
public void onCompletion(String responseText) { |
final ListeObservation observationData ; |
final JSONValue responseValue = JSONParser.parse(responseText); |
JSONArray reponse=null; |
// si c'est un tableau |
if ((reponse=responseValue.isArray()) != null) { |
try { |
rb.sendRequest(null, new RequestCallback() { |
public void onError(Request request, Throwable exception) { |
// TODO Auto-generated method stub |
JSONArray observation; |
final int taillemax = reponse.size(); |
} |
public void onResponseReceived(Request request, |
Response response) { |
observationData = new ListeObservation(taillemax); |
final ListeObservation observationData ; |
final JSONValue responseValue = JSONParser.parse(response.getText()); |
JSONArray reponse=null; |
for (int i = 0; i < taillemax; i++) { |
// si c'est un tableau |
if ((reponse=responseValue.isArray()) != null) { |
if ((observation=reponse.get(i).isArray()) != null) { |
JSONArray observation; |
final int taillemax = reponse.size(); |
observationData = new ListeObservation(taillemax); |
for (int i = 0; i < taillemax; i++) { |
String transmis=((JSONString) observation.get(13)).stringValue(); |
String identifiantLocalite=((JSONString) observation.get(14)).toString(); |
String nomSaisi=Util.toCelString(((JSONString) observation.get(0)).toString()); |
String nomRetenu=Util.toCelString(((JSONString) observation.get(2)).toString()); |
String numeroNomenclaturalSaisi=((JSONString) observation.get(1)).stringValue(); |
String numeroNomenclaturalRetenu=((JSONString) observation.get(3)).stringValue(); |
String numeroTaxonomique=((JSONString) observation.get(4)).stringValue(); |
String famille=Util.toCelString(((JSONString) observation .get(5)).toString()); |
String localite=Util.toCelString(((JSONString) observation .get(6)).toString()); |
String lieudit=Util.toCelString(((JSONString) observation .get(9)).toString()); |
String station=Util.toCelString(((JSONString) observation .get(10)).toString()); |
String milieu=Util.toCelString(((JSONString) observation .get(11)).toString()); |
String commentaire=Util.toCelString(((JSONString) observation .get(12)).toString()); |
String date=((JSONString) observation .get(8)).stringValue(); |
String numeroOrdre=((JSONString) observation.get(7)).stringValue(); |
Observation obs=new Observation(transmis, nomSaisi, nomRetenu, numeroNomenclaturalSaisi, numeroNomenclaturalRetenu ,numeroTaxonomique, famille, localite, identifiantLocalite, lieudit, station, milieu, commentaire, date, numeroOrdre); |
observationData.put(obs.getNumeroOrdre(),obs); |
if ((observation=reponse.get(i).isArray()) != null) { |
String transmis=((JSONString) observation.get(13)).stringValue(); |
String identifiantLocalite=((JSONString) observation.get(14)).toString(); |
String nomSaisi=Util.toCelString(((JSONString) observation.get(0)).toString()); |
String nomRetenu=Util.toCelString(((JSONString) observation.get(2)).toString()); |
String numeroNomenclaturalSaisi=((JSONString) observation.get(1)).stringValue(); |
String numeroNomenclaturalRetenu=((JSONString) observation.get(3)).stringValue(); |
String numeroTaxonomique=((JSONString) observation.get(4)).stringValue(); |
String famille=Util.toCelString(((JSONString) observation .get(5)).toString()); |
String localite=Util.toCelString(((JSONString) observation .get(6)).toString()); |
String lieudit=Util.toCelString(((JSONString) observation .get(9)).toString()); |
String station=Util.toCelString(((JSONString) observation .get(10)).toString()); |
String milieu=Util.toCelString(((JSONString) observation .get(11)).toString()); |
String commentaire=Util.toCelString(((JSONString) observation .get(12)).toString()); |
String date=((JSONString) observation .get(8)).stringValue(); |
String numeroOrdre=((JSONString) observation.get(7)).stringValue(); |
Observation obs=new Observation(transmis, nomSaisi, nomRetenu, numeroNomenclaturalSaisi, numeroNomenclaturalRetenu ,numeroTaxonomique, famille, localite, identifiantLocalite, lieudit, station, milieu, commentaire, date, numeroOrdre); |
observationData.put(obs.getNumeroOrdre(),obs); |
} |
} |
} else { |
observationData = new ListeObservation(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 |
r.rafraichir(observationData,true); |
} |
} |
}); |
// 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 |
r.rafraichir(observationData,true); |
} |
}) ; |
} catch (RequestException e) { |
// TODO Auto-generated catch block |
e.printStackTrace(); |
} |
} |
} |
/trunk/src/org/tela_botanica/client/modeles/NombreObservationAsynchroneDAO.java |
---|
3,6 → 3,11 |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.observation.ObservationModele; |
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.json.client.JSONParser; |
import com.google.gwt.json.client.JSONString; |
import com.google.gwt.json.client.JSONValue; |
55,29 → 60,47 |
} |
} |
// on fait un get asynchrone |
HTTPRequest.asyncGet(observationModele.getConfig().getServiceBaseUrl()+"/InventoryObservationCount/"+utilisateur+"/"+requete, new ResponseTextHandler() { |
public void onCompletion(String responseText) { |
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET,observationModele.getConfig().getServiceBaseUrl()+"/InventoryObservationCount/"+utilisateur+"/"+requete) ; |
try { |
rb.sendRequest(null, new RequestCallback() { |
public void onError(Request request, Throwable exception) { |
// TODO Auto-generated method stub |
} |
public void onResponseReceived(Request request, |
Response response) { |
final JSONValue responseValue = JSONParser.parse(response.getText()); |
// si la requete se passe bien on reçoit un tableau JSON |
if(responseValue.isArray() != null) |
{ |
// qui contient une valeur : le nombre d'images correspondant au critères |
JSONValue res = responseValue.isArray().get(0) ; |
JSONString reponseNombre = res.isString() ; |
int maxObservations = Integer.parseInt(reponseNombre.stringValue()) ; |
int[] nbObservations = {maxObservations} ; |
// on le met dans un tableau d'entiers qu'on tranmset au demandeur de la mise à jour |
r.rafraichir(nbObservations, true) ; |
} else { |
int[] nbObservations = {} ; |
r.rafraichir(nbObservations, true) ; |
} |
} |
final JSONValue responseValue = JSONParser.parse(responseText); |
// si la requete se passe bien on reçoit un tableau JSON |
if(responseValue.isArray() != null) |
{ |
// qui contient une valeur : le nombre d'images correspondant au critères |
JSONValue res = responseValue.isArray().get(0) ; |
JSONString reponseNombre = res.isString() ; |
int maxObservations = Integer.parseInt(reponseNombre.stringValue()) ; |
int[] nbObservations = {maxObservations} ; |
// on le met dans un tableau d'entiers qu'on tranmset au demandeur de la mise à jour |
r.rafraichir(nbObservations, true) ; |
} |
} |
}) ; |
}) ; |
} catch (RequestException e) { |
} |
} |
} |