Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 87 Rev 89
Line 4... Line 4...
4
 
4
 
5
import org.tela_botanica.client.interfaces.Filtrable;
5
import org.tela_botanica.client.interfaces.Filtrable;
6
import org.tela_botanica.client.interfaces.Rafraichissable;
6
import org.tela_botanica.client.interfaces.Rafraichissable;
7
import org.tela_botanica.client.modeles.EntiteGeographiqueObservation;
7
import org.tela_botanica.client.modeles.EntiteGeographiqueObservation;
-
 
8
import org.tela_botanica.client.modeles.ListeEntiteGeographiqueObservation;
8
import org.tela_botanica.client.modeles.ListeEntiteGeographiqueObservation;
9
import org.tela_botanica.client.modeles.Observation;
Line 9... Line 10...
9
import org.tela_botanica.client.observation.ObservationMediateur;
10
import org.tela_botanica.client.observation.ObservationMediateur;
10
 
11
 
11
import com.google.gwt.core.client.GWT;
12
import com.google.gwt.core.client.GWT;
Line 228... Line 229...
228
			boolean repandreRaffraichissement) {
229
			boolean repandreRaffraichissement) {
Line 229... Line 230...
229
 
230
 
Line 230... Line 231...
230
 
231
 
231
		if (nouvelleDonnees instanceof ListeEntiteGeographiqueObservation) {
232
		if (nouvelleDonnees instanceof ListeEntiteGeographiqueObservation) {
232
		
233
		
Line 233... Line 234...
233
			String entite=null;
234
			String id_location=null;
Line 234... Line -...
234
			String idEntite=null;
-
 
235
			String idParent=null;
-
 
236
			
235
			String location=null;
237
			ListeEntiteGeographiqueObservation data = (ListeEntiteGeographiqueObservation) nouvelleDonnees ;
236
			String lieuDit=null;
238
		
237
			
239
			
238
			ListeEntiteGeographiqueObservation data = (ListeEntiteGeographiqueObservation) nouvelleDonnees ;
240
			if (data.isEmpty()) {
239
		
241
				// on crée un arbre vide
240
				// on crée un arbre vide
242
				TreeNode root = new TreeNode();
241
				TreeNode root = new TreeNode();
243
				root.setId("racine_entite");
-
 
244
				root.setText("Localités");
-
 
Line 245... Line 242...
245
				String[] usObj = { "Localités"};
242
				root.setId("racine_entite");
246
				root.setUserObject(usObj);
243
				root.setText("Localités");
Line 247... Line 244...
247
				donneeEntitesGeographiques.setRootNode(root);
244
				String[] usObjRoot = { "Localités"};
Line -... Line 245...
-
 
245
				root.setUserObject(usObjRoot);
-
 
246
				donneeEntitesGeographiques.setRootNode(root);
248
				
247
			
Line 249... Line 248...
249
			}
248
			// on la parse et on récupère les informations qui nous interessent
250
			
249
			for (Iterator<String> it= data.keySet().iterator(); it.hasNext();) {
251
			// on la parse et on récupère les informations qui nous interessent
250
				
Line 252... Line 251...
252
			for (Iterator<String> it= data.keySet().iterator(); it.hasNext();) {
251
				EntiteGeographiqueObservation ent=(EntiteGeographiqueObservation) data.get(it.next());
253
				
252
				
-
 
253
				id_location=ent.getIdLocation();
Line 254... Line -...
254
				EntiteGeographiqueObservation ent=(EntiteGeographiqueObservation) data.get(it.next());
-
 
-
 
254
				location=ent.getLocation();
255
				
255
				lieuDit=ent.getLieuDit();
-
 
256
				
256
				entite=ent.getEntite();
257
				if(id_location.contains("000null")) {
257
				
258
					id_location="Inconnue" ;
258
				if(entite.contains("000null")) {
259
				}
259
					entite="Inconnue" ;
260
				
-
 
261
				if(location.contains("000null")) {
260
				}
262
					location="Inconnue" ;
-
 
263
				}
261
				
264
				
-
 
265
				if(lieuDit.contains("000null")) {
262
				idEntite=ent.getIdEntite();
266
					lieuDit="Inconnue" ;
-
 
267
				}
263
				idParent=ent.getIdParent();
268
				
-
 
269
				Node noeudMemeId = donneeEntitesGeographiques.getNodeById(""+id_location);
264
				
270
				// si la région existe déjà
-
 
271
					if(noeudMemeId != null)
265
		
272
					{
-
 
273
						// on teste si la localité existe
266
				String[] usObj = { entite };
274
						Node noeudMemeLoc = donneeEntitesGeographiques.getNodeById(""+(id_location+location));
267
 
275
						if(noeudMemeLoc != null)
268
					// et on construit l'arbre à partir de la racine (qui est
276
						{
269
					// toujours le premier élément)
277
							// enfin on teste si le lieu dit existe
270
					if (entite.equals("racine_entite")) {
278
							Node noeudMemeLieu = donneeEntitesGeographiques.getNodeById(""+(id_location+location+lieuDit));
271
						TreeNode root = new TreeNode();
279
							if(noeudMemeLieu != null)
272
						root.setId(idEntite);
280
							{
-
 
281
								// tous les noeuds existent déjà, normalement ça ne devrait pas arriver
-
 
282
							}
273
						root.setText(entite);
283
							else
274
						root.setUserObject(usObj);
284
							{
-
 
285
								// enfin on ne crée que le noeud du lieu dit
-
 
286
								TreeNode node_lieu = new TreeNode();
-
 
287
								node_lieu.setId(""+(id_location+location+lieuDit));
-
 
288
								node_lieu.setText(lieuDit);
-
 
289
								noeudMemeLoc.appendChild(node_lieu) ;
275
						donneeEntitesGeographiques.setRootNode(root);
290
								String[] usObj = {lieuDit};
-
 
291
								node_lieu.setUserObject(usObj);
-
 
292
							}
-
 
293
						}
-
 
294
						else
276
					} else {
295
						{
-
 
296
							TreeNode node_loc = new TreeNode();
-
 
297
							node_loc.setId(""+(id_location+location));
-
 
298
							node_loc.setText(location);
277
						// et en ajoutant les noeuds un à un (qui sont renvoyé
299
							noeudMemeId.appendChild(node_loc) ;
278
						// dans l'ordre hierarchique de leur niveau
300
							String[] usObj = {location};
-
 
301
							node_loc.setUserObject(usObj);
-
 
302
							
-
 
303
							TreeNode node_lieu = new TreeNode();
-
 
304
							node_lieu.setId(""+(id_location+location+lieuDit));
-
 
305
							node_lieu.setText(lieuDit);
-
 
306
							node_loc.appendChild(node_lieu) ;
-
 
307
							String[] usObj2 = {lieuDit};
-
 
308
							node_lieu.setUserObject(usObj2);
-
 
309
							
-
 
310
						}
-
 
311
					}
-
 
312
					else
-
 
313
					{
-
 
314
						TreeNode node_id_loc = new TreeNode();
-
 
315
						node_id_loc.setId(""+id_location);
-
 
316
						node_id_loc.setText(id_location);
-
 
317
						root.appendChild(node_id_loc) ;
-
 
318
						String[] usObj = {id_location};
-
 
319
						node_id_loc.setUserObject(usObj);
-
 
320
						
-
 
321
						TreeNode node_loc = new TreeNode();
-
 
322
						node_loc.setId(""+(id_location+location));
279
						// ce qui permet de les traiter séquentiellement)
323
						node_loc.setText(location);
Line 280... Line 324...
280
						TreeNode node = new TreeNode();
324
						node_id_loc.appendChild(node_loc) ;
Line 281... Line 325...
281
						node.setId(idEntite);
325
						String[] usObj2 = {location};
282
						node.setText(entite);
326
						node_loc.setUserObject(usObj2);
283
						Node parentNode = donneeEntitesGeographiques.getNodeById(idParent);
327
						
284
						if(parentNode != null)
328
						TreeNode node_lieu = new TreeNode();
-
 
329
						node_lieu.setId(""+(id_location+location+lieuDit));
-
 
330
						node_lieu.setText(lieuDit);
-
 
331
						node_loc.appendChild(node_lieu) ;
-
 
332
						String[] usObj3 = {lieuDit};
-
 
333
						node_lieu.setUserObject(usObj3);
-
 
334
					}
Line -... Line 335...
-
 
335
 
-
 
336
				}
285
						{
337
			
-
 
338
				// on vide tous les noeuds
-
 
339
				arbreEntitesGeographiques.getRootNode().eachChild(new NodeTraversalCallback() {
-
 
340
	
-
 
341
					public boolean execute(Node node) {
286
							node.setUserObject(usObj);
342
	
287
							parentNode.appendChild(node);
343
						node.remove();
-
 
344
						return true;
-
 
345
					}
-
 
346
	
-
 
347
				});
-
 
348
 
Line 288... Line -...
288
						}
-
 
289
					}
-
 
290
				}
-
 
291
 
-
 
292
			}
-
 
293
			
-
 
294
			// on vide tous les noeuds
-
 
295
			arbreEntitesGeographiques.getRootNode().eachChild(new NodeTraversalCallback() {
-
 
296
 
-
 
297
				public boolean execute(Node node) {
-
 
298
 
349
				// et on recopie le nouvel arbre
299
					node.remove();
350
				copierFilsNoeud(donneeEntitesGeographiques.getRootNode(), arbreEntitesGeographiques
-
 
351
						.getRootNode());
-
 
352
	
-
 
353
				// si l'arbre n'était pas encore considéré comme instancié
-
 
354
				if (!estInstancie) {
-
 
355
					// on signale que oui
-
 
356
					estInstancie = true;
-
 
357
				}
-
 
358
	
-
 
359
				// l'état du filtre est réinitialisé
-
 
360
				filtreModifie = false;
-
 
361
				//show() ;
-
 
362
				doLayout();
-
 
363
 
-
 
364
			}
-
 
365
		
-
 
366
		if(nouvelleDonnees instanceof Observation)
-
 
367
		{			
-
 
368
			Observation obs = (Observation)nouvelleDonnees ;
-
 
369
			
-
 
370
			String id_location= obs.getIdentifiantLocalite();
-
 
371
			id_location.replaceAll("\"", "") ;
-
 
372
			String location=obs.getLocalite();
-
 
373
			String lieuDit=obs.getLieudit();
-
 
374
			
300
					return true;
375
			Node root = arbreEntitesGeographiques.getRootNode() ;
301
				}
376
			
-
 
377
			if(id_location.contains("000null") || id_location.equals(null)) {
-
 
378
				id_location="Inconnue" ;
-
 
379
			}
-
 
380
			
-
 
381
			if(location.contains("000null") || location.equals(null)) {
-
 
382
				location="Inconnue" ;
-
 
383
			}
-
 
384
			
-
 
385
			if(lieuDit.contains("000null") || lieuDit.equals(null)) {
-
 
386
				lieuDit="Inconnue" ;
-
 
387
			}
302
 
388
			
-
 
389
			Node noeudMemeId = donneeEntitesGeographiques.getNodeById(""+id_location);
-
 
390
			// si la région existe déjà
-
 
391
				if(noeudMemeId != null)
-
 
392
				{
-
 
393
					// on teste si la localité existe
-
 
394
					Node noeudMemeLoc = donneeEntitesGeographiques.getNodeById(""+(id_location+location));
-
 
395
					if(noeudMemeLoc != null)
-
 
396
					{
-
 
397
						// enfin on teste si le lieu dit existe
-
 
398
						Node noeudMemeLieu = donneeEntitesGeographiques.getNodeById(""+(id_location+location+lieuDit));
303
			});
399
						if(noeudMemeLieu != null)
-
 
400
						{
-
 
401
							// tous les noeuds existent déjà, normalement ça ne devrait pas arriver
-
 
402
						}
-
 
403
						else
-
 
404
						{
-
 
405
							// enfin on ne crée que le noeud du lieu dit
-
 
406
							TreeNode node_lieu = new TreeNode();
-
 
407
							node_lieu.setId(""+(id_location+location+lieuDit));
-
 
408
							node_lieu.setText(lieuDit);
-
 
409
							String[] usObj = {lieuDit};
-
 
410
							node_lieu.setUserObject(usObj);
-
 
411
							noeudMemeLoc.appendChild(node_lieu) ;
-
 
412
						}
-
 
413
					}
-
 
414
					else
-
 
415
					{
-
 
416
						TreeNode node_loc = new TreeNode();
-
 
417
						node_loc.setId(""+(id_location+location));
-
 
418
						node_loc.setText(location);
-
 
419
						String[] usObj = {location};
-
 
420
						node_loc.setUserObject(usObj);
-
 
421
						noeudMemeId.appendChild(node_loc) ;
-
 
422
						
-
 
423
						TreeNode node_lieu = new TreeNode();
-
 
424
						node_lieu.setId(""+(id_location+location+lieuDit));
-
 
425
						node_lieu.setText(lieuDit);
-
 
426
						String[] usObj2 = {lieuDit};
-
 
427
						node_lieu.setUserObject(usObj2);
-
 
428
						node_loc.appendChild(node_lieu) ;
-
 
429
						
-
 
430
					}
-
 
431
			}
-
 
432
			else
-
 
433
			{
-
 
434
				TreeNode node_id_loc = new TreeNode();
-
 
435
				node_id_loc.setId(""+id_location);
-
 
436
				node_id_loc.setText(id_location);
-
 
437
				String[] usObj = {id_location};
-
 
438
				node_id_loc.setUserObject(usObj);
-
 
439
				root.appendChild(node_id_loc) ;
-
 
440
				
-
 
441
				TreeNode node_loc = new TreeNode();
-
 
442
				node_loc.setId(""+(id_location+location));
304
 
443
				node_loc.setText(location);
305
			// et on recopie le nouvel arbre
-
 
306
			copierFilsNoeud(donneeEntitesGeographiques.getRootNode(), arbreEntitesGeographiques
-
 
307
					.getRootNode());
-
 
Line 308... Line 444...
308
 
444
				String[] usObj2 = {location};
309
			// si l'arbre n'était pas encore considéré comme instancié
445
				node_loc.setUserObject(usObj2);
310
			if (!estInstancie) {
446
				node_id_loc.appendChild(node_loc) ;