Search in sources :

Example 1 with NoSuchKeyException

use of org.crosswire.jsword.passage.NoSuchKeyException in project step by STEPBible.

the class BibleInformationServiceImpl method getArrayOfStrongNumbers.

// @Override
public PassageStat getArrayOfStrongNumbers(final String version, final String reference, PassageStat stat, final String userLanguage) {
    Verse key = null;
    final Versification versificationForVersion = this.jswordVersification.getVersificationForVersion(version);
    try {
        key = VerseFactory.fromString(versificationForVersion, reference);
    } catch (NoSuchKeyException e) {
        // perhaps we're looking at multiple verses....
        try {
            // currently not supporting multiple verses
            key = KeyUtil.getVerse(this.jswordVersification.getBookFromVersion(version).getKey(reference));
        } catch (NoSuchKeyException e1) {
            // try reversifying essentially
            try {
                key = KeyUtil.getVerse(this.jswordVersification.getBookFromVersion(JSwordPassageService.REFERENCE_BOOK).getKey(reference));
            } catch (NoSuchKeyException ex) {
                LOGGER.error("Unable to look up strongs for [{}]", reference, e);
            }
        }
    }
    return new JSwordStrongNumberHelper(this.entityManager, key, this.jswordVersification, this.jswordSearch, this.strongAugmentationService).calculateStrongArrayCounts(version, stat, userLanguage);
}
Also used : NoSuchKeyException(org.crosswire.jsword.passage.NoSuchKeyException) Versification(org.crosswire.jsword.versification.Versification) Verse(org.crosswire.jsword.passage.Verse) JSwordStrongNumberHelper(com.tyndalehouse.step.core.service.jsword.helpers.JSwordStrongNumberHelper)

Example 2 with NoSuchKeyException

use of org.crosswire.jsword.passage.NoSuchKeyException in project step by STEPBible.

the class JSwordRelatedVersesServiceImpl method getRelatedVerses.

@Override
public Key getRelatedVerses(final String version, final String key) {
    try {
        // target book, and intermediary strong book
        final Book targetBook = jSwordVersificationService.getBookFromVersion(version);
        final Book strongBook = jSwordMetadataService.supportsStrongs(targetBook) ? targetBook : jSwordVersificationService.getBookFromVersion(JSwordPassageService.REFERENCE_BOOK);
        // target and strong key
        final Key targetKey = targetBook.getKey(key);
        final Key strongKey = VersificationsMapper.instance().map(KeyUtil.getPassage(targetKey), jSwordVersificationService.getVersificationForVersion(strongBook));
        // get list of strong numbers
        final String[] strongs = this.getStrongsFromKey(new BookData(strongBook, strongKey));
        final IndexSearcher is = jSwordSearchService.getIndexSearcher(strongBook.getInitials());
        final List<String> filteredStrongs = keepInfrequentStrongs(strongs, is);
        return targetBook.getKey(getRelatedVerseReference(filteredStrongs, is));
    } catch (final NoSuchKeyException ex) {
        throw new StepInternalException(ex.getMessage(), ex);
    }
}
Also used : IndexSearcher(org.apache.lucene.search.IndexSearcher) NoSuchKeyException(org.crosswire.jsword.passage.NoSuchKeyException) StepInternalException(com.tyndalehouse.step.core.exceptions.StepInternalException) Book(org.crosswire.jsword.book.Book) BookData(org.crosswire.jsword.book.BookData) Key(org.crosswire.jsword.passage.Key)

Example 3 with NoSuchKeyException

use of org.crosswire.jsword.passage.NoSuchKeyException in project step by STEPBible.

the class JSwordPassageServiceImpl method getSiblingChapter.

@Override
public KeyWrapper getSiblingChapter(final String reference, final String version, final boolean previousChapter) {
    // getting the next chapter
    // FIXME find a way of getting the next chapter from the current key, in the current book, rather than
    // relying on versification systems which may contain verses that the Book does not support
    final Book currentBook = this.versificationService.getBookFromVersion(version);
    final Versification v11n = this.versificationService.getVersificationForVersion(currentBook);
    try {
        final Key key = currentBook.getKey(reference);
        return getSiblingChapter(previousChapter, currentBook, v11n, key);
    } catch (final NoSuchKeyException e) {
        throw new TranslatedException(e, "invalid_reference_in_book", reference, version);
    }
}
Also used : NoSuchKeyException(org.crosswire.jsword.passage.NoSuchKeyException) TranslatedException(com.tyndalehouse.step.core.exceptions.TranslatedException) BibleBook(org.crosswire.jsword.versification.BibleBook) Book(org.crosswire.jsword.book.Book) Versification(org.crosswire.jsword.versification.Versification) Key(org.crosswire.jsword.passage.Key)

Example 4 with NoSuchKeyException

use of org.crosswire.jsword.passage.NoSuchKeyException in project step by STEPBible.

the class JSwordPassageServiceImpl method getBookDataByKey.

/**
 * Gets the BookData set up for verse retrieval
 *
 * @param version the version to be used
 * @param key     the reference
 * @return the BookData object
 */
BookData getBookDataByKey(final String version, final Key key) {
    final Book currentBook = this.versificationService.getBookFromVersion(version);
    final Versification v11n = this.versificationService.getVersificationForVersion(currentBook);
    try {
        Key copyOfKey = normalize(key, v11n);
        return new BookData(currentBook, copyOfKey);
    } catch (final NoSuchKeyException e) {
        return handlePassageLookupNSKException(key.getName(), currentBook, v11n, e);
    }
}
Also used : NoSuchKeyException(org.crosswire.jsword.passage.NoSuchKeyException) BibleBook(org.crosswire.jsword.versification.BibleBook) Book(org.crosswire.jsword.book.Book) Versification(org.crosswire.jsword.versification.Versification) BookData(org.crosswire.jsword.book.BookData) Key(org.crosswire.jsword.passage.Key)

Example 5 with NoSuchKeyException

use of org.crosswire.jsword.passage.NoSuchKeyException in project step by STEPBible.

the class JSwordPassageServiceImpl method getBookData.

/**
 * Gets the BookData set up for verse retrieval
 *
 * @param version   the version to be used
 * @param reference the reference
 * @return the BookData object
 */
BookData getBookData(final String version, final String reference) {
    final Book currentBook = this.versificationService.getBookFromVersion(version);
    final Versification v11n = this.versificationService.getVersificationForVersion(currentBook);
    try {
        Key key = currentBook.getKey(reference);
        key = normalize(key, v11n);
        return new BookData(currentBook, key);
    } catch (final NoSuchKeyException e) {
        return handlePassageLookupNSKException(reference, currentBook, v11n, e);
    }
}
Also used : NoSuchKeyException(org.crosswire.jsword.passage.NoSuchKeyException) BibleBook(org.crosswire.jsword.versification.BibleBook) Book(org.crosswire.jsword.book.Book) Versification(org.crosswire.jsword.versification.Versification) BookData(org.crosswire.jsword.book.BookData) Key(org.crosswire.jsword.passage.Key)

Aggregations

NoSuchKeyException (org.crosswire.jsword.passage.NoSuchKeyException)16 Book (org.crosswire.jsword.book.Book)13 Key (org.crosswire.jsword.passage.Key)13 Versification (org.crosswire.jsword.versification.Versification)11 BibleBook (org.crosswire.jsword.versification.BibleBook)9 TranslatedException (com.tyndalehouse.step.core.exceptions.TranslatedException)6 BookData (org.crosswire.jsword.book.BookData)5 Verse (org.crosswire.jsword.passage.Verse)5 StepInternalException (com.tyndalehouse.step.core.exceptions.StepInternalException)3 BookException (org.crosswire.jsword.book.BookException)3 Passage (org.crosswire.jsword.passage.Passage)3 VerseKey (org.crosswire.jsword.passage.VerseKey)3 LocalisedException (com.tyndalehouse.step.core.exceptions.LocalisedException)2 OsisWrapper (com.tyndalehouse.step.core.models.OsisWrapper)2 StringAndCount (com.tyndalehouse.step.core.models.StringAndCount)2 JSwordStrongNumberHelper (com.tyndalehouse.step.core.service.jsword.helpers.JSwordStrongNumberHelper)2 AbstractPassageBook (org.crosswire.jsword.book.basic.AbstractPassageBook)2 RangedPassage (org.crosswire.jsword.passage.RangedPassage)2 VerseRange (org.crosswire.jsword.passage.VerseRange)2 EntityDoc (com.tyndalehouse.step.core.data.EntityDoc)1