Subversion Repositories eFlore/Applications.del

Rev

Rev 922 | Rev 1003 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 922 Rev 933
1
package org.tela_botanica.del.client.modeles;
1
package org.tela_botanica.del.client.modeles;
2
 
2
 
3
import java.io.Serializable;
3
import java.io.Serializable;
4
import java.util.HashMap;
4
import java.util.HashMap;
5
import java.util.Map;
5
import java.util.Map;
6
 
6
 
7
public class PropositionDetermination extends InterventionForum implements Serializable {
7
public class PropositionDetermination extends InterventionForum implements Serializable {
8
 
8
 
9
	private static final long serialVersionUID = 840032625524143547L;
9
	private static final long serialVersionUID = 840032625524143547L;
10
	private String id, espece, commentaire;
10
	private String id, espece, commentaire;
11
	private int nbCommentaires = 0;
11
	private int nbCommentaires = 0;
12
 
12
 
13
	private Map<String, VoteDetermination> votesDeterminations = new HashMap<String, VoteDetermination>();
13
	private Map<String, VoteDetermination> votesDeterminations = new HashMap<String, VoteDetermination>();
14
	private Observation observation;
14
	private Observation observation;
15
 
15
 
16
	public PropositionDetermination(String id, Contributeur contributeur, String texte) {
16
	public PropositionDetermination(String id, Contributeur contributeur, String texte) {
17
		setId(id);
17
		setId(id);
18
		setContributeur(contributeur);
18
		setContributeur(contributeur);
19
		setCommentaire(texte);
19
		setCommentaire(texte);
20
	}
20
	}
21
 
21
 
22
	public PropositionDetermination(Observation observation) {
22
	public PropositionDetermination(Observation observation) {
23
		this.observation = observation;
23
		this.observation = observation;
24
	}
24
	}
25
 
25
 
26
	public void ajouterVoteDetermination(VoteDetermination vd) {
26
	public void ajouterVoteDetermination(VoteDetermination vd) {
27
		votesDeterminations.put(vd.getContributeur(), vd);
27
		votesDeterminations.put(vd.getContributeur(), vd);
28
	}
28
	}
29
 
29
 
30
	public String getId() {
30
	public String getId() {
31
		return id;
31
		return id;
32
	}
32
	}
33
 
33
 
34
	public void setId(String id) {
34
	public void setId(String id) {
35
		this.id = id;
35
		this.id = id;
36
	}
36
	}
37
 
37
 
38
	public String getEspece() {
38
	public String getEspece() {
39
		return espece;
39
		return espece;
40
	}
40
	}
41
 
41
 
42
	public void setEspece(String espece) {
42
	public void setEspece(String espece) {
43
		this.espece = espece;
43
		this.espece = espece;
44
	}
44
	}
45
 
45
 
46
	public Map<String, VoteDetermination> getVotesDeterminations() {
46
	public Map<String, VoteDetermination> getVotesDeterminations() {
47
		return votesDeterminations;
47
		return votesDeterminations;
48
	}
48
	}
49
 
49
 
50
	public void setVotesDeterminations(Map<String, VoteDetermination> votesDeterminations) {
50
	public void setVotesDeterminations(Map<String, VoteDetermination> votesDeterminations) {
51
		this.votesDeterminations = votesDeterminations;
51
		this.votesDeterminations = votesDeterminations;
52
	}
52
	}
53
 
53
 
54
	public boolean utilisateurAVotePourDetermination(String idContributeur) {
54
	public boolean utilisateurAVotePourDetermination(String idContributeur) {
55
		return votesDeterminations.containsKey(idContributeur);
55
		return votesDeterminations.containsKey(idContributeur);
56
	}
56
	}
57
 
57
 
58
	public Observation getObservation() {
58
	public Observation getObservation() {
59
		return observation;
59
		return observation;
60
	}
60
	}
61
 
61
 
62
	public void setObservation(Observation observation) {
62
	public void setObservation(Observation observation) {
63
		this.observation = observation;
63
		this.observation = observation;
64
	}
64
	}
65
 
65
 
66
	public void setCommentaire(String commentaire) {
66
	public void setCommentaire(String commentaire) {
67
		this.commentaire = commentaire;
67
		this.commentaire = commentaire;
68
	}
68
	}
69
 
69
 
70
	public String getCommentaire() {
70
	public String getCommentaire() {
71
		return commentaire;
71
		return commentaire;
72
	}
72
	}
73
 
73
 
74
	public void setNbCommentaires(int nbCommentaires) {
74
	public void setNbCommentaires(int nbCommentaires) {
75
		this.nbCommentaires = nbCommentaires;
75
		this.nbCommentaires = nbCommentaires;
76
	}
76
	}
77
 
77
 
78
	public int getTotalCommentaires() {
78
	public int getTotalCommentaires() {
-
 
79
		// le nombre de commentaire peut avoir été renvoyé par le web service
-
 
80
		// sans que l'on possède la liste des commentaires elle même, auquel cas, il sera différent de 0
-
 
81
		// et ne doit pas être recalculé
79
		if (nbCommentaires == 0) {
82
		if (nbCommentaires == 0 && this.listeCommentaires.size() != 0) {
80
			nbCommentaires = super.getTotalCommentaires();
83
			nbCommentaires = super.getTotalCommentaires();
81
			if (this.getCommentaire() != null&&this.getCommentaire()!="") {
84
			if (this.getCommentaire() != null&&this.getCommentaire()!="") {
82
				nbCommentaires += 1;
85
				nbCommentaires += 1;
83
			}
86
			}
84
		}
87
		}
85
 
88
 
86
		return nbCommentaires;
89
		return nbCommentaires;
87
	}
90
	}
88
}
91
}