/**
   * 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;
  }