New file |
0,0 → 1,133 |
package org.tela_botanica.del.client.modeles; |
|
import java.util.ArrayList; |
import java.util.Date; |
import java.util.Iterator; |
import java.util.List; |
public class InterventionForum { |
|
private Contributeur contributeur; |
private Date date; |
private String id, idParent; |
private InterventionForum parent; |
private Observation observation; |
public List<Commentaire> listeCommentaires = new ArrayList<Commentaire>(); |
boolean estAffichee; |
|
public void setId(String id) { |
this.id = id; |
} |
|
public String getId() { |
return id; |
} |
|
public String getIdParent() { |
return idParent; |
} |
|
public void afficher() { |
this.estAffichee = true; |
} |
|
public boolean estAffichee() { |
return this.estAffichee; |
} |
|
public void setIdParent(String idParent) { |
this.idParent = idParent; |
} |
|
public void setParent(InterventionForum parent) { |
this.parent = parent; |
} |
|
public boolean estFils() { |
return (this.parent != null); |
} |
|
public InterventionForum getParent() { |
return parent; |
} |
|
public void setObservation(Observation observation) { |
this.observation = observation; |
} |
|
public Observation getObservation() { |
return observation; |
} |
|
public String getAuteur() { |
return contributeur.getNomComplet(); |
} |
|
public void setContributeur(Contributeur contributeur) { |
this.contributeur = contributeur; |
} |
|
public Contributeur getContributeur() { |
return contributeur; |
} |
|
public Date getDate() { |
return date; |
} |
|
public void setDate(Date date) { |
this.date = date; |
} |
|
public List<Commentaire> getListeCommentaires() { |
return listeCommentaires; |
} |
|
public void setListeCommentaires(List<Commentaire> listeCommentaires) { |
this.listeCommentaires = listeCommentaires; |
} |
|
public void ajouterCommentaire(Commentaire commentaire) { |
listeCommentaires.add(commentaire); |
} |
|
public boolean aDesCommentaires() { |
return (listeCommentaires.size() != 0); |
} |
|
public void supprimerIntervention(InterventionForum intervention) { |
if(listeCommentaires.contains(intervention)) { |
listeCommentaires.remove(intervention); |
} else { |
for (Iterator<Commentaire> iterator = listeCommentaires.iterator(); iterator.hasNext();) { |
iterator.next().supprimerIntervention(intervention); |
} |
} |
} |
|
public PropositionDetermination getPropositionParenteOuNulle() { |
InterventionForum parent = getParent(); |
PropositionDetermination proposition = null; |
while(parent != null && !(parent instanceof PropositionDetermination)) { |
parent = parent.getParent(); |
} |
if(parent != null) { |
proposition = (PropositionDetermination)parent; |
} |
return proposition; |
} |
|
public int getTotalCommentaires() { |
int nbCommentaires = 0; |
for (Commentaire commentaire : listeCommentaires) { |
chargerNbCommentairesRecursivement(nbCommentaires, commentaire); |
} |
return nbCommentaires; |
} |
|
private void chargerNbCommentairesRecursivement(int nbCommentaires, Commentaire commentaire) { |
nbCommentaires ++; |
for (Commentaire commentaireFils: commentaire.getListeCommentaires()) { |
chargerNbCommentairesRecursivement(nbCommentaires, commentaireFils); |
} |
} |
} |