/** * Copyright (C) 2008-2010, Squale Project - http://www.squale.org * * This file is part of Squale. * * Squale is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of the * License, or any later version. * * Squale is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Squale. If not, see <http://www.gnu.org/licenses/>. */ package org.squale.squalecommon.enterpriselayer.facade.component; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import org.squale.jraf.commons.exception.JrafDaoException; import org.squale.jraf.commons.exception.JrafEnterpriseException; import org.squale.jraf.helper.PersistenceHelper; import org.squale.jraf.provider.persistence.hibernate.facade.FacadeHelper; import org.squale.jraf.spi.persistence.IPersistenceProvider; import org.squale.jraf.spi.persistence.ISession; import org.squale.squalecommon.daolayer.component.ProjectDAOImpl; import org.squale.squalecommon.datatransfertobject.transform.config.TaskTransform; import org.squale.squalecommon.enterpriselayer.businessobject.component.ProjectBO; import org.squale.squalecommon.enterpriselayer.businessobject.config.TaskRefBO; /** */ public class TaskFacade { /** * provider de persistence */ private static final IPersistenceProvider PERSISTENTPROVIDER = PersistenceHelper.getPersistenceProvider(); /** * r�cup�re toutes les taches existantes * * @param pProjectId l'id du projet * @return la collection de taches * @throws JrafEnterpriseException en cas d'�chec */ public static Collection getAllTasks( Long pProjectId ) throws JrafEnterpriseException { ISession session = null; Collection collBo = new ArrayList(); Collection collDto = new ArrayList( 0 ); try { session = PERSISTENTPROVIDER.getSession(); // On r�cup�re le projet ProjectBO project = (ProjectBO) ProjectDAOImpl.getInstance().get( session, pProjectId ); /* * On va ajouter les t�ches dans leur ordre d'�x�cution c-a-d : 1 - les t�ches d'analyses du source manager * 2 - les t�ches d'analyses du profil 3 - les t�ches terminales du profil 4 - les t�ches terminales du * source manager */ collBo.addAll( project.getSourceManager().getAnalysisTasks() ); collBo.addAll( project.getProfile().getAnalysisTasks() ); collBo.addAll( project.getProfile().getTerminationTasks() ); collBo.addAll( project.getSourceManager().getTerminationTasks() ); // on caste chaque �l�ment de la collection de taskBO en TaskDTO Iterator it = collBo.iterator(); while ( it.hasNext() ) { TaskRefBO taskRef = (TaskRefBO) it.next(); collDto.add( TaskTransform.bo2dto( taskRef ) ); } } catch ( JrafDaoException e ) { FacadeHelper.convertException( e, TaskFacade.class.getName() + ".getAllTasks" ); } finally { FacadeHelper.closeSession( session, TaskFacade.class.getName() + ".getAllTasks" ); } return collDto; } }