Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 2694 → Rev 2695

/trunk/src/org/tela_botanica/client/modeles/dao/ImageInformationRepartitionAsynchroneDAO.java
4,11 → 4,13
import org.tela_botanica.client.modeles.objets.Configuration;
import org.tela_botanica.client.observation.ObservationModele;
 
import com.google.gwt.core.client.Callback;
import com.google.gwt.http.client.Request;
import org.tela_botanica.client.util.RequestBuilderWithCredentials;
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.JSONString;
84,6 → 86,39
}
}
public static void taxonEstPresentDansZoneGeo(String referentielTaxo, String numeroNomenclaturalSaisiObservation, String pays, String zoneGeo, final Callback<String, String> callback) {
String referentielDefaut = Configuration.getReferentielsDispos().get(0).getCode();
referentielTaxo = (referentielTaxo != null && !referentielTaxo.isEmpty()) ? referentielTaxo : referentielDefaut;
String url = Configuration.getServiceBaseUrl()+"/InventoryTaxonPresent/"+referentielTaxo+"/"+numeroNomenclaturalSaisiObservation+"?pays="+URL.encode(pays)+"&ce_zone_geo="+URL.encode(zoneGeo);
RequestBuilderWithCredentials rb = new RequestBuilderWithCredentials(RequestBuilderWithCredentials.GET, url) ;
try {
rb.sendRequest(null, new RequestCallback() {
 
@Override
public void onError(Request request, Throwable exception) {
callback.onFailure(exception.getMessage());
}
 
@Override
public void onResponseReceived(Request request,
Response response) {
final JSONValue responseValue = JSONParser
.parse(response.getText());
if (responseValue.isString() != null) {
//Window.alert(response.getText()+responseValue.isString().stringValue());
callback.onSuccess(responseValue.isString().stringValue());
} else {
callback.onFailure(response.getText());
}
}
}) ;
 
} catch (RequestException e) {
callback.onFailure(e.getMessage());
}
}
}
/trunk/src/org/tela_botanica/client/modeles/objets/Configuration.java
79,6 → 79,8
private static String langueDefaut = "";
private static String languesDisponibles = "";
private static String chorologieAvertissementCourriel = "";
 
/**
* Constructeur sans argument
158,6 → 160,8
languesDisponibles = Dictionary.getDictionary("configuration").get("languesDisponibles");
chorologieAvertissementCourriel = Dictionary.getDictionary("configuration").get("chorologieAvertissementCourriel");
// Pour test, l'activation de l'ajout des champs étendus est activable ou désactivable par
// l'url
if(Location.getParameter("activerSaisieChampsEtendus") != null) {
319,4 → 323,8
public static String getLanguesDisponibles() {
return languesDisponibles;
}
public static String getChorologieAvertissementCourriel() {
return chorologieAvertissementCourriel;
}
}
/trunk/src/org/tela_botanica/client/vues/observation/FormulaireSaisieObservationVue.java
11,6 → 11,7
import org.tela_botanica.client.CarnetEnLigneMediateur;
import org.tela_botanica.client.i18n.Msg;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.dao.ImageInformationRepartitionAsynchroneDAO;
import org.tela_botanica.client.modeles.dao.ListeReferentielChampsEtendusDAO;
import org.tela_botanica.client.modeles.dao.ListeReferentielLocaliteAsynchroneDAO;
import org.tela_botanica.client.modeles.dao.ListeReferentielNomAsynchroneDAO;
30,6 → 31,7
import org.tela_botanica.client.util.Util;
import org.tela_botanica.client.util.autocompletion.AutoCompletionComboBox;
 
import com.google.gwt.core.client.Callback;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.http.client.Response;
103,6 → 105,9
private String numeroOrdre = null;
private String referentielTaxo = null;
private String referentielGeo = null;
private Map<String, String> avertissementPresence = new HashMap<String, String>();
private boolean enRequeteChrologie = false;
 
// Pour remise a zero partielle lors d'une validation
 
330,11 → 335,13
public void onSelectionValeur() {
localiteModifiee = true;
surSelectionLocalite();
verifierPresenceTaxonSaisi();
}
@Override
protected void onModificationValeur() {
localiteModifiee = true;
verifierPresenceTaxonSaisi();
}
 
@Override
502,11 → 509,19
public void onSelectionValeur() {
especeModifiee = true;
surSelectionEspece();
verifierPresenceTaxonSaisi();
}
@Override
protected void onModificationValeur() {
especeModifiee = true;
// Pour éviter qu'un mauvais nn ne soit gardé lors d'une modification
// vers un nom ne faisant pas partie du référentiel
numeroNom = null;
if(referentielNom.containsKey(espece.getText())) {
numeroNom = referentielNom.get(espece.getText()).getNumeroNom();
}
verifierPresenceTaxonSaisi();
}
 
@Override
525,7 → 540,7
String valeurAffichee = nomValeur.getNom();
// Pour afficher les noms retenus en gras
if (nomValeur.estRetenu()) {
valeurAffichee = "<span class=\"nomRetenu\">" + nomValeur.getNom() + "</span>";
valeurAffichee = "<span class=\"nomRetenu\">"+nomValeur.getNom().trim()+"</span>";
}
return valeurAffichee;
}
1278,7 → 1293,7
if(infosCom != null && infosCom.getZoneGeo() != null && !infosCom.getZoneGeo().trim().isEmpty()) {
nlocalite += infosCom.getZoneGeo();
if(infosCom.getIdZoneGeo() != null && !infosCom.getIdZoneGeo().trim().isEmpty()) {
if(Util.estUnNombre(infosCom.getIdZoneGeo())) {
if(Util.estUnDepartement(infosCom.getIdZoneGeo())) {
nlocalite += " ("+Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo())+")";
} else if(infosCom.getPays() != null && !infosCom.getPays().trim().isEmpty()) {
nlocalite += " ("+infosCom.getPays()+")";
1339,7 → 1354,7
nlocalite += infosCom.getZoneGeo();
}
if(infosCom.getIdZoneGeo() != null && Util.estUnNombre(infosCom.getIdZoneGeo())) {
if(infosCom.getIdZoneGeo() != null && Util.estUnDepartement(infosCom.getIdZoneGeo())) {
String codeGeoFormate = Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo());
nlocalite += " ("+codeGeoFormate+")";
codeLocalite = Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo());
1456,7 → 1471,7
String codeLoc = codeCom[codeCom.length - 1].replace('(', ' ');
codeLoc = codeLoc.replace(')', ' ').trim().replace('\\',' ').trim();
 
if(Util.estUnNombre(codeLoc)) {
if(Util.estUnDepartement(codeLoc)) {
codeLocalite = codeLoc ;
} else {
pays = codeLoc.toUpperCase();
1507,7 → 1522,7
String codeLoc = codeCom[1].replace('(', ' ');
codeLoc = codeLoc.replace(')', ' ').trim().replace('\\',' ').trim();
 
if(Util.estUnNombre(codeLoc)) {
if(Util.estUnDepartement(codeLoc)) {
codeLocaliteM = codeLoc ;
} else {
paysM = codeLoc;
2202,16 → 2217,27
}
 
private void obtenirInformationLocalite() {
String idLoc = obtenirIdLocalite();
observationMediateur.obtenirInformationLocalite(getlocaliteSansIdLoc(), idLoc);
}
private String obtenirIdLocalite() {
String idLoc = "";
if(codeLocalite != null && !codeLocalite.isEmpty()) {
idLoc = codeLocalite;
} else {
idLoc = Util.obtenirIdLocAPartirChaineLocalite(localite.getText());
if(Util.estUnNombre(idLoc)) {
idLoc = Util.formaterDepartement(idLoc);
// Soit un numéro de département, soit un code de pays à deux lettres
String[] codeCom = localite.getText().split(" ");
if(codeCom.length > 1 && ressembleAUnCodePaysOuDepartement(codeCom[codeCom.length - 1])) {
String codeLoc = codeCom[codeCom.length - 1].replace('(', ' ');
codeLoc = codeLoc.replace(')', ' ').trim().replace('\\',' ').trim();
 
if(Util.estUnNombre(codeLoc)) {
idLoc = codeLoc ;
} else {
idLoc = codeLoc.toUpperCase();
}
}
observationMediateur.obtenirInformationLocalite(getlocaliteSansIdLoc(), idLoc);
return idLoc;
}
 
public double[] coordonneesValides() {
2302,4 → 2328,44
 
doLayout();
}
private void verifierPresenceTaxonSaisi() {
affecterCodeLocaliteOuPays();
if(!enRequeteChrologie && !codeLocalite.isEmpty() && numeroNom != null && !numeroNom.isEmpty()) {
enRequeteChrologie = true;
// Pour le moment, si on a un code localité, c'est qu'on est en France
final String paysStr = pays.isEmpty() ? "FR" : pays;
final String cleCache = numeroNom.trim()+paysStr.trim()+codeLocalite.trim();
 
// Pour éviter de vérifier et d'afficher plus d'une fois l'avertissement de présence
if(!avertissementPresence.containsKey(numeroNom.trim()+paysStr.trim()+codeLocalite.trim())) {
// Pour l'instant c'est toujours France mais il serait bon un jour d'avoir une chorologie multi pays.
// donc ça ne coute rien de le gérer déjà ici dans l'interface
ImageInformationRepartitionAsynchroneDAO.taxonEstPresentDansZoneGeo(referentielTaxo, numeroNom, paysStr, codeLocalite, new Callback<String, String>() {
@Override
public void onSuccess(String result) {
// En cas d'absence d'infos sur la zone le service retourne "" (chaîne vide)
// En cas de non signalement dans la zone, il retourne 0,
// En cas de présence, il retourne 1
if(result.equals("0")) {
// L'absence explicite est le seul cas qui nous interesse
String[] stParams = {espece.getText(), codeLocalite, Configuration.getChorologieAvertissementCourriel()};
String message = Msg.get("indication-premiere-presence", stParams);
Window.alert(message);
}
 
avertissementPresence.put(cleCache, result);
enRequeteChrologie = false;
}
@Override
public void onFailure(String reason) {
enRequeteChrologie = false;
}
});
}
}
}
}