use of com.tyndalehouse.step.core.models.search.SearchResult in project step by STEPBible.
the class SearchPageController method setupRequestContext.
/**
* Sets up the request context for use in the JSTL parsing
*
* @param req the request
* @param data the osisWrapper
* @throws IOException
*/
private void setupRequestContext(final HttpServletRequest req, final AbstractComplexSearch data) throws IOException {
// global settings
// set the language attributes once
final Locale userLocale = this.clientSessionProvider.get().getLocale();
if (userLocale.getLanguage().equalsIgnoreCase("zh") && userLocale.getCountry().equalsIgnoreCase("tw")) {
req.setAttribute("languageCode", "zh_TW");
} else
req.setAttribute("languageCode", userLocale.getLanguage());
req.setAttribute("languageName", ContemporaryLanguageUtils.capitaliseFirstLetter(userLocale.getDisplayLanguage(userLocale)).replace("\"", ""));
req.setAttribute("languageComplete", this.languageService.isCompleted(userLocale.getLanguage()));
req.setAttribute("ltr", ComponentOrientation.getOrientation(userLocale).isLeftToRight());
req.setAttribute("versions", objectMapper.get().writeValueAsString(modules.getAllModules()));
req.setAttribute("searchType", data.getSearchType().name());
req.setAttribute("versionList", getVersionList(data.getMasterVersion(), data.getExtraVersions()));
req.setAttribute("languages", this.languageService.getAvailableLanguages());
// specific to passages
if (data instanceof OsisWrapper) {
final OsisWrapper osisWrapper = (OsisWrapper) data;
req.setAttribute("passageText", osisWrapper.getValue());
osisWrapper.setValue(null);
req.setAttribute("passageModel", objectMapper.get().writeValueAsString(osisWrapper));
populateMetaPassage(req, osisWrapper);
populateSiblingChapters(req, osisWrapper);
} else if (data instanceof SearchResult) {
final SearchResult results = (SearchResult) data;
req.setAttribute("searchResults", results.getResults());
req.setAttribute("definitions", results.getDefinitions());
req.setAttribute("filter", results.getStrongHighlights());
req.setAttribute("numResults", results.getTotal());
req.setAttribute("sort", results.getOrder());
results.setResults(null);
req.setAttribute("passageModel", objectMapper.get().writeValueAsString(results));
populateMetaSearch(req, results);
}
// set the analytics token
req.setAttribute("stepDomain", appManagerService.getAppDomain());
req.setAttribute("analyticsToken", Boolean.TRUE.equals(Boolean.getBoolean("step.development")) ? DEV_TOKEN : LIVE_TOKEN);
}
Aggregations