예제 #1
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;
 }
예제 #2
0
  /**
   * Convert a number to correct i18n label. eg: 12 == December / ONEYEAR 6 == Saturday / SEVENDAYS
   * 24 == 24 / TWENTYFOURHOURS
   *
   * @param period the period
   * @param label the label to be translated
   * @param request {@link HttpServletRequest}.
   * @return
   */
  private String getHashTagStatsDataRangeLabel(
      final String period, final Integer label, final HttpServletRequest request) {
    String dataRangeLabel = null;
    HashTagRate tagRateLabel;
    final SearchPeriods periodSelected = SearchPeriods.getPeriodString(period);

    if (periodSelected.equals(SearchPeriods.ONEYEAR)) {
      tagRateLabel = HashTagRate.getHashTagMonthLabel(Integer.toString(label));
      dataRangeLabel =
          this.convertHashTagDataRangeLabelMessage(tagRateLabel, request, new Object[] {});
    } else if (periodSelected.equals(SearchPeriods.ALLTIME)) {
      dataRangeLabel = String.valueOf(label);
    } else if (periodSelected.equals(SearchPeriods.THIRTYDAYS)) {
      dataRangeLabel = String.valueOf(label);
    } else if (periodSelected.equals(SearchPeriods.TWENTYFOURHOURS)) {
      dataRangeLabel = String.valueOf(label);
    } else if (periodSelected.equals(SearchPeriods.SEVENDAYS)) {
      tagRateLabel = HashTagRate.getHashTagWeekDayLabel(Integer.toString(label));
      dataRangeLabel =
          this.convertHashTagDataRangeLabelMessage(tagRateLabel, request, new Object[] {});
    }
    return dataRangeLabel;
  }