Subversion Repositories eFlore/Applications.cel

Rev

Rev 2644 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2644 Rev 2695
Line 9... Line 9...
9
import java.util.Map;
9
import java.util.Map;
Line 10... Line 10...
10
 
10
 
11
import org.tela_botanica.client.CarnetEnLigneMediateur;
11
import org.tela_botanica.client.CarnetEnLigneMediateur;
12
import org.tela_botanica.client.i18n.Msg;
12
import org.tela_botanica.client.i18n.Msg;
-
 
13
import org.tela_botanica.client.interfaces.Rafraichissable;
13
import org.tela_botanica.client.interfaces.Rafraichissable;
14
import org.tela_botanica.client.modeles.dao.ImageInformationRepartitionAsynchroneDAO;
14
import org.tela_botanica.client.modeles.dao.ListeReferentielChampsEtendusDAO;
15
import org.tela_botanica.client.modeles.dao.ListeReferentielChampsEtendusDAO;
15
import org.tela_botanica.client.modeles.dao.ListeReferentielLocaliteAsynchroneDAO;
16
import org.tela_botanica.client.modeles.dao.ListeReferentielLocaliteAsynchroneDAO;
16
import org.tela_botanica.client.modeles.dao.ListeReferentielNomAsynchroneDAO;
17
import org.tela_botanica.client.modeles.dao.ListeReferentielNomAsynchroneDAO;
17
import org.tela_botanica.client.modeles.dao.ListeReferentielPersoAsynchroneDAO;
18
import org.tela_botanica.client.modeles.dao.ListeReferentielPersoAsynchroneDAO;
Line 28... Line 29...
28
import org.tela_botanica.client.util.ChampSaisieEtendu;
29
import org.tela_botanica.client.util.ChampSaisieEtendu;
29
import org.tela_botanica.client.util.FormulaireSaisieChampEtendu;
30
import org.tela_botanica.client.util.FormulaireSaisieChampEtendu;
30
import org.tela_botanica.client.util.Util;
31
import org.tela_botanica.client.util.Util;
31
import org.tela_botanica.client.util.autocompletion.AutoCompletionComboBox;
32
import org.tela_botanica.client.util.autocompletion.AutoCompletionComboBox;
Line -... Line 33...
-
 
33
 
32
 
34
import com.google.gwt.core.client.Callback;
33
import com.google.gwt.event.dom.client.ClickEvent;
35
import com.google.gwt.event.dom.client.ClickEvent;
34
import com.google.gwt.event.dom.client.ClickHandler;
36
import com.google.gwt.event.dom.client.ClickHandler;
35
import com.google.gwt.http.client.Response;
37
import com.google.gwt.http.client.Response;
36
import com.google.gwt.user.client.Timer;
38
import com.google.gwt.user.client.Timer;
Line 101... Line 103...
101
	
103
	
102
	private String numeroNom = null;
104
	private String numeroNom = null;
103
	private String numeroOrdre = null;
105
	private String numeroOrdre = null;
104
	private String referentielTaxo = null;
106
	private String referentielTaxo = null;
-
 
107
	private String referentielGeo = null;
-
 
108
	
-
 
109
	private Map<String, String> avertissementPresence = new HashMap<String, String>();
Line 105... Line 110...
105
	private String referentielGeo = null;
110
	private boolean enRequeteChrologie = false;
Line 106... Line 111...
106
 
111
 
107
	// Pour remise a zero partielle lors d'une validation
112
	// Pour remise a zero partielle lors d'une validation
Line 328... Line 333...
328
			
333
			
329
			@Override
334
			@Override
330
			public void onSelectionValeur() {
335
			public void onSelectionValeur() {
331
				localiteModifiee = true;
336
				localiteModifiee = true;
-
 
337
				surSelectionLocalite();
332
				surSelectionLocalite();
338
				verifierPresenceTaxonSaisi();
Line 333... Line 339...
333
			}
339
			}
334
			
340
			
335
			@Override
341
			@Override
-
 
342
			protected void onModificationValeur() {
336
			protected void onModificationValeur() {
343
				localiteModifiee = true;	
Line 337... Line 344...
337
				localiteModifiee = true;	
344
				verifierPresenceTaxonSaisi();
338
			}
345
			}
339
 
346
 
Line 500... Line 507...
500
			
507
			
501
			@Override
508
			@Override
502
			public void onSelectionValeur() {
509
			public void onSelectionValeur() {
503
				especeModifiee = true;
510
				especeModifiee = true;
-
 
511
				surSelectionEspece();
504
				surSelectionEspece();
512
				verifierPresenceTaxonSaisi();
Line 505... Line 513...
505
			}
513
			}
506
			
514
			
507
			@Override
515
			@Override
-
 
516
			protected void onModificationValeur() {
-
 
517
				especeModifiee = true;	
-
 
518
				// Pour éviter qu'un mauvais nn ne soit gardé lors d'une modification
-
 
519
				// vers un nom ne faisant pas partie du référentiel
-
 
520
				numeroNom = null;
-
 
521
				if(referentielNom.containsKey(espece.getText())) {
-
 
522
					numeroNom = referentielNom.get(espece.getText()).getNumeroNom();
508
			protected void onModificationValeur() {
523
				}
Line 509... Line 524...
509
				especeModifiee = true;	
524
				verifierPresenceTaxonSaisi();
510
			}
525
			}
511
 
526
 
Line 523... Line 538...
523
			protected String preTraiterValeurAvantAffichage(String valeur) {
538
			protected String preTraiterValeurAvantAffichage(String valeur) {
524
				ReferentielNom nomValeur = referentielNom.get(valeur);
539
				ReferentielNom nomValeur = referentielNom.get(valeur);
525
				String valeurAffichee = nomValeur.getNom();
540
				String valeurAffichee = nomValeur.getNom();
526
				// Pour afficher les noms retenus en gras
541
				// Pour afficher les noms retenus en gras
527
				if (nomValeur.estRetenu()) {
542
				if (nomValeur.estRetenu()) {
528
					valeurAffichee = "<span class=\"nomRetenu\">" + nomValeur.getNom() + "</span>";
543
					valeurAffichee = "<span class=\"nomRetenu\">"+nomValeur.getNom().trim()+"</span>";
529
				}
544
				}
530
				return valeurAffichee;
545
				return valeurAffichee;
531
			}
546
			}
532
	    };
547
	    };
Line 1276... Line 1291...
1276
 
1291
 
1277
		String nlocalite = "";
1292
		String nlocalite = "";
1278
		if(infosCom != null && infosCom.getZoneGeo() != null && !infosCom.getZoneGeo().trim().isEmpty()) {
1293
		if(infosCom != null && infosCom.getZoneGeo() != null && !infosCom.getZoneGeo().trim().isEmpty()) {
1279
			nlocalite += infosCom.getZoneGeo();
1294
			nlocalite += infosCom.getZoneGeo();
1280
			if(infosCom.getIdZoneGeo() != null && !infosCom.getIdZoneGeo().trim().isEmpty()) {
1295
			if(infosCom.getIdZoneGeo() != null && !infosCom.getIdZoneGeo().trim().isEmpty()) {
1281
				if(Util.estUnNombre(infosCom.getIdZoneGeo())) {
1296
				if(Util.estUnDepartement(infosCom.getIdZoneGeo())) {
1282
					nlocalite += " ("+Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo())+")";
1297
					nlocalite += " ("+Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo())+")";
1283
				} else if(infosCom.getPays() != null && !infosCom.getPays().trim().isEmpty()) {
1298
				} else if(infosCom.getPays() != null && !infosCom.getPays().trim().isEmpty()) {
1284
					nlocalite += " ("+infosCom.getPays()+")";
1299
					nlocalite += " ("+infosCom.getPays()+")";
1285
				}
1300
				}
Line 1337... Line 1352...
1337
 
1352
 
1338
		if(infosCom.getZoneGeo() != null && !infosCom.getZoneGeo().equals("")) {
1353
		if(infosCom.getZoneGeo() != null && !infosCom.getZoneGeo().equals("")) {
1339
			nlocalite += infosCom.getZoneGeo();
1354
			nlocalite += infosCom.getZoneGeo();
Line 1340... Line 1355...
1340
		}
1355
		}
1341
		
1356
		
1342
		if(infosCom.getIdZoneGeo() != null && Util.estUnNombre(infosCom.getIdZoneGeo())) {
1357
		if(infosCom.getIdZoneGeo() != null && Util.estUnDepartement(infosCom.getIdZoneGeo())) {
1343
			String codeGeoFormate = Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo());
1358
			String codeGeoFormate = Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo());
1344
			nlocalite += " ("+codeGeoFormate+")";
1359
			nlocalite += " ("+codeGeoFormate+")";
1345
			codeLocalite = Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo());
1360
			codeLocalite = Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo());
Line 1454... Line 1469...
1454
		String[] codeCom = localite.getText().split(" ");
1469
		String[] codeCom = localite.getText().split(" ");
1455
		if(codeCom.length > 1 && ressembleAUnCodePaysOuDepartement(codeCom[codeCom.length - 1])) {
1470
		if(codeCom.length > 1 && ressembleAUnCodePaysOuDepartement(codeCom[codeCom.length - 1])) {
1456
			String codeLoc = codeCom[codeCom.length - 1].replace('(', ' ');
1471
			String codeLoc = codeCom[codeCom.length - 1].replace('(', ' ');
1457
			codeLoc = codeLoc.replace(')', ' ').trim().replace('\\',' ').trim();
1472
			codeLoc = codeLoc.replace(')', ' ').trim().replace('\\',' ').trim();
Line 1458... Line 1473...
1458
 
1473
 
1459
			if(Util.estUnNombre(codeLoc)) {
1474
			if(Util.estUnDepartement(codeLoc)) {
1460
				codeLocalite = codeLoc ;
1475
				codeLocalite = codeLoc ;
1461
			} else {
1476
			} else {
1462
				pays = codeLoc.toUpperCase();
1477
				pays = codeLoc.toUpperCase();
1463
			}
1478
			}
Line 1505... Line 1520...
1505
			String[] codeCom = localite.getText().split(" ");
1520
			String[] codeCom = localite.getText().split(" ");
1506
			if(codeCom.length > 1) {
1521
			if(codeCom.length > 1) {
1507
				String codeLoc = codeCom[1].replace('(', ' ');
1522
				String codeLoc = codeCom[1].replace('(', ' ');
1508
				codeLoc = codeLoc.replace(')', ' ').trim().replace('\\',' ').trim();
1523
				codeLoc = codeLoc.replace(')', ' ').trim().replace('\\',' ').trim();
Line 1509... Line 1524...
1509
 
1524
 
1510
				if(Util.estUnNombre(codeLoc)) {
1525
				if(Util.estUnDepartement(codeLoc)) {
1511
					codeLocaliteM = codeLoc ;
1526
					codeLocaliteM = codeLoc ;
1512
				} else {
1527
				} else {
1513
					paysM = codeLoc;
1528
					paysM = codeLoc;
1514
				}
1529
				}
Line 2200... Line 2215...
2200
			}
2215
			}
2201
		}
2216
		}
2202
	}
2217
	}
Line 2203... Line 2218...
2203
 
2218
 
-
 
2219
	private void obtenirInformationLocalite() {
-
 
2220
		String idLoc = obtenirIdLocalite();
-
 
2221
		observationMediateur.obtenirInformationLocalite(getlocaliteSansIdLoc(), idLoc);
-
 
2222
	}
-
 
2223
	
2204
	private void obtenirInformationLocalite() {
2224
	private String obtenirIdLocalite() {
-
 
2225
		String idLoc = "";
2205
		String idLoc = "";
2226
		
2206
		if(codeLocalite != null && !codeLocalite.isEmpty()) {
2227
		// Soit un numéro de département, soit un code de pays à deux lettres
-
 
2228
		String[] codeCom = localite.getText().split(" ");
2207
			idLoc = codeLocalite;
2229
		if(codeCom.length > 1 && ressembleAUnCodePaysOuDepartement(codeCom[codeCom.length - 1])) {
2208
		} else {
2230
			String codeLoc = codeCom[codeCom.length - 1].replace('(', ' ');
-
 
2231
			codeLoc = codeLoc.replace(')', ' ').trim().replace('\\',' ').trim();
2209
			idLoc = Util.obtenirIdLocAPartirChaineLocalite(localite.getText());
2232
 
-
 
2233
			if(Util.estUnNombre(codeLoc)) {
-
 
2234
				idLoc = codeLoc ;
2210
			if(Util.estUnNombre(idLoc)) {
2235
			} else {
2211
				idLoc = Util.formaterDepartement(idLoc);
2236
				idLoc = codeLoc.toUpperCase();
2212
			}
2237
			}
-
 
2238
		}
2213
		}
2239
		
2214
		observationMediateur.obtenirInformationLocalite(getlocaliteSansIdLoc(), idLoc);
2240
		return idLoc;
Line 2215... Line 2241...
2215
	}
2241
	}
2216
 
2242
 
Line 2300... Line 2326...
2300
		panneauSecondeColonne.doLayout();
2326
		panneauSecondeColonne.doLayout();
2301
		panneauIntermediaire.doLayout();
2327
		panneauIntermediaire.doLayout();
Line 2302... Line 2328...
2302
 
2328
 
2303
		doLayout();
2329
		doLayout();
-
 
2330
	}
-
 
2331
	
-
 
2332
	private void verifierPresenceTaxonSaisi() {
-
 
2333
		affecterCodeLocaliteOuPays();
-
 
2334
		if(!enRequeteChrologie && !codeLocalite.isEmpty() && numeroNom != null && !numeroNom.isEmpty()) {
-
 
2335
			enRequeteChrologie = true;
-
 
2336
			// Pour le moment, si on a un code localité, c'est qu'on est en France
-
 
2337
			final String paysStr = pays.isEmpty() ? "FR" : pays;
-
 
2338
			final String cleCache = numeroNom.trim()+paysStr.trim()+codeLocalite.trim();
-
 
2339
 
-
 
2340
			// Pour éviter de vérifier et d'afficher plus d'une fois l'avertissement de présence
-
 
2341
			if(!avertissementPresence.containsKey(numeroNom.trim()+paysStr.trim()+codeLocalite.trim())) {
-
 
2342
				// Pour l'instant c'est toujours France mais il serait bon un jour d'avoir une chorologie multi pays.
-
 
2343
				// donc ça ne coute rien de le gérer déjà ici dans l'interface
-
 
2344
				ImageInformationRepartitionAsynchroneDAO.taxonEstPresentDansZoneGeo(referentielTaxo, numeroNom, paysStr, codeLocalite, new Callback<String, String>() {			
-
 
2345
					@Override
-
 
2346
					public void onSuccess(String result) {
-
 
2347
						
-
 
2348
						// En cas d'absence d'infos sur la zone le service retourne "" (chaîne vide)
-
 
2349
						// En cas de non signalement dans la zone, il retourne 0, 
-
 
2350
						// En cas de présence, il retourne 1 
-
 
2351
						if(result.equals("0")) {
-
 
2352
							// L'absence explicite est le seul cas qui nous interesse
-
 
2353
							String[] stParams = {espece.getText(), codeLocalite, Configuration.getChorologieAvertissementCourriel()};
-
 
2354
							String message = Msg.get("indication-premiere-presence", stParams);
-
 
2355
							
-
 
2356
							Window.alert(message);
-
 
2357
						}
-
 
2358
 
-
 
2359
						avertissementPresence.put(cleCache, result);
-
 
2360
						enRequeteChrologie = false;
-
 
2361
					}
-
 
2362
					
-
 
2363
					@Override
-
 
2364
					public void onFailure(String reason) {
-
 
2365
						enRequeteChrologie = false;
-
 
2366
					}
-
 
2367
				});
-
 
2368
			}
-
 
2369
		}
2304
	}
2370
	}