/**
  * @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);
 }
 /**
  * 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;
 }
 /*
  * (non-Javadoc)
  * @see org.encuestame.core.service.SetupOperations#validateInstall()
  */
 public void validateInstall() {
     log.debug("validateInstall ------------");
     final XMLConfigurationFileSupport config = EnMePlaceHolderConfigurer.getConfigurationManager();
     log.debug("validateInstall ------------"+config.getXmlConfiguration().getBasePath());
     config.getXmlConfiguration().addProperty("install.date", DateUtil.getCurrentFormatedDate());
     config.getXmlConfiguration().addProperty("install.uuid", RandomStringUtils.randomAlphanumeric(50));
     log.debug("validateInstall ------------");
 }
 /**
  * Remove duplicate item from {@link TweetPollResult} vote.
  *
  * @param itemList
  * @param period
  */
 private void removeDuplicatleItemOutOfRange(
     final List<ItemStatDetail> itemList, final Integer period) {
   Boolean check;
   for (int i = 0; i < itemList.size(); i++) {
     check = DateUtil.checkDatedWithinAllowableRange(period, itemList.get(i).getDate());
     if (!check) {
       itemList.remove(i);
     }
   }
 }
示例#5
0
 /**
  * Before.
  *
  * @throws ParseException
  */
 @Before
 public void beforeQuestion() throws ParseException {
   this.user = createUser("testEncuesta", "testEncuesta123");
   createFakesQuestions(this.user);
   // masive insert.
   for (int i = 0; i < 200; i++) {
     createQuestion("Word Cup 2010, Spain is a good champion?", this.user);
   }
   final Date createDate = DateUtil.parseDate("2011-01-01", DateUtil.DEFAULT_FORMAT_DATE);
   createQuestion("Question with date and hits", this.user, createDate, 200L);
   this.initQuestion =
       createDefaultQuestion(
           "What is the country with the highest number of medals at the 2012 Olympic game");
 }
  /**
   * @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;
  }