static Partitioner<Partition<CaptureSearchResult>> partitionPartitioner =
new Partitioner<Partition<CaptureSearchResult>>(partitionMap);
public BubbleCalendarData(UIResults results) {
this.results = results;
CaptureSearchResults cResults = results.getCaptureResults();
WaybackRequest wbRequest = results.getWbRequest();
StringFormatter fmt = wbRequest.getFormatter();
String searchUrl =
UrlOperations.stripDefaultPortFromUrl(wbRequest.getRequestUrl());
searchUrlForHTML = fmt.escapeHtml(searchUrl);
searchUrlForJS = fmt.escapeJavaScript(searchUrl);
firstResultDate = cResults.getFirstResultDate();
firstResultReplayUrl = fmt.escapeHtml(results.resultToReplayUrl(cResults.getResults().getFirst()));
lastResultDate = cResults.getLastResultDate();
lastResultReplayUrl = fmt.escapeHtml(results.resultToReplayUrl(cResults.getResults().getLast()));
Date searchStartDate = wbRequest.getStartDate();
Date searchEndDate = wbRequest.getEndDate();
months = capturePartitioner.getRange(monthSize,searchStartDate,searchEndDate);
years = partitionPartitioner.getRange(yearSize,searchStartDate,searchEndDate);
// To build the graph, we need to break all the results into 1 month
// partitions, so partition all the results into the months:
capturePartitioner.populate(months,cResults.iterator());
// To fill in the calendar, we need to break the current year into day
// sized partitions, so first partition those months into years:
partitionPartitioner.populate(years,months.iterator());
// find the active year:
Partition<Partition<CaptureSearchResult>> activeYear = null;
for(Partition<Partition<CaptureSearchResult>> year : years) {
if(year.isContainsClosest()) {
activeYear = year;
break;
}
}
// if there's no activeYear, something is quite wrong...
// TODO: check anyways:
if (activeYear == null) {
activeYear = years.get(years.size() - 1);
}
String yearStr = fmt.format("{0,date,yyyy}",activeYear.getStart());
yearNum = Integer.parseInt(yearStr);
// now unroll the months in the active year into day-sized partitions:
List<Partition<CaptureSearchResult>> days =
capturePartitioner.getRange(daySize,
activeYear.getStart(),activeYear.getEnd());
for(Partition<CaptureSearchResult> month : activeYear.list()) {
capturePartitioner.populate(days,month.iterator());
}
// finally, spool the days of the current year into 12 month-sized
// partitions:
monthsByDay = partitionPartitioner.getRange(monthSize, activeYear.getStart(), activeYear.getEnd());
partitionPartitioner.populate(monthsByDay,days.iterator());
dataStartMSSE = years.get(0).getStart().getTime();
dataEndMSSE = years.get(years.size()-1).getEnd().getTime();
numResults = cResults.getMatchingCount();
}