*/
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws Exception {
SearchCommand searchCommand = (SearchCommand) request.getSession().getAttribute(Constants.SEARCH_COMMAND);
StudyCriteria studyCriteria = new StudyCriteria();
List<SearchCriteriaCommand> criterias = searchCommand.getCriterias();
Collection<Study> studyList = new ArrayList<Study>();
// no longer needed
request.getSession().removeAttribute(Constants.SEARCH_COMMAND);
if (searchCommand == null) {
return new ModelAndView("studyList", Constants.STUDY_LIST, studyList);
}
// TODO:
// need a better way to handle this - hardcode it for now
List<String> authors = new ArrayList<String>();
List<String> citationTitles = new ArrayList<String>();
for (SearchCriteriaCommand criteria : criterias) {
String attribute = criteria.getAttribute();
String value = criteria.getValue();
if (attribute == null || value == null) continue;
// treat all search as equal to
if (attribute.equals(Constants.SEARCH_AUTHOR)) {
authors.add(value);
} else if (attribute.equals(Constants.SEARCH_CITATION_TITLE)) {
citationTitles.add(Constants.SEARCH_CITATION_TITLE);
} else if (attribute.equals(Constants.SEARCH_ALGORITHM)) {
studyCriteria.setAlgorithm(value);
} else if (attribute.equals(Constants.SEARCH_SOFTWARE)) {
studyCriteria.setSoftware(value);
}
// end if
} // end for
studyCriteria.setAuthorLastNames(authors);
studyCriteria.setCitationTitles(citationTitles);
studyList = mStudyService.findByCriteria(studyCriteria);
return new ModelAndView("studyList", Constants.STUDY_LIST, studyList);
}