public class GestionProjetImpl implements GestionProjet {
private static final Logger log = Logger.getLogger(GestionProjetImpl.class);
private ProjetDAO projetDAO;
private LotDAO lotDAO;
private TacheDAO tacheDAO;
private CollaborateurDAO collaborateurDAO;
/** Creates a new instance of GestionProjetImpl */
public GestionProjetImpl() {}
public Projet creerProjet( String intitule,
Calendar dateCreation, Calendar dateDebut, Calendar dateFin,
Client client){
Projet p = null;
if (dateDebut.before(dateFin) ){
p = new Projet(intitule, dateCreation, dateDebut, dateFin, client );
projetDAO.create(p);
}
return p;
}
public void updateProjet(Projet p){
projetDAO.update(p);
}
public void deleteProjet(int numProjet){
projetDAO.delete(numProjet);
}
public Lot creerLot(String intitule, int idProjet,
Calendar dateDebut, Calendar dateFin ){
Projet projet = projetDAO.findById(idProjet);
if (projet != null ){
try{
Lot lot = new Lot(intitule, projet, dateDebut, dateFin );
lot.setDateCreation( new GregorianCalendar());
projet.addTolots(lot); // a remonter dans lotDAO.create() ?
return lotDAO.create(lot);
}
catch(Exception e){}
// Le constructeur du BO retourne une checked exception
}
else{} // Le projet auquel est rattache le lot n'existe pas
return null;
}
public void updateLot(Lot l){
lotDAO.update(l);
}
public void deleteLot(int numLot){
lotDAO.delete(numLot);
}
...
public void assignerCollaborateurToProjet( int idProjet, int idCollaborateur){
Projet p = projetDAO.findById(idProjet);
Collaborateur c = collaborateurDAO.findById(idCollaborateur);
if (p != null && c != null ){
p.assigneCollaborateurToProjet(c);
projetDAO.update(p);
// facultatif si session ouverte, obligatoire si session fermée, donc on le met pour l'instant!
}
}
Partager