Map<WaveId, WaveViewData> results = Maps.newLinkedHashMap();
// Loop over the user waves view.
for (WaveId waveId : currentUserWavesView.keySet()) {
Collection<WaveletId> waveletIds = currentUserWavesView.get(waveId);
WaveViewData view = null; // Copy of the wave built up for search hits.
for (WaveletId waveletId : waveletIds) {
WaveletContainer waveletContainer = null;
WaveletName waveletname = WaveletName.of(waveId, waveletId);
try {
waveletContainer = waveMap.getLocalWavelet(waveletname);
} catch (WaveletStateException e) {
LOG.severe(String.format("Failed to get local wavelet %s", waveletname.toString()), e);
}
// TODO (Yuri Z.) This loop collects all the wavelets that match the
// query, so the view is determined by the query. Instead we should
// look at the user's wave view and determine if the view matches the query.
try {
if (waveletContainer == null || !waveletContainer.applyFunction(matchesFunction)) {
continue;
}
if (view == null) {
view = WaveViewDataImpl.create(waveId);
}
// Just keep adding all the relevant wavelets in this wave.
view.addWavelet(waveletContainer.copyWaveletData());
} catch (WaveletStateException e) {
LOG.warning("Failed to access wavelet " + waveletContainer.getWaveletName(), e);
}
}
if (view != null) {