*/
public void search() {
searchOptionsHolder = null;
if (!isSearchOptionSelected()) {
// If no options selected
error.fire(new ErrorEvent(Constants.SEARCH_NO_OPTIONS_ERROR));
return;
}
if (!isWhereSearchOptionSelected()) {
// If both search in My and search is shared unselected
error.fire(new ErrorEvent(Constants.SEARCH_NO_WHERE_OPTIONS_ERROR));
return;
}
keywords = new ArrayList<String>();
// Update view
navEvent.fire(new NavEvent(NavigationEnum.SEARCH));
// parse query
keywords = parse(searchQuery);
Iterator<ISearchOption> it = options.iterator();
// Search by first keyword by default
selectedKeyword = keywords.get(0).trim();
while (it.hasNext()) {
ISearchOption option = it.next();
try {
if (option.getSelected()) {
option.search(searchAction, selectedKeyword, seachInMyAlbums, searchInShared);
}
} catch (PhotoAlbumException e) {
error.fire(new ErrorEvent("Error", option.getName() + ":" + e.getMessage()));
}
}
searchOptionsHolder = new SearchInformationHolder(new ArrayList<ISearchOption>(options), seachInMyAlbums,
searchInShared);
searchQuery = "";