package org.tela_botanica.client;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import org.tela_botanica.client.configuration.Configuration;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Utilisateur;
import org.tela_botanica.client.modeles.UtilisateurAsyncDao;
import org.tela_botanica.client.modeles.ValeurListeAsyncDao;
import org.tela_botanica.client.modeles.collection.Collection;
import org.tela_botanica.client.modeles.collection.CollectionACommentaire;
import org.tela_botanica.client.modeles.collection.CollectionACommentaireAsyncDao;
import org.tela_botanica.client.modeles.collection.CollectionAPersonne;
import org.tela_botanica.client.modeles.collection.CollectionAPersonneAsyncDao;
import org.tela_botanica.client.modeles.collection.CollectionAPublication;
import org.tela_botanica.client.modeles.collection.CollectionAPublicationAsyncDao;
import org.tela_botanica.client.modeles.collection.CollectionAsyncDao;
import org.tela_botanica.client.modeles.commentaire.Commentaire;
import org.tela_botanica.client.modeles.commentaire.CommentaireAsyncDao;
import org.tela_botanica.client.modeles.personne.Personne;
import org.tela_botanica.client.modeles.personne.PersonneAsyncDao;
import org.tela_botanica.client.modeles.projet.Projet;
import org.tela_botanica.client.modeles.projet.ProjetAsyncDao;
import org.tela_botanica.client.modeles.publication.Publication;
import org.tela_botanica.client.modeles.publication.PublicationAPersonne;
import org.tela_botanica.client.modeles.publication.PublicationAPersonneAsyncDao;
import org.tela_botanica.client.modeles.publication.PublicationAsyncDao;
import org.tela_botanica.client.modeles.structure.Structure;
import org.tela_botanica.client.modeles.structure.StructureAPersonne;
import org.tela_botanica.client.modeles.structure.StructureAPersonneAsyncDao;
import org.tela_botanica.client.modeles.structure.StructureAsyncDao;
import org.tela_botanica.client.modeles.structure.StructureConservation;
import org.tela_botanica.client.modeles.structure.StructureValorisation;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;

import com.extjs.gxt.ui.client.Registry;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;

// TODO : le transformer en SINGLETON
public class Modele {

	public Modele() {
		Registry.register(RegistreId.MODELE, this);
	}

	//+----------------------------------------------------------------------------------------------------------------+
	//												GESTION DES VALEURS ET LISTES
	//+----------------------------------------------------------------------------------------------------------------+
	public void obtenirListeValeurs(Rafraichissable vue, Integer id, Integer seqId) {
		ValeurListeAsyncDao lsDao = new ValeurListeAsyncDao(vue);
		lsDao.obtenirListe(id, seqId);
	}

	public void obtenirListeValeurs(Rafraichissable vue, String type, int id, Integer seqId) {
		ValeurListeAsyncDao lsDao = new ValeurListeAsyncDao(vue);
		lsDao.obtenirListe(type, String.valueOf(id), seqId);
	}	
	
	public void obtenirListeValeurs(Rafraichissable vue, Integer listId, boolean pagination, String recherche, int start, int nbElements, Integer seqId) {
		ValeurListeAsyncDao lsDao = new ValeurListeAsyncDao(vue);
		lsDao.obtenirListe(listId, pagination, recherche, start, nbElements, seqId);
	}

	public void obtenirListeValeurs(Rafraichissable vue, String type, String id, Integer seqId) {
		ValeurListeAsyncDao lsDao = new ValeurListeAsyncDao(vue);
		lsDao.obtenirListe(type, String.valueOf(id), seqId);
	}	
	
	public void obtenirListeRegion(Rafraichissable vue, Integer id, String region) {
		ValeurListeAsyncDao lsDao = new ValeurListeAsyncDao(vue);
		lsDao.selectionner("abv", id, region, null, null);
	}
	
	public void obtenirValeur(Rafraichissable vue, String type, Integer id, String identifiant, Integer seqId) {
		ValeurListeAsyncDao lsDao = new ValeurListeAsyncDao(vue);
		lsDao.selectionner(type, id, null, identifiant, seqId);
	}
	
	//+----------------------------------------------------------------------------------------------------------------+
	//												GESTION DES UTILISATEURS
	//+----------------------------------------------------------------------------------------------------------------+
	
	public void connecterUtilisateur(Rafraichissable vue, String login, String mdp) {
		Utilisateur utilisateur = (Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT);
		utilisateur.setLogin(login);
		utilisateur.setMotDePasse(mdp);
		UtilisateurAsyncDao uDao = new UtilisateurAsyncDao(vue);
		uDao.connecterUtilisateur();		
	}
	
	public void deconnecterUtilisateur(Rafraichissable vue) {
		UtilisateurAsyncDao uDao = new UtilisateurAsyncDao(vue);
		uDao.deconnecterUtilisateur();		
	}
	
	public void accepterLicence(Rafraichissable vue)	{
		UtilisateurAsyncDao uDao = new UtilisateurAsyncDao(vue);
		uDao.accepterLicence();
		
	}
	
	public void modifierUtilisateur(Rafraichissable vueARafraichir, Utilisateur utilisateur)	{
		PersonneAsyncDao pAdao = new PersonneAsyncDao(vueARafraichir);
		
		Personne personne = new Personne();
		personne.setId(utilisateur.getId());
		personne.setPrenom(utilisateur.getPrenom());
		personne.setNom(utilisateur.getNom());
		personne.setNomComplet(utilisateur.getNomComplet());
		personne.setParametre(utilisateur.getParametre());
		
		pAdao.modifier(personne);
	}
	
	//+----------------------------------------------------------------------------------------------------------------+
	//												GESTION DES PROJETS
	//+----------------------------------------------------------------------------------------------------------------+
	
	public void selectionnerProjet(Rafraichissable vueARafraichir, String projetId, String nom, int start, int nbElements, String formatRetour, boolean paginationProgressive, Integer seqId) {
		ProjetAsyncDao pADAO = new ProjetAsyncDao(vueARafraichir);
		pADAO.selectionner(paginationProgressive, projetId, nom, start, nbElements, formatRetour, seqId);
	}
	
	public void selectionnerProjet(Rafraichissable vueARafraichir, String recherche, int start, int nbElements, Integer seqId) {
		ProjetAsyncDao pADAO = new ProjetAsyncDao(vueARafraichir);
		pADAO.selectionner(true, null, recherche, start, nbElements, null, seqId);
	}

	public void ajouterProjet(Rafraichissable vueARafraichir, Projet projetCollecte) {
		ProjetAsyncDao pADAO = new ProjetAsyncDao(vueARafraichir);
		pADAO.ajouter(projetCollecte);
	}

	public void modifierProjet(Rafraichissable vueARafraichir, Projet projetCollecte) {
		ProjetAsyncDao pADAO = new ProjetAsyncDao(vueARafraichir);
		pADAO.modifier(projetCollecte);
	}

	//+----------------------------------------------------------------------------------------------------------------+
	//												GESTION DES STRUCTURES
	//+----------------------------------------------------------------------------------------------------------------+

	public void selectionnerStructure(Rafraichissable vueARafraichir, String projetId, String structureId, String nomStructure, int start, int nbElements, Integer seqId, boolean searchCity) {
		// Gestion des données des tables coel_structure, coel_structure_conservation et coel_structure_valorisation 
		StructureAsyncDao sDao = new StructureAsyncDao(vueARafraichir);
		sDao.selectionner(false, projetId, structureId, nomStructure, null, start, nbElements, seqId, searchCity);
	}
	
	public void selectionnerStructureAvecPaginationProgressive(Rafraichissable vueARafraichir, String projetId, String structureId, String nomStructure, String formatRetour, int start, int nbElements, Integer seqId, boolean searchCity) {
		// Gestion des données des tables coel_structure, coel_structure_conservation et coel_structure_valorisation 
		StructureAsyncDao sDao = new StructureAsyncDao(vueARafraichir);
		sDao.selectionner(true, projetId, structureId, nomStructure, formatRetour, start, nbElements, seqId, searchCity);
	}
	
	public void selectionnerStructure(Rafraichissable vueARafraichir, String recherche, int start, int nbElements, Integer seqId, boolean searchCity) {
		// Gestion des données des tables coel_structure, coel_structure_conservation et coel_structure_valorisation 
		StructureAsyncDao sDao = new StructureAsyncDao(vueARafraichir);
		sDao.selectionner(true, null, null, recherche, null, start, nbElements, seqId, searchCity);
	}
	
	/** Lance la creation d'une Structure
	 * @param vueARafraichir la vue demandant a être rafraichie
	 * @param structure les données de la structure
	 */
	public void ajouterStructure(Rafraichissable vueARafraichir, Structure structure, StructureConservation conservation, StructureValorisation valorisation) {
		StructureAsyncDao structureDao = new StructureAsyncDao(vueARafraichir);
		structureDao.ajouter(structure, conservation, valorisation);
	}

	public void supprimerStructure(Rafraichissable vueARafraichir, String idStr) {
		StructureAsyncDao structureDao = new StructureAsyncDao(vueARafraichir);
		structureDao.supprimer(idStr);
	}
	
	public void modifierStructure(Rafraichissable vueARafraichir, String structureId, Structure structure, StructureConservation conservation, StructureValorisation valorisation) {
		StructureAsyncDao structureDao = new StructureAsyncDao(vueARafraichir);
		structureDao.modifier(structureId, structure, conservation, valorisation);
	}

	//+----------------------------------------------------------------------------------------------------------------+
	// GESTION de la relation STRUCTURE A PERSONNE
	
	public void selectionnerStructureAPersonne(Rafraichissable vueARafraichir, String structureId, String roleId, Integer seqId) {
		// Gestion des données de la table coel_structure_a_personne
		if (structureId != null && roleId != null) {
			StructureAPersonneAsyncDao sapDao = new StructureAPersonneAsyncDao(vueARafraichir);
			sapDao.selectionner(false, structureId, roleId, null, 0, -1, seqId);
		}
	}
	
	public void selectionnerStructureAPersonne(Rafraichissable vueARafraichir, String structureId, String roleId, String recherche, int start, int nbElements, Integer seqId) {
		StructureAPersonneAsyncDao sapDao = new StructureAPersonneAsyncDao(vueARafraichir);
		sapDao.selectionner(true, structureId, roleId, recherche, start, nbElements, seqId);
	}
	
	public void modifierStructureAPersonne(Rafraichissable vueARafraichir, StructureAPersonne personnel) {
		StructureAPersonneAsyncDao structureAPersonneDao = new StructureAPersonneAsyncDao(vueARafraichir);
		structureAPersonneDao.modifier(personnel);
	}
	
	public void ajouterStructureAPersonne(Rafraichissable vueARafraichir, String structureId, StructureAPersonne personnel) {
		StructureAPersonneAsyncDao structureAPersonneDao = new StructureAPersonneAsyncDao(vueARafraichir);
		structureAPersonneDao.ajouter(structureId, personnel);	
	}
	
	public void supprimerStructureAPersonne(Rafraichissable vueARafraichir, String personnelId) {
		StructureAPersonneAsyncDao structureAPersonneDao = new StructureAPersonneAsyncDao(vueARafraichir);
		structureAPersonneDao.supprimer(personnelId);
	}

	//+----------------------------------------------------------------------------------------------------------------+
	//												GESTION DES COLLECTIONS
	//+----------------------------------------------------------------------------------------------------------------+
	
	public void selectionnerCollection(Rafraichissable vueARafraichir, String projetId, String collectionId, String nom, int start, int nbElements, Integer seqId) {
		CollectionAsyncDao cDao = new CollectionAsyncDao(vueARafraichir);
		cDao.selectionner(false, projetId, collectionId, nom, start, nbElements, seqId);
	}
	
	public void selectionnerCollection(Rafraichissable vueARafraichir, String recherche, int start, int nbElements, Integer seqId) {
		CollectionAsyncDao cDao = new CollectionAsyncDao(vueARafraichir);
		cDao.selectionner(true, null, null, recherche, start, nbElements, seqId);
	}
	
	public void ajouterCollection(Rafraichissable vueARafraichir, Collection collection) {
		CollectionAsyncDao cDao = new CollectionAsyncDao(vueARafraichir);
		cDao.ajouter(collection);
	}

	public void modifierCollection(Rafraichissable vueARafraichir, Collection collection) {
		CollectionAsyncDao cDao = new CollectionAsyncDao(vueARafraichir);
		cDao.modifier(collection);
	}

	public void supprimerCollection(Rafraichissable vueARafraichir, String identifiantsCollectionSepareParVirgule) {
		CollectionAsyncDao cDao = new CollectionAsyncDao(vueARafraichir);
		cDao.supprimer(identifiantsCollectionSepareParVirgule);
	}
	
	//+----------------------------------------------------------------------------------------------------------------+
	// GESTION de la relation COLLECTION A PERSONNE
	
	public void selectionnerCollectionAPersonne(Rafraichissable vueARafraichir, String collectionId, String roleId, String recherche, int start, int nbElements, Integer seqId) {
		CollectionAPersonneAsyncDao sapDao = new CollectionAPersonneAsyncDao(vueARafraichir);
		sapDao.selectionner(true, collectionId, roleId, recherche, start, nbElements, seqId);
	}
	
	public void selectionnerCollectionAPersonne(Rafraichissable vueARafraichir, String collectionId, String roleId, Integer seqId) {
		CollectionAPersonneAsyncDao sapDao = new CollectionAPersonneAsyncDao(vueARafraichir);
		sapDao.selectionner(false, collectionId, roleId, null, 0, -1, seqId);
	}
	
	public void modifierCollectionAPersonne(Rafraichissable vueARafraichir, CollectionAPersonne collectionAPersonne) {
		CollectionAPersonneAsyncDao collectionAPersonneDao = new CollectionAPersonneAsyncDao(vueARafraichir);
		collectionAPersonneDao.modifier(collectionAPersonne);
	}
	
	public void ajouterCollectionAPersonne(Rafraichissable vueARafraichir, String collectionId, CollectionAPersonne collectionAPersonne) {
		CollectionAPersonneAsyncDao collectionAPersonneDao = new CollectionAPersonneAsyncDao(vueARafraichir);
		collectionAPersonneDao.ajouter(collectionId, collectionAPersonne);	
	}
	
	public void supprimerCollectionAPersonne(Rafraichissable vueARafraichir, String collectionAPersonneId) {
		CollectionAPersonneAsyncDao collectionAPersonneDao = new CollectionAPersonneAsyncDao(vueARafraichir);
		collectionAPersonneDao.supprimer(collectionAPersonneId);
	}
	
	//+----------------------------------------------------------------------------------------------------------------+
	// GESTION de la relation COLLECTION A PUBLICATION

	public void selectionnerCollectionAPublication(Rafraichissable vueARafraichir, String collectionId, String recherche, int start, int nbElements, Integer seqId) {
		CollectionAPublicationAsyncDao capDao = new CollectionAPublicationAsyncDao(vueARafraichir);
		capDao.selectionner(true, collectionId, recherche, start, nbElements, seqId);
	}
	
	public void selectionnerCollectionAPublication(Rafraichissable vueARafraichir, String collectionId, Integer seqId) {
		CollectionAPublicationAsyncDao capDao = new CollectionAPublicationAsyncDao(vueARafraichir);
		capDao.selectionner(false, collectionId, null, 0, -1, seqId);
	}
	
	public void modifierCollectionAPublication(Rafraichissable vueARafraichir, CollectionAPublication collectionAPublication) {
		CollectionAPublicationAsyncDao collectionAPublicationDao = new CollectionAPublicationAsyncDao(vueARafraichir);
		collectionAPublicationDao.modifier(collectionAPublication);
	}
	
	public void ajouterCollectionAPublication(Rafraichissable vueARafraichir, String collectionId, CollectionAPublication collectionAPublication) {
		CollectionAPublicationAsyncDao collectionAPublicationDao = new CollectionAPublicationAsyncDao(vueARafraichir);
		collectionAPublicationDao.ajouter(collectionId, collectionAPublication);	
	}
	
	public void supprimerCollectionAPublication(Rafraichissable vueARafraichir, String collectionAPublicationId) {
		CollectionAPublicationAsyncDao collectionAPublicationDao = new CollectionAPublicationAsyncDao(vueARafraichir);
		collectionAPublicationDao.supprimer(collectionAPublicationId);
	}

	//+----------------------------------------------------------------------------------------------------------------+
	// GESTION de la relation COLLECTION A COMMENTAIRE
	
	public void selectionnerCollectionACommentaire(Rafraichissable vueARafraichir, String collectionId, Integer seqId) {
		CollectionACommentaireAsyncDao cacDao = new CollectionACommentaireAsyncDao(vueARafraichir);
		cacDao.selectionner(false, collectionId, null, 0, -1, seqId);
	}
	
	public void selectionnerCollectionACommentaire(Rafraichissable vueARafraichir, String collectionId, String recherche, int start, int nbElements, Integer seqId) {
		CollectionACommentaireAsyncDao cacDao = new CollectionACommentaireAsyncDao(vueARafraichir);
		cacDao.selectionner(true, collectionId, recherche, start, nbElements, seqId);
	}
	
	public void modifierCollectionACommentaire(Rafraichissable vueARafraichir, CollectionACommentaire collectionACommentaire) {
		CollectionACommentaireAsyncDao cacDao = new CollectionACommentaireAsyncDao(vueARafraichir);
		cacDao.modifier(collectionACommentaire);
	}
	
	public void ajouterCollectionACommentaire(Rafraichissable vueARafraichir, String collectionId, CollectionACommentaire collectionACommentaire) {
		CollectionACommentaireAsyncDao cacDao = new CollectionACommentaireAsyncDao(vueARafraichir);
		cacDao.ajouter(collectionId, collectionACommentaire);	
	}
	
	public void supprimerCollectionACommentaire(Rafraichissable vueARafraichir, String collectionACommentaireId, String mode) {
		CollectionACommentaireAsyncDao cacDao = new CollectionACommentaireAsyncDao(vueARafraichir);
		cacDao.supprimer(collectionACommentaireId, mode);
	}
	
	//+----------------------------------------------------------------------------------------------------------------+
	//												GESTION DES PERSONNES
	//+----------------------------------------------------------------------------------------------------------------+
	public void selectionnerPersonne(Rafraichissable vueARafraichir, String personneId, String projetId, String nomComplet, int start, int nbElements) {
		selectionnerPersonne(vueARafraichir, personneId, projetId, nomComplet, start, nbElements, null);
	}
	
	public void selectionnerPersonne(Rafraichissable vueARafraichir, String personneId, String projetId, String nomComplet, int start, int nbElements, Integer seqId) {
		PersonneAsyncDao pDao = new PersonneAsyncDao(vueARafraichir);
		pDao.selectionner(false, personneId, projetId, nomComplet, start, nbElements, seqId);
	}
	
	public void selectionnerPersonne(Rafraichissable vueARafraichir, String recherche, int start, int nbElements, Integer seqId) {
		PersonneAsyncDao pDao = new PersonneAsyncDao(vueARafraichir);
		pDao.selectionner(true, null, null, recherche, start, nbElements, seqId);
	}

	public void supprimerPersonne(Rafraichissable vueARafraichir, String idPersonneSepareParVirgule) {
		PersonneAsyncDao personneDao = new PersonneAsyncDao(vueARafraichir);
		personneDao.supprimer(idPersonneSepareParVirgule);
	}
	
	public void ajouterPersonne(Rafraichissable vue, Personne personne)	{
		PersonneAsyncDao personneDao = new PersonneAsyncDao(vue);
		personneDao.ajouter(personne);
	}
	
	public void modifierPersonne(Rafraichissable vueARafraichir, Personne personne)	{
		PersonneAsyncDao personneDao = new PersonneAsyncDao(vueARafraichir);
		personneDao.modifier(personne);
	}

	//+----------------------------------------------------------------------------------------------------------------+
	//												GESTION DES PUBLICATIONS
	//+----------------------------------------------------------------------------------------------------------------+
	
	public void selectionnerPublication(Rafraichissable vueARafraichir, String publicationId, String projetId, String nomComplet, int pageCourante, int nbElements, Integer seqId) {
		PublicationAsyncDao lsDao = new PublicationAsyncDao(vueARafraichir);
		lsDao.selectionner(false, publicationId, projetId, nomComplet, pageCourante, nbElements, seqId);
	}
	
	public void selectionnerPublication(Rafraichissable vueARafraichir, String recherche, int start, int nbElements, Integer seqId) {
		PublicationAsyncDao lsDao = new PublicationAsyncDao(vueARafraichir);
		lsDao.selectionner(true, null, null, recherche, start, nbElements, seqId);
	}
	
	public void modifierPublication(Rafraichissable vueRafraichir, Publication publication, Integer seqId) {
		PublicationAsyncDao pDao = new PublicationAsyncDao(vueRafraichir);
		pDao.modifier(publication, seqId);
	}

	public void ajouterPublication(Rafraichissable vueARafraichir, Publication publication, Integer seqId) {
		PublicationAsyncDao pDao = new PublicationAsyncDao(vueARafraichir);
		pDao.ajouter(publication, seqId);
	}

	public void supprimerPublication(Rafraichissable vueARafraichir, String idPublicationSeparesParVirgule) {		
		PublicationAsyncDao pDao = new PublicationAsyncDao(vueARafraichir);
		pDao.supprimer(idPublicationSeparesParVirgule);
	}

	//+----------------------------------------------------------------------------------------------------------------+
	// GESTION de la relation PUBLICATION A PERSONNE

	public void selectionPersonnesAPublication(Rafraichissable vueARafraichir, String publicationId, String recherche, int start, int nbElements, Integer seqId) {
		PublicationAPersonneAsyncDao paDao = new PublicationAPersonneAsyncDao(vueARafraichir);
		paDao.selectionner(true, publicationId, null, PublicationAPersonne.ROLE_AUTEUR, recherche, start, nbElements, seqId);
	}
	
	public void selectionPublicationsAPersonne(Rafraichissable vueARafraichir, String personneId, String roleIds, String recherche, int start, int nbElements, Integer seqId) {
		PublicationAPersonneAsyncDao paDao = new PublicationAPersonneAsyncDao(vueARafraichir);
		paDao.selectionner(true, null, personneId, roleIds, recherche, start, nbElements, seqId);
	}
	
	public void selectionPublicationAPersonne(Rafraichissable vueARafraichir, String publicationId, String personnesId, String roleId, Integer seqId) {
		PublicationAPersonneAsyncDao paDao = new PublicationAPersonneAsyncDao(vueARafraichir);
		paDao.selectionner(false, publicationId, personnesId, roleId, null, 0, -1, seqId);
	}
	
	public void ajouterPublicationAPersonne(Rafraichissable vueARafraichir, String publicationId, String personnesId, String ordreAuteursSepareParVirgule, String roleId, Integer seqId) {
		PublicationAPersonneAsyncDao paDao = new PublicationAPersonneAsyncDao(vueARafraichir);
		paDao.ajouter(publicationId, personnesId, ordreAuteursSepareParVirgule, roleId, seqId);
	}
	
	public void modifierPublicationAPersonne(Rafraichissable vueARafraichir, String publicationId, String personnesId, String ordreAuteurs, String roleId, Integer seqId) {
		PublicationAPersonneAsyncDao paDao = new PublicationAPersonneAsyncDao(vueARafraichir);
		paDao.modifier(publicationId, personnesId, ordreAuteurs, roleId, seqId);
	}

	public void supprimerPublicationAPersonne(Rafraichissable vueARafraichir, String publicationsAPersonneId) {		
		PublicationAPersonneAsyncDao publicationAPersonneDao = new PublicationAPersonneAsyncDao(vueARafraichir);		
		publicationAPersonneDao.supprimer(publicationsAPersonneId);
	}

	public void supprimerProjet(Rafraichissable vueARafraichir,
			List<Projet> projetListe) {
		
		String projetsId = "";
		for(Iterator<Projet> it = projetListe.iterator(); it.hasNext();) {
			Projet proj = it.next();
			projetsId += proj.getId();
			if(it.hasNext()) {
				projetsId += ",";
			}
		}
		ProjetAsyncDao pADAO = new ProjetAsyncDao(vueARafraichir);
		pADAO.supprimer(projetsId);
	}
	
	//+----------------------------------------------------------------------------------------------------------------+
	//												GESTION DES COMMENTAIRES
	//+----------------------------------------------------------------------------------------------------------------+
	
	public void selectionnerCommentaire(Rafraichissable vueARafraichir, String commentaireId, String projetId, String titre, int pageCourante, int nbElements, Integer seqId) {		
		CommentaireAsyncDao cDao = new CommentaireAsyncDao(vueARafraichir);
		cDao.selectionner(false, commentaireId, projetId, titre, pageCourante, nbElements, seqId);
	}
	
	public void selectionnerCommentaire(Rafraichissable vueARafraichir, String recherche, int pageCourante, int nbElements, Integer seqId) {		
		CommentaireAsyncDao cDao = new CommentaireAsyncDao(vueARafraichir);
		cDao.selectionner(true, null, null, recherche, pageCourante, nbElements, seqId);
	}
	
	public void modifierCommentaire(Rafraichissable vueRafraichir, Commentaire commentaire) {
		CommentaireAsyncDao cDao = new CommentaireAsyncDao(vueRafraichir);
		cDao.modifier(commentaire);
	}

	public void ajouterCommentaire(Rafraichissable vueARafraichir, Commentaire commentaire) {
		CommentaireAsyncDao cDao = new CommentaireAsyncDao(vueARafraichir);
		cDao.ajouter(commentaire);
	}

	public void supprimerCommentaire(Rafraichissable vueARafraichir, String idCommentaireSeparesParVirgule) {
		CommentaireAsyncDao cDao = new CommentaireAsyncDao(vueARafraichir);
		cDao.supprimer(idCommentaireSeparesParVirgule);	
	}
}
