Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 887 Rev 901
Line 12... Line 12...
12
import org.tela_botanica.client.modeles.Personne;
12
import org.tela_botanica.client.modeles.Personne;
13
import org.tela_botanica.client.modeles.PersonneListe;
13
import org.tela_botanica.client.modeles.PersonneListe;
14
import org.tela_botanica.client.modeles.Publication;
14
import org.tela_botanica.client.modeles.Publication;
15
import org.tela_botanica.client.modeles.PublicationAPersonne;
15
import org.tela_botanica.client.modeles.PublicationAPersonne;
16
import org.tela_botanica.client.modeles.PublicationAPersonneListe;
16
import org.tela_botanica.client.modeles.PublicationAPersonneListe;
-
 
17
import org.tela_botanica.client.modeles.PublicationListe;
17
import org.tela_botanica.client.modeles.Structure;
18
import org.tela_botanica.client.modeles.Structure;
18
import org.tela_botanica.client.modeles.StructureListe;
19
import org.tela_botanica.client.modeles.StructureListe;
19
import org.tela_botanica.client.util.Pattern;
20
import org.tela_botanica.client.util.Pattern;
20
import org.tela_botanica.client.util.UtilArray;
21
import org.tela_botanica.client.util.UtilArray;
21
import org.tela_botanica.client.util.UtilString;
22
import org.tela_botanica.client.util.UtilString;
Line 39... Line 40...
39
 
40
 
Line 40... Line 41...
40
public class PublicationForm extends Formulaire implements Rafraichissable {
41
public class PublicationForm extends Formulaire implements Rafraichissable {
41
	
42
	
42
	private Publication publication;
43
	private Publication publication;
-
 
44
	private PublicationAPersonneListe publicationAPersonneListe = null;
-
 
45
	private static boolean publicationAPersonneListeChargementOk = false;
Line 43... Line 46...
43
	private PublicationAPersonneListe publicationAPersonneListe = null;
46
	private PublicationAPersonneListe auteursAjoutes = null;
44
	private boolean publicationAPersonneListeChargementOk = false;
47
	private PublicationAPersonneListe auteursSupprimes = null;
45
	
48
	
46
	private FieldSet auteursFieldset = null;
49
	private FieldSet auteursFieldset = null;
47
	private ArrayList<ComboBox<Personne>> auteurComboboxListe = null;
50
	private ArrayList<ComboBox<Personne>> auteurComboboxListe = null;
Line 48... Line 51...
48
	private LayoutContainer conteneurChamps;
51
	private LayoutContainer conteneurChamps;
49
	private ListStore<Personne> auteursStorePartage = null;
52
	private ListStore<Personne> auteursStorePartage = null;
50
	private boolean auteurStorePartageChargementOk = false;
53
	private static boolean auteurStorePartageChargementOk = false;
51
	
54
	
Line 60... Line 63...
60
	private TextField<String> tomeChp = null;
63
	private TextField<String> tomeChp = null;
61
	private TextField<String> fasciculeChp = null;
64
	private TextField<String> fasciculeChp = null;
62
	private TextField<String> pagesChp = null;
65
	private TextField<String> pagesChp = null;
Line 63... Line 66...
63
	
66
	
64
	private String idStructureEdition = ""; 
-
 
Line 65... Line 67...
65
	private String idAuteurs = "";
67
	private String idStructureEdition = ""; 
66
 
68
 
67
	private boolean formulaireValideOk = false;
69
	private static boolean formulaireValideOk = false;
-
 
70
	private static boolean publicationValideOk = false;
-
 
71
	private static boolean auteursValideOk = false;
Line 68... Line 72...
68
	private boolean publicationValideOk = false;
72
	private static boolean attenteAjoutAuteursOk = true;
69
	private boolean auteursValideOk = false;
73
	private static boolean attenteSuppressionAuteursOk = true;
70
 
74
 
Line 76... Line 80...
76
		vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
80
		vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
77
		initialiserPublicationForm(mediateurCourrant, publicationId);
81
		initialiserPublicationForm(mediateurCourrant, publicationId);
78
	}
82
	}
Line 79... Line 83...
79
	
83
	
-
 
84
	private void initialiserPublicationForm(Mediateur mediateurCourrant, String publicationId) {
-
 
85
		initialiserValidation();
-
 
86
		initialiserAffichageAuteurs();
80
	private void initialiserPublicationForm(Mediateur mediateurCourrant, String publicationId) {
87
		
81
		publication = new Publication();
88
		publication = new Publication();
Line 82... Line 89...
82
		publication.setId(publicationId);
89
		publication.setId(publicationId);
83
		
90
		
Line 155... Line 162...
155
		final HorizontalPanel panneauHorizontal = new HorizontalPanel();
162
		final HorizontalPanel panneauHorizontal = new HorizontalPanel();
156
		panneauHorizontal.setLayout(new FormLayout());
163
		panneauHorizontal.setLayout(new FormLayout());
Line 157... Line 164...
157
		
164
		
158
		final ComboBox<Personne> auteursSaisisComboBox = creerComboBoxAuteursSaisis();
165
		final ComboBox<Personne> auteursSaisisComboBox = creerComboBoxAuteursSaisis();
159
		if (auteur != null) {
166
		if (auteur != null) {
160
			GWT.log(auteur.getId(), null);
167
			GWT.log("Auteur peuplé : "+auteur.getId(), null);
-
 
168
			auteursSaisisComboBox.setValue(auteursStorePartage.findModel("id_personne", auteur.getId()));
161
			auteursSaisisComboBox.setValue(auteursStorePartage.findModel("id_personne", auteur.getId()));
169
			auteursSaisisComboBox.validate();
162
		}
170
		}
163
		auteurComboboxListe.add(auteursSaisisComboBox);
171
		auteurComboboxListe.add(auteursSaisisComboBox);
-
 
172
		auteursSaisisComboBox.setFieldLabel("Auteur "+auteurComboboxListe.size());
Line 164... Line 173...
164
		auteursSaisisComboBox.setFieldLabel("Auteur "+auteurComboboxListe.size());
173
		GWT.log("Nbre de combobox auteur dans liste : "+auteurComboboxListe.size(), null);
165
		
174
		
166
		LayoutContainer panneauChampTxtEtBouton = new LayoutContainer();
175
		LayoutContainer panneauChampTxtEtBouton = new LayoutContainer();
167
		panneauChampTxtEtBouton.setLayout(new FormLayout());
176
		panneauChampTxtEtBouton.setLayout(new FormLayout());
Line 283... Line 292...
283
		} else {
292
		} else {
284
			GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
293
			GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
285
		}
294
		}
Line 286... Line 295...
286
		
295
		
-
 
296
		if (etrePretAAfficherAuteurs()) {
287
		if (etrePretAAfficherAuteurs()) {
297
			initialiserAffichageAuteurs();
288
			afficherAuteurs();
298
			afficherAuteurs();
Line 289... Line 299...
289
		}
299
		}
290
		
300
		
291
		if (etreValide()) {
301
		if (etreValide()) {
292
			initialiserValidation();
302
			initialiserValidation();
293
			repandreRafraichissement();
303
			repandreRafraichissement();
294
			controlerFermetureApresRafraichissement();
304
			controlerFermetureApresRafraichissement();
295
		}
305
		}
-
 
306
	}
-
 
307
	
-
 
308
	private void miseAJourPublicationAPersonneListe() {
-
 
309
		GWT.log("Mise à jour liste publication à personne", null);
-
 
310
		Iterator<String> clesAjoutees = auteursAjoutes.keySet().iterator();
-
 
311
		while (clesAjoutees.hasNext()) {
-
 
312
			String id = clesAjoutees.next();
-
 
313
			publicationAPersonneListe.put(id, auteursAjoutes.get(id));
-
 
314
			GWT.log("Auteurs ajouté :"+publicationAPersonneListe.get(id).getPersonne().getNomComplet(), null);
-
 
315
		}
-
 
316
		
-
 
317
		Iterator<String> clesSupprimees = auteursSupprimes.keySet().iterator();
-
 
318
		while (clesSupprimees.hasNext()) {
-
 
319
			String id = clesSupprimees.next();
-
 
320
			publicationAPersonneListe.remove(id);
-
 
321
			GWT.log("Personne surpprimé :"+id, null);
-
 
322
		}
-
 
323
		GWT.log("Nbre auteurs après maj :"+publicationAPersonneListe.size(), null);
296
	}
324
	}
297
 
325
	
298
	private void rafraichirPublication(Publication publi) {
326
	private void rafraichirPublication(Publication publi) {
299
		publication = publi;
327
		publication = publi;
Line 327... Line 355...
327
		} else if (info.getType().equals("publication_valide")) {
355
		} else if (info.getType().equals("publication_valide")) {
328
			publicationValideOk = true;
356
			publicationValideOk = true;
329
			publication.setId((String) info.getDonnee(0));
357
			publication.setId((String) info.getDonnee(0));
Line 330... Line 358...
330
			
358
			
331
			if (mode.equals(Formulaire.MODE_AJOUTER)) {
-
 
332
				mediateur.ajouterPublicationAPersonne(this, publication.getId(), idAuteurs, PublicationAPersonne.ROLE_AUTEUR);
359
			if (mode.equals(Formulaire.MODE_AJOUTER)) {
333
			} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
360
				attenteAjoutAuteursOk = true;
334
				mediateur.modifierPublicationAPersonne(this, publication.getId(), idAuteurs, PublicationAPersonne.ROLE_AUTEUR);
361
				mediateur.ajouterPublicationAPersonne(this, publication.getId(), auteursAjoutes, PublicationAPersonne.ROLE_AUTEUR);
335
			}
362
			}
-
 
363
		} else if (info.getType().equals("ajout_publication_a_personne")) {
-
 
364
			attenteAjoutAuteursOk = false;
-
 
365
			GWT.log("attenteAjoutAuteursOk", null);
-
 
366
		} else if (info.getType().equals("suppression_publication_a_personne")) {
-
 
367
			attenteSuppressionAuteursOk = false;
-
 
368
			GWT.log("attenteSuppressionAuteursOk", null);
-
 
369
		}
-
 
370
		
336
		} else if (info.getType().equals("auteur_valide")) {
371
		if (avoirAuteursMiseAJourCorrectement()) {
-
 
372
			auteursValideOk = true;
-
 
373
			miseAJourPublicationAPersonneListe();
337
			auteursValideOk = true;
374
			initialiserAuteurs();
338
		}
375
		}
Line -... Line 376...
-
 
376
	}
-
 
377
	
-
 
378
	private boolean avoirAuteursMiseAJourCorrectement() {
-
 
379
		boolean ok = false;
-
 
380
		if (attenteAjoutAuteursOk == false && attenteSuppressionAuteursOk == false) {
-
 
381
			ok = true;
-
 
382
		}
-
 
383
		return ok;
339
	}
384
	}
340
	
385
	
-
 
386
	private void afficherAuteurs() {
341
	private void afficherAuteurs() {
387
		Iterator<String> itap = publicationAPersonneListe.keySet().iterator();
342
		Iterator<String> itap = publicationAPersonneListe.keySet().iterator();
388
		GWT.log("Auteur"+publicationAPersonneListe.size(), null);
343
		while (itap.hasNext()) {
389
		while (itap.hasNext()) {
344
			creerChampAuteurEtBoutonSupprimer(publicationAPersonneListe.get(itap.next()).getPersonne());
-
 
345
		}
390
			creerChampAuteurEtBoutonSupprimer(publicationAPersonneListe.get(itap.next()).getPersonne());
Line 346... Line 391...
346
		initialiserAffichageAuteurs();
391
		}
347
	}
392
	}
348
 
393
 
Line 369... Line 414...
369
	}
414
	}
Line 370... Line 415...
370
	
415
	
371
	private void initialiserValidation() {
416
	private void initialiserValidation() {
372
		formulaireValideOk = false;
417
		formulaireValideOk = false;
-
 
418
		publicationValideOk = false;
373
		publicationValideOk = false;
419
		initialiserAuteurs();
374
		auteursValideOk = false;
420
		auteursValideOk = false;
Line -... Line 421...
-
 
421
	}
-
 
422
	
-
 
423
	private void initialiserAuteurs() {
-
 
424
		attenteAjoutAuteursOk = true;
-
 
425
		auteursAjoutes = new PublicationAPersonneListe();
-
 
426
		attenteSuppressionAuteursOk = true;
-
 
427
		auteursSupprimes = new PublicationAPersonneListe();
375
	}
428
	}
376
	
429
	
377
	private void repandreRafraichissement() {
430
	private void repandreRafraichissement() {
378
		if (vueExterneARafraichirApresValidation != null) {
431
		if (vueExterneARafraichirApresValidation != null) {
379
			String type = "publication_modifiee";
432
			String type = "publication_modifiee";
Line 388... Line 441...
388
	
441
	
389
	public boolean soumettreFormulaire() {
442
	public boolean soumettreFormulaire() {
390
		formulaireValideOk = verifierFormulaire();
443
		formulaireValideOk = verifierFormulaire();
391
		GWT.log("Form?"+formulaireValideOk, null);
444
		GWT.log("Form?"+formulaireValideOk, null);
-
 
445
		if (formulaireValideOk) {
-
 
446
			soumettrePublication();
-
 
447
			soumettreAuteurs();
-
 
448
		}
-
 
449
		return formulaireValideOk;
-
 
450
	}
-
 
451
	
392
		if (formulaireValideOk) {
452
	private void soumettrePublication() {
393
			Publication publicationCollectee = collecterPublication();
453
		Publication publicationCollectee = collecterPublication();
394
			if (publicationCollectee != null) {
454
		if (publicationCollectee != null) {
395
				GWT.log("Info collectée ? ok", null);
455
			GWT.log("Info public collectée ? ok", null);
396
				if (mode.equals(Formulaire.MODE_AJOUTER)) {
456
			if (mode.equals(Formulaire.MODE_AJOUTER)) {
397
					mediateur.ajouterPublication(this, publicationCollectee);
457
				mediateur.ajouterPublication(this, publicationCollectee);
398
				} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
458
			} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
-
 
459
				mediateur.modifierPublication(this, publicationCollectee);
-
 
460
			}
-
 
461
		}
-
 
462
	}
-
 
463
	
-
 
464
	private void soumettreAuteurs() {
-
 
465
		attenteAjoutAuteursOk = false;
-
 
466
		attenteSuppressionAuteursOk = false;
-
 
467
		
-
 
468
		PersonneListe personnesInitiales = new PersonneListe();
-
 
469
		if (publicationAPersonneListe != null) {
-
 
470
			GWT.log("Nbre auteur initial :"+publicationAPersonneListe.size(), null);
-
 
471
			Iterator<String> itap = publicationAPersonneListe.keySet().iterator();
-
 
472
			while (itap.hasNext()) {
-
 
473
				Personne personne = publicationAPersonneListe.get(itap.next()).getPersonne();
-
 
474
				GWT.log("Auteur initial :"+personne.getNomComplet(), null);
-
 
475
				personnesInitiales.put(personne.getId(), personne);
-
 
476
			}
-
 
477
		}
-
 
478
		
-
 
479
		PersonneListe personnesActuelles = new PersonneListe();
-
 
480
		GWT.log("Nbre auteur actuel :"+auteurComboboxListe.size(), null);
-
 
481
		for (int i = 0; i < auteurComboboxListe.size(); i++) {
-
 
482
			if (auteurComboboxListe.get(i).getValue() != null) {
-
 
483
				Personne personne = auteurComboboxListe.get(i).getValue();
-
 
484
				personnesActuelles.put(personne.getId(), personne);
-
 
485
			}
-
 
486
		}
-
 
487
		
-
 
488
		// Auteurs ajoutés
-
 
489
		Iterator<String> clesActuelles = personnesActuelles.keySet().iterator();
-
 
490
		while (clesActuelles.hasNext()) {
-
 
491
			String idActuel = clesActuelles.next();
-
 
492
			if (personnesInitiales.size() == 0 || personnesInitiales.get(idActuel) == null) {
-
 
493
				Personne personne = personnesActuelles.get(idActuel);
-
 
494
				GWT.log("Auteur ajouté :"+personne.getNomComplet(), null);
-
 
495
				PublicationAPersonne publicationAAuteur = new PublicationAPersonne();
-
 
496
				if (mode.equals(Formulaire.MODE_MODIFIER)) {
399
					mediateur.modifierPublication(this, publicationCollectee);
497
					publicationAAuteur.setIdPublication(publication.getId());
-
 
498
				}
-
 
499
				publicationAAuteur.setPersonne(personne);
-
 
500
				publicationAAuteur.setIdRole(PublicationAPersonne.ROLE_AUTEUR);
-
 
501
				auteursAjoutes.put(publicationAAuteur.getId(), publicationAAuteur);
-
 
502
				attenteAjoutAuteursOk = true;
-
 
503
			}
-
 
504
		}
-
 
505
 
-
 
506
		// Auteurs supprimés
-
 
507
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
-
 
508
			Iterator<String> clesInitiales = personnesInitiales.keySet().iterator();
-
 
509
			while (clesInitiales.hasNext()) {
-
 
510
				String idInitial = clesInitiales.next();
-
 
511
				if (personnesActuelles.size() == 0 || personnesActuelles.get(idInitial) == null) {
-
 
512
					Personne personne = personnesInitiales.get(idInitial);
-
 
513
					GWT.log("Auteur supprimé :"+personne.getNomComplet(), null);
-
 
514
					PublicationAPersonne publicationAAuteur = new PublicationAPersonne();
-
 
515
					publicationAAuteur.setIdPublication(publication.getId());
-
 
516
					publicationAAuteur.setPersonne(personne);
-
 
517
					publicationAAuteur.setIdRole(PublicationAPersonne.ROLE_AUTEUR);
-
 
518
					auteursSupprimes.put(publicationAAuteur.getId(), publicationAAuteur);
-
 
519
					attenteSuppressionAuteursOk = true;
-
 
520
				}
-
 
521
			}
-
 
522
		}
-
 
523
		
-
 
524
		// Execution de les mise à jour pour le mode MODIFICATION
-
 
525
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
-
 
526
			if (auteursAjoutes != null && auteursAjoutes.size() != 0) {
-
 
527
				mediateur.ajouterPublicationAPersonne(this, publication.getId(), auteursAjoutes, PublicationAPersonne.ROLE_AUTEUR);
-
 
528
			}
-
 
529
			
-
 
530
			if (auteursSupprimes != null && auteursSupprimes.size() != 0) {
400
				}
531
				mediateur.supprimerPublicationAPersonne(this, auteursSupprimes);
401
			}
532
			}
402
		}
-
 
403
		return formulaireValideOk;
533
		}
Line 404... Line 534...
404
	}
534
	}
405
	
535
	
406
	protected boolean verifierFormulaire() {
536
	protected boolean verifierFormulaire() {
Line 477... Line 607...
477
		String auteurIntituleFormate = "";
607
		String auteurIntituleFormate = "";
478
		int auteursNombre = auteurComboboxListe.size();
608
		int auteursNombre = auteurComboboxListe.size();
479
		for (int i = 0; i < auteursNombre; i++) {
609
		for (int i = 0; i < auteursNombre; i++) {
480
			if (auteurComboboxListe.get(i).getValue() != null) {
610
			if (auteurComboboxListe.get(i).getValue() != null) {
481
				Personne auteur = auteurComboboxListe.get(i).getValue();
611
				Personne auteur = auteurComboboxListe.get(i).getValue();
482
				idAuteurs += auteur.getId();
-
 
483
				auteurIntituleFormate += auteur.getNom()+ " "+auteur.getPrenom();
612
				auteurIntituleFormate += auteur.getNom()+ " "+auteur.getPrenom();
484
				if (i != (auteursNombre - 1)) {
613
				if (i != (auteursNombre - 1)) {
485
					auteurIntituleFormate += ", ";
614
					auteurIntituleFormate += ", ";
486
					idAuteurs += ",";
-
 
487
				}
615
				}
488
			}
616
			}
489
		}
617
		}
490
		GWT.log("Auteurs formaté :"+auteurIntituleFormate, null);
618
		GWT.log("Auteurs formaté :"+auteurIntituleFormate, null);
491
		GWT.log("Auteurs ids :"+idAuteurs, null);
-
 
492
		publicationCollectee.setAuteur(auteurIntituleFormate);
619
		publicationCollectee.setAuteur(auteurIntituleFormate);
Line 493... Line 620...
493
		
620
		
494
		String titre = titreChp.getValue();
621
		String titre = titreChp.getValue();