/**
   * This methods retrieve the statistics which are linked the component given in argument
   *
   * @param session The hibernate session
   * @param component The component for which the method searches the statistics
   * @return The list of statistics linked to the segmentation
   * @throws JrafEnterpriseException Exception occurs during the retrieve work
   */
  public static List<SharedRepoStatsDTO> retrieveStats(ISession session, ComponentDTO component)
      throws JrafEnterpriseException {
    List<SharedRepoStatsDTO> listStatsDto = new ArrayList<SharedRepoStatsDTO>();
    try {
      // The method retrieves the segment linked to the component
      SegmentDAOImpl segmentDao = SegmentDAOImpl.getInstance();
      List<SegmentBO> segmentlist = segmentDao.findModuleSegments(session, component.getID());

      // The method retrieves the segmentation corresponding to the list of segment
      SegmentationDAOImpl dao = SegmentationDAOImpl.getInstance();
      List<SegmentationBO> segmentList =
          (List<SegmentationBO>) dao.findContainsSegments(session, segmentlist);

      if (segmentList.size() > 0) {
        SegmentationBO segmentationBo = segmentList.get(0);
        Set<SharedRepoStatsBO> statsBoList = segmentationBo.getStatsList();
        for (SharedRepoStatsBO statsBo : statsBoList) {
          listStatsDto.add(SharedRepoStatsTransform.bo2dto(statsBo));
        }
      }
    } catch (JrafDaoException e) {
      FacadeHelper.convertException(e, "retrieveStats");
    } finally {
      FacadeHelper.closeSession(session, SharedRepoStatsFacade.class.getName() + ".retrieveStats");
    }
    return listStatsDto;
  }
 /** Test du update */
 public void testUpdate() {
   try {
     ISession session = PERSISTENTPROVIDER.getSession();
     ApplicationBO application = getComponentFactory().createApplication(session);
     QualityGridBO grid = getComponentFactory().createGrid(session);
     ProjectProfileBO profile = getComponentFactory().createProjectProfile(session);
     SourceManagementBO manager = getComponentFactory().createSourceManagement(session);
     MapParameterBO parameters = getComponentFactory().createParameters(session);
     ProjectBO project =
         getComponentFactory()
             .createProject(session, application, grid, profile, manager, parameters);
     assertEquals(0, project.getParameters().getParameters().size());
     ApplicationConfDTO applicationConf = new ApplicationConfDTO();
     applicationConf.setId(application.getId());
     ProjectConfDTO projectConf = new ProjectConfDTO();
     projectConf.setId(project.getId());
     projectConf.setName(project.getName());
     // Création des paramètres
     MapParameterDTO params = new MapParameterDTO();
     StringParameterDTO strParam = new StringParameterDTO("strParam");
     params.getParameters().put("strParam", strParam);
     projectConf.setParameters(params);
     // La grille
     QualityGridDTO gridDTO = new QualityGridDTO();
     gridDTO.setName(grid.getName());
     projectConf.setQualityGrid(gridDTO);
     // Le profil
     ProjectProfileDTO profileDTO = new ProjectProfileDTO();
     profileDTO.setName(profile.getName());
     projectConf.setProfile(profileDTO);
     // Le source manager
     SourceManagementDTO managerDTO = new SourceManagementDTO();
     managerDTO.setName(manager.getName());
     projectConf.setSourceManager(managerDTO);
     ProjectFacade.update(projectConf, applicationConf, getSession());
     ProjectConfDTO projectconfGetting = ProjectFacade.get(projectConf);
     MapParameterDTO paramsDTOGetting = projectconfGetting.getParameters();
     Map mapGetting = paramsDTOGetting.getParameters();
     assertEquals(1, mapGetting.size());
     FacadeHelper.closeSession(session, "");
   } catch (Exception e) {
     e.printStackTrace();
     fail("unexpected exception");
   }
 }
 /**
  * This method persists in the database the list of statistics given in argument
  *
  * @param session The hibernate session
  * @param statsListDto The list of statistics to persist in the database
  * @throws JrafEnterpriseException exception occurs the saveAll work
  */
 public static void saveAll(ISession session, List<SharedRepoStatsDTO> statsListDto)
     throws JrafEnterpriseException {
   try {
     SharedRepoStatsDAOImpl sharedRepoDao = SharedRepoStatsDAOImpl.getInstance();
     SegmentationDAOImpl segmentationDao = SegmentationDAOImpl.getInstance();
     for (SharedRepoStatsDTO sharedRepoStatsDto : statsListDto) {
       SharedRepoStatsBO statsBo = SharedRepoStatsTransform.dto2bo(sharedRepoStatsDto);
       SegmentationBO segment =
           (SegmentationBO)
               segmentationDao.get(session, statsBo.getSegmentation().getSegmentationId());
       segment.getStatsList().add(statsBo);
       statsBo.setSegmentation(segment);
       sharedRepoDao.save(session, statsBo);
     }
   } catch (JrafDaoException e) {
     FacadeHelper.convertException(e, "saveAll");
   }
 }
 /** Test du get */
 public void testGet() {
   try {
     ISession session = PERSISTENTPROVIDER.getSession();
     ApplicationBO application = getComponentFactory().createApplication(session);
     QualityGridBO grid = getComponentFactory().createGrid(session);
     ProjectProfileBO profile = getComponentFactory().createProjectProfile(session);
     SourceManagementBO manager = getComponentFactory().createSourceManagement(session);
     MapParameterBO parameters = getComponentFactory().createParameters(session);
     ProjectBO project =
         getComponentFactory()
             .createProject(session, application, grid, profile, manager, parameters);
     ProjectConfDTO projectConf = new ProjectConfDTO();
     projectConf.setId(project.getId());
     ProjectConfDTO out = ProjectFacade.get(projectConf);
     FacadeHelper.closeSession(session, "");
   } catch (Exception e) {
     e.printStackTrace();
     fail("unexpected exception");
   }
 }