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; |
104,6 → 106,9 |
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 |
|
private enum Champs { |
330,11 → 335,13 |
public void onSelectionValeur() { |
localiteModifiee = true; |
surSelectionLocalite(); |
verifierPresenceTaxonSaisi(); |
} |
|
@Override |
protected void onModificationValeur() { |
localiteModifiee = true; |
verifierPresenceTaxonSaisi(); |
} |
|
@Override |
502,12 → 509,20 |
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 |
public void onValidationSaisie() { |
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; |
|
// 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 = Util.obtenirIdLocAPartirChaineLocalite(localite.getText()); |
if(Util.estUnNombre(idLoc)) { |
idLoc = Util.formaterDepartement(idLoc); |
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; |
} |
}); |
} |
} |
} |
} |