if (formName.equals("matrixSimple")) {
String buttonName = request.getParameter("searchButton");
Set<Matrix> matches = new HashSet<Matrix>();
String searchTerm = convertStars(request.getParameter("searchTerm"));
SearchMessageSetter mSetter = new RequestMessageSetter(request);
MatrixSearchResults oldRes;
{
SearchResults<?> sr = searchResults(request);
if (sr != null) {
oldRes = (MatrixSearchResults) sr.convertToMatrices();
} else {
oldRes = new MatrixSearchResults (); // TODO: Convert existing search results to new type
}
}
if (buttonName.equals("matrixID")) {
matches.addAll(doSearch(request, response, SearchType.byID, errors,searchTerm));
} else if (buttonName.equals("matrixTitle")) {
matches.addAll(doSearch(request, response, SearchType.byTitle, errors,searchTerm));
} else if (buttonName.equals("matrixType")) {
matches.addAll(doSearch(request, response, SearchType.byType, errors,searchTerm));
} else if (buttonName.equals("matrixNTAX")) {
matches.addAll(doSearch(request, response, SearchType.byNTAX, errors,searchTerm));
} else if (buttonName.equals("matrixNCHAR")) {
matches.addAll(doSearch(request, response, SearchType.byNCHAR, errors,searchTerm));
} else {
throw new Error("Unknown search button name '" + buttonName + "'");
}
if ( TreebaseUtil.isEmpty(request.getParameter("format")) || ! request.getParameter("format").equals("rss1") ) {
SearchResults<Matrix> newRes = intersectSearchResults(oldRes,
new MatrixSearchResults(matches), mSetter, "No matching matrices found");
saveSearchResults(request, newRes);
return new ModelAndView("search/matrixSearch", Constants.RESULT_SET, newRes);
}
else {
return this.searchResultsAsRDF(new MatrixSearchResults(matches), request, null, "matrix", "matrix");
}
}
else {
return super.onSubmit(request, response, command, errors);