Search in sources :

Example 16 with SearchResult

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);
}
Also used : SearchResult(com.tyndalehouse.step.core.models.search.SearchResult) OsisWrapper(com.tyndalehouse.step.core.models.OsisWrapper)

Aggregations

SearchResult (com.tyndalehouse.step.core.models.search.SearchResult)16 SearchEntry (com.tyndalehouse.step.core.models.search.SearchEntry)5 SubjectHeadingSearchEntry (com.tyndalehouse.step.core.models.search.SubjectHeadingSearchEntry)4 EntityDoc (com.tyndalehouse.step.core.data.EntityDoc)3 ExpandableSubjectHeadingEntry (com.tyndalehouse.step.core.models.search.ExpandableSubjectHeadingEntry)3 IndividualSearch (com.tyndalehouse.step.core.service.impl.IndividualSearch)3 ArrayList (java.util.ArrayList)3 TimelineEventSearchEntry (com.tyndalehouse.step.core.models.search.TimelineEventSearchEntry)2 VerseSearchEntry (com.tyndalehouse.step.core.models.search.VerseSearchEntry)2 SearchQuery (com.tyndalehouse.step.core.service.impl.SearchQuery)2 LookupOption (com.tyndalehouse.step.core.models.LookupOption)1 OsisWrapper (com.tyndalehouse.step.core.models.OsisWrapper)1 KeyedSearchResultSearchEntry (com.tyndalehouse.step.core.models.search.KeyedSearchResultSearchEntry)1 LexicalSearchEntry (com.tyndalehouse.step.core.models.search.LexicalSearchEntry)1 PassageStat (com.tyndalehouse.step.core.models.stats.PassageStat)1 AbortQueryException (com.tyndalehouse.step.core.service.impl.AbortQueryException)1 Key (org.crosswire.jsword.passage.Key)1 Passage (org.crosswire.jsword.passage.Passage)1 RangedPassage (org.crosswire.jsword.passage.RangedPassage)1 VerseKey (org.crosswire.jsword.passage.VerseKey)1