if (searchType != null && !searchType.isEmpty() && !SearchBox.ALL.equals(searchType)) {
warn("Removed user filter when executing your saved search");
searchBox.setSearchType(SearchBox.ALL);
}
JUser user = getMySession().getUser();
SavedSearch ss = user.getSavedSearch(ssId);
if (ss != null) {
doSearch(ss.getQuery(), 0, true);
uindexProvider.get().save(user, true);
}
updateSSCounts(target);
updateAfterAjax(target, true);
}
@Override
public void onRemove(AjaxRequestTarget target, long ssId) {
JUser user = getMySession().getUser();
user.removeSavedSearch(ssId);
uindexProvider.get().save(user, true);
updateSSCounts(target);
}
@Override
public void onSave(AjaxRequestTarget target, long ssId) {
if (lastQuery == null)
return;
SavedSearch ss = new SavedSearch(ssId, lastQuery);
JUser user = getMySession().getUser();
user.addSavedSearch(ss);
uindexProvider.get().save(user, true);
updateSSCounts(target);
}
@Override
public void updateSSCounts(AjaxRequestTarget target) {
try {
JUser user = getMySession().getUser();
if (user != null) {
StopWatch sw = new StopWatch().start();
update(getTweetSearch().updateSavedSearches(user.getSavedSearches()));
if (target != null)
target.addComponent(ssPanel);
logger.info("Updated saved search counts for " + user.getScreenName() + " " + sw.stop().getSeconds());
}
} catch (Exception ex) {
logger.error("Error while searching in savedSearches", ex);
}
}
@Override
public String translate(long id) {
SavedSearch ss = getMySession().getUser().getSavedSearch(id);
return ss.getName();
}
};
add(ssPanel.setOutputMarkupId(true));