Subversion Repositories eFlore/Applications.del

Rev

Rev 1001 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1001 Rev 1003
1
package org.tela_botanica.del.client.modeles;
1
package org.tela_botanica.del.client.modeles;
2
 
2
 
3
import java.util.ArrayList;
3
import java.util.ArrayList;
4
import java.util.Date;
4
import java.util.Date;
5
import java.util.Iterator;
5
import java.util.Iterator;
6
import java.util.List;
6
import java.util.List;
7
public class InterventionForum {
7
public class InterventionForum {
8
	
8
	
9
	private Contributeur contributeur;
9
	private Contributeur contributeur;
10
	private Date date;
10
	private Date date;
11
	private String id, idParent;
11
	private String id, idParent;
12
	private InterventionForum parent;
12
	private InterventionForum parent;
13
	private Observation observation;
13
	private Observation observation;
14
	public List<Commentaire> listeCommentaires = new ArrayList<Commentaire>();
14
	public List<Commentaire> listeCommentaires = new ArrayList<Commentaire>();
15
	boolean estAffichee;
15
	boolean estAffichee;
16
	
16
	
17
	public void setId(String id) {
17
	public void setId(String id) {
18
		this.id = id;
18
		this.id = id;
19
	}
19
	}
20
	
20
	
21
	public String getId() {
21
	public String getId() {
22
		return id;
22
		return id;
23
	}
23
	}
24
	
24
	
25
	public String getIdParent() {
25
	public String getIdParent() {
26
		return idParent;
26
		return idParent;
27
	}
27
	}
28
 
28
 
29
	public void afficher() {
29
	public void afficher() {
30
		this.estAffichee = true;
30
		this.estAffichee = true;
31
	}
31
	}
32
	
32
	
33
	public boolean estAffichee() {
33
	public boolean estAffichee() {
34
		return this.estAffichee;
34
		return this.estAffichee;
35
	}
35
	}
36
	
36
	
37
	public void setIdParent(String idParent) {
37
	public void setIdParent(String idParent) {
38
		this.idParent = idParent;
38
		this.idParent = idParent;
39
	}
39
	}
40
	
40
	
41
	public void setParent(InterventionForum parent) {
41
	public void setParent(InterventionForum parent) {
42
		this.parent = parent;
42
		this.parent = parent;
43
	}
43
	}
44
	
44
	
45
	public boolean estFils() {
45
	public boolean estFils() {
46
		return (this.parent != null);
46
		return (this.parent != null);
47
	}
47
	}
48
	
48
	
49
	public InterventionForum getParent() {
49
	public InterventionForum getParent() {
50
		return parent;
50
		return parent;
51
	}
51
	}
52
	
52
	
53
	public void setObservation(Observation observation) {
53
	public void setObservation(Observation observation) {
54
		this.observation = observation;
54
		this.observation = observation;
55
	}
55
	}
56
	
56
	
57
	public Observation getObservation() {
57
	public Observation getObservation() {
58
		return observation;
58
		return observation;
59
	}
59
	}
60
	
60
	
61
	public String getAuteur() {
61
	public String getAuteur() {
62
		return contributeur.getNomComplet();
62
		return contributeur.getNomComplet();
63
	}
63
	}
64
 
64
 
65
	public void setContributeur(Contributeur contributeur) {
65
	public void setContributeur(Contributeur contributeur) {
66
		this.contributeur = contributeur;
66
		this.contributeur = contributeur;
67
	}
67
	}
68
	
68
	
69
	public Contributeur getContributeur() {
69
	public Contributeur getContributeur() {
70
		return contributeur;
70
		return contributeur;
71
	}
71
	}
72
	
72
	
73
	public Date getDate() {
73
	public Date getDate() {
74
		return date;
74
		return date;
75
	}
75
	}
76
 
76
 
77
	public void setDate(Date date) {
77
	public void setDate(Date date) {
78
		this.date = date;
78
		this.date = date;
79
	}
79
	}
80
 
80
 
81
	public List<Commentaire> getListeCommentaires() {
81
	public List<Commentaire> getListeCommentaires() {
82
		return listeCommentaires;
82
		return listeCommentaires;
83
	}
83
	}
84
 
84
 
85
	public void setListeCommentaires(List<Commentaire> listeCommentaires) {
85
	public void setListeCommentaires(List<Commentaire> listeCommentaires) {
86
		this.listeCommentaires = listeCommentaires;
86
		this.listeCommentaires = listeCommentaires;
87
	}
87
	}
88
 
88
 
89
	public void ajouterCommentaire(Commentaire commentaire) {
89
	public void ajouterCommentaire(Commentaire commentaire) {
90
		listeCommentaires.add(commentaire);
90
		listeCommentaires.add(commentaire);
91
	}
91
	}
92
	
92
	
93
	public boolean aDesCommentaires() {
93
	public boolean aDesCommentaires() {
94
		return (listeCommentaires.size() != 0);
94
		return (listeCommentaires.size() != 0);
95
	}
95
	}
96
	
96
	
97
	public void supprimerIntervention(InterventionForum intervention) {
97
	public void supprimerIntervention(InterventionForum intervention) {
98
		if(listeCommentaires.contains(intervention)) {
98
		if(listeCommentaires.contains(intervention)) {
99
			listeCommentaires.remove(intervention);
99
			listeCommentaires.remove(intervention);
100
		} else {
100
		} else {
101
			for (Iterator<Commentaire> iterator = listeCommentaires.iterator(); iterator.hasNext();) {
101
			for (Iterator<Commentaire> iterator = listeCommentaires.iterator(); iterator.hasNext();) {
102
				iterator.next().supprimerIntervention(intervention);
102
				iterator.next().supprimerIntervention(intervention);
103
			}
103
			}
104
		}
104
		}
105
	}
105
	}
106
	
106
	
107
	public PropositionDetermination getPropositionParenteOuNulle() {
107
	public PropositionDetermination getPropositionParenteOuNulle() {
108
		InterventionForum parent = getParent();
108
		InterventionForum parent = getParent();
109
		PropositionDetermination proposition = null;
109
		PropositionDetermination proposition = null;
110
		while(parent != null && !(parent instanceof PropositionDetermination)) {
110
		while(parent != null && !(parent instanceof PropositionDetermination)) {
111
			parent = parent.getParent();
111
			parent = parent.getParent();
112
		}
112
		}
113
		if(parent != null) {
113
		if(parent != null) {
114
			proposition = (PropositionDetermination)parent;
114
			proposition = (PropositionDetermination)parent;
115
		}
115
		}
116
		return proposition;
116
		return proposition;
117
	}
117
	}
118
	
118
	
119
	public int getTotalCommentaires() {
119
	public int getTotalCommentaires() {
120
		int nbCommentaires = 0;
120
		int nbCommentaires = 0;
121
		for (Iterator<Commentaire> iterator = listeCommentaires.iterator(); iterator.hasNext();) {
-
 
122
			nbCommentaires++;
-
 
123
			Commentaire commentaire = (Commentaire) iterator.next();
121
		for (Commentaire commentaire : listeCommentaires) {
124
			nbCommentaires += commentaire.getTotalCommentaires();
122
			chargerNbCommentairesRecursivement(nbCommentaires, commentaire);
125
		}
123
		}
126
		
-
 
127
		return nbCommentaires;
124
		return nbCommentaires;
128
	}
125
	}
-
 
126
 
-
 
127
	private void chargerNbCommentairesRecursivement(int nbCommentaires, Commentaire commentaire) {
-
 
128
		nbCommentaires ++;
-
 
129
		for (Commentaire commentaireFils: commentaire.getListeCommentaires()) {
-
 
130
			chargerNbCommentairesRecursivement(nbCommentaires, commentaireFils);
-
 
131
		}
-
 
132
	}
129
}
133
}