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);
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations