Ejemplo n.º 1
0
  /**
   * @param itemList
   * @param period
   * @param request
   * @return
   * @throws EnMeSearchException
   */
  public List<HashTagDetailStats> compareHashtagListGraph(
      final List<ItemStatDetail> itemList,
      final SearchPeriods period,
      final HttpServletRequest request)
      throws EnMeSearchException {
    Integer month = 0;
    Integer monthB;
    Integer dayA = 0;
    Integer dayB = 0;

    Integer yearA = 0;
    Integer yearB = 0;

    boolean existItemStatDetailLabel = false;
    List<HashTagDetailStats> tagDetailStatsCompare = new ArrayList<HashTagDetailStats>();
    // FIXME: It's limited only for dates in the same year, upgrade to accept dates for different
    // year.

    for (int i = 0; i < itemList.size(); i++) {
      Long countItems = 0L;
      // Get the date values.
      monthB = DateUtil.getValueCurrentMonthOfTheYear(itemList.get(i).getDate());
      dayB = DateUtil.getValueCurrentDateOfTheMonths(itemList.get(i).getDate());
      yearB = DateUtil.getValueCurrentYear(itemList.get(i).getDate());

      for (int j = 0; j < itemList.size(); j++) {
        month = DateUtil.getValueCurrentMonthOfTheYear(itemList.get(j).getDate());
        dayA = DateUtil.getValueCurrentDateOfTheMonths(itemList.get(j).getDate());
        yearA = DateUtil.getValueCurrentYear(itemList.get(j).getDate());
        if ((monthB.equals(month)) && (dayB.equals(dayA)) && (yearB.equals(yearA))) {
          countItems++;
        }
      }
      // check if the label exist previously

      final DateTime myDate = new DateTime(itemList.get(i).getDate());
      existItemStatDetailLabel =
          checkLabelExistsHashTagDetailStatGraph(tagDetailStatsCompare, myDate);
      if (!existItemStatDetailLabel) {

        tagDetailStatsCompare.add(
            this.createHastagItemDetailGraph(
                monthB.toString(), countItems, "Compare", myDate.getMillis(), myDate));
      }
    }

    return tagDetailStatsCompare;
  }
Ejemplo n.º 2
0
 /**
  * @param itemList
  * @param period
  * @param request
  * @return
  * @throws EnMeNoResultsFoundException
  * @throws EnMeSearchException
  */
 private List<HashTagListGraphData> groupListItemStatDetail(
     final List<ItemStatDetail> itemList,
     final SearchPeriods period,
     final HttpServletRequest request)
     throws EnMeNoResultsFoundException, EnMeSearchException {
   final List<HashTagListGraphData> tagDetailStatsCompare = new ArrayList<HashTagListGraphData>();
   for (ItemStatDetail item : itemList) {
     int month = DateUtil.getValueCurrentMonthOfTheYear(item.getDate());
     int year = DateUtil.getValueCurrentYear(item.getDate());
     int day = DateUtil.getValueCurrentDateOfTheMonths(item.getDate());
     Long value = item.getItemId();
     tagDetailStatsCompare.add(this.createHastagItemDetailGraph(year, value, month, day));
   }
   return this.groupHashTagListGraphData(tagDetailStatsCompare);
 }
Ejemplo n.º 3
0
 /**
  * Return the label value of the period based on {@link Date}. eg :: 22/12/2012 - Period : ONEYEAR
  * return 12;
  *
  * @param period {@link SearchPeriods}
  * @param pubDate {@link Date}
  * @return
  */
 private Integer getLabelDateValue(final SearchPeriods periodSelected, final Date pubDate) {
   Integer labelValue = null;
   if (periodSelected.equals(SearchPeriods.ONEYEAR)) { // return motnhs
     labelValue = DateUtil.getValueCurrentMonthOfTheYear(pubDate);
   } else if (periodSelected.equals(SearchPeriods.THIRTYDAYS)) { // return days
     labelValue = DateUtil.getValueCurrentDateOfTheMonths(pubDate);
   } else if (periodSelected.equals(SearchPeriods.TWENTYFOURHOURS)) { // return hours
     labelValue = DateUtil.getValueHourOfTheDay(pubDate);
   } else if (periodSelected.equals(SearchPeriods.SEVENDAYS)) { // return days
     labelValue = DateUtil.getValueCurrentDayOfTheWeek(pubDate);
   } else if (periodSelected.equals(SearchPeriods.ALLTIME)) { // return years
     labelValue = DateUtil.getValueCurrentYear(pubDate);
   }
   return labelValue;
 }