Subversion Repositories eFlore/Applications.del

Rev

Details | Last modification | View Log | RSS feed

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