import com.netfever.site.dynovisz.web.utils.Cache;
public final class SearchFormToSolQuery implements Adapter<SearchForm, SolrQuery> {
@Override
public SolrQuery adapt(SearchForm in) {
final SolrQuery res = new SolrQuery();
String category = Cache.getCategories().get(new Integer(in.getCategory()));
res.setCategory(category);
res.setStartDate(in.getStartDateAsDate());
res.setEndDate(in.getEndDateAsDate());
res.setLanguage(in.getLanguage());
try {
final int page = Integer.parseInt(in.getPage());
res.setPage(page);
} catch (NumberFormatException e) {
res.setPage(1);
}
res.setQuery(in.getQuery());
if (in.getSafeSortBy().equals("R")) {
res.setSortedBy(SortedBy.VIDEO_DATE);
} else {
res.setSortedBy(SortedBy.NUMBER_OF_VIEW);
}
res.setWithcomments(in.isWithcomments());
return res;
}