Search in sources :

Example 11 with OsisWrapper

use of com.tyndalehouse.step.core.models.OsisWrapper in project step by STEPBible.

the class SubjectEntryServiceImpl method getVersesForResults.

/**
 * obtains the verses for all results
 *
 * @param results  the results
 * @param versions the version in which to look it up
 * @param context  the context to expand with the reference
 * @return the verses
 */
private SubjectEntries getVersesForResults(final EntityDoc[] results, final String[] versions, final String limitingScopeReference, final int context) {
    final List<OsisWrapper> verses = new ArrayList<OsisWrapper>(32);
    boolean masterVersionSwapped = false;
    for (final EntityDoc doc : results) {
        final String references = doc.get("references");
        masterVersionSwapped |= collectVersesFromReferences(verses, versions, references, limitingScopeReference, context);
    }
    return new SubjectEntries(verses, masterVersionSwapped);
}
Also used : SubjectEntries(com.tyndalehouse.step.core.models.search.SubjectEntries) ArrayList(java.util.ArrayList) EntityDoc(com.tyndalehouse.step.core.data.EntityDoc) OsisWrapper(com.tyndalehouse.step.core.models.OsisWrapper)

Example 12 with OsisWrapper

use of com.tyndalehouse.step.core.models.OsisWrapper in project step by STEPBible.

the class BibleInformationServiceImpl method getPassageText.

/**
 * Gets the passage text.
 *
 * @param version            the version
 * @param startVerseId       the start verse id
 * @param endVerseId         the end verse id
 * @param options            the options
 * @param interlinearVersion the interlinear version
 * @param roundUp            the round up
 * @return the passage text
 */
@Override
public OsisWrapper getPassageText(final String version, final int startVerseId, final int endVerseId, final String options, final String interlinearVersion, final Boolean roundUp) {
    final List<String> extraVersions = getExtraVersionsFromString(interlinearVersion);
    final Set<LookupOption> lookupOptions = this.optionsValidationService.trim(this.optionsValidationService.getLookupOptions(options), version, extraVersions, InterlinearMode.NONE, null);
    final OsisWrapper passage = this.jswordPassage.getOsisTextByVerseNumbers(version, version, startVerseId, endVerseId, new ArrayList<LookupOption>(lookupOptions), interlinearVersion, roundUp, false);
    return passage;
}
Also used : LookupOption(com.tyndalehouse.step.core.models.LookupOption) TrimmedLookupOption(com.tyndalehouse.step.core.models.TrimmedLookupOption) EnrichedLookupOption(com.tyndalehouse.step.core.models.EnrichedLookupOption) OsisWrapper(com.tyndalehouse.step.core.models.OsisWrapper)

Example 13 with OsisWrapper

use of com.tyndalehouse.step.core.models.OsisWrapper 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

OsisWrapper (com.tyndalehouse.step.core.models.OsisWrapper)13 LookupOption (com.tyndalehouse.step.core.models.LookupOption)7 ArrayList (java.util.ArrayList)6 StepInternalException (com.tyndalehouse.step.core.exceptions.StepInternalException)4 Book (org.crosswire.jsword.book.Book)4 Test (org.junit.Test)4 Key (org.crosswire.jsword.passage.Key)3 BibleBook (org.crosswire.jsword.versification.BibleBook)3 LocalisedException (com.tyndalehouse.step.core.exceptions.LocalisedException)2 EnrichedLookupOption (com.tyndalehouse.step.core.models.EnrichedLookupOption)2 InterlinearMode (com.tyndalehouse.step.core.models.InterlinearMode)2 TrimmedLookupOption (com.tyndalehouse.step.core.models.TrimmedLookupOption)2 StringReader (java.io.StringReader)2 TransformerException (javax.xml.transform.TransformerException)2 TransformingSAXEventProvider (org.crosswire.common.xml.TransformingSAXEventProvider)2 XMLUtil.writeToString (org.crosswire.common.xml.XMLUtil.writeToString)2 BookData (org.crosswire.jsword.book.BookData)2 BookException (org.crosswire.jsword.book.BookException)2 NoSuchKeyException (org.crosswire.jsword.passage.NoSuchKeyException)2 Passage (org.crosswire.jsword.passage.Passage)2