use of com.tyndalehouse.step.core.models.LookupOption in project step by STEPBible.
the class JSwordPassageServiceImplTest method testComparing.
/**
* tests that the XSLT transformation is handled correctly
*
* @throws BookException uncaught exception
* @throws NoSuchKeyException uncaught exception
* @throws IOException uncaught exception
* @throws JDOMException uncaught exception
*/
@Test
public void testComparing() throws BookException, NoSuchKeyException, JDOMException, IOException {
final Book currentBook = Books.installed().getBook("ESV_th");
final Book secondaryBook = Books.installed().getBook("KJV");
final String reference = "Psalm.3";
final BookData bookData = new BookData(new Book[] { currentBook, secondaryBook }, currentBook.getKey(reference), true);
final Element osisFragment = bookData.getOsisFragment();
final XMLOutputter xmlOutputter = new XMLOutputter(Format.getPrettyFormat());
LOGGER.info(xmlOutputter.outputString(osisFragment));
// do the test
final List<LookupOption> options = new ArrayList<LookupOption>();
final String osisText = this.jsi.getInterleavedVersions(new String[] { currentBook.getInitials(), secondaryBook.getInitials() }, reference, options, InterlinearMode.INTERLEAVED_COMPARE, "en").getValue();
final SAXBuilder sb = new SAXBuilder();
final Document d = sb.build(new StringReader(osisText));
LOGGER.info("\n {}", xmlOutputter.outputString(d));
Assert.assertTrue(osisText.contains("span"));
}
use of com.tyndalehouse.step.core.models.LookupOption in project step by STEPBible.
the class JSwordPassageServiceImpl method setOptions.
/**
* This method sets up the options for the XSLT transformation. Note: the set of options is trimmed to those
* actually available
*
* @param tsep the xslt transformer
* @param options the options available
* @param books the version to initialise a potential interlinear with
*/
protected void setOptions(final TransformingSAXEventProvider tsep, final List<LookupOption> options, final Book[] books) {
final boolean isHebrew = JSwordUtils.isAncientHebrewBook(books);
final boolean isGreek = JSwordUtils.isAncientGreekBook(books);
for (final LookupOption lookupOption : options) {
if (lookupOption.getXsltParameterName() != null) {
tsep.setParameter(lookupOption.getXsltParameterName(), true);
switch(lookupOption) {
case VERSE_NUMBERS:
tsep.setParameter(LookupOption.TINY_VERSE_NUMBERS.getXsltParameterName(), true);
break;
case CHAPTER_BOOK_VERSE_NUMBER:
tsep.setParameter(LookupOption.VERSE_NUMBERS.getXsltParameterName(), true);
break;
case MORPHOLOGY:
tsep.setParameter("morphologyProvider", this.morphologyProvider);
break;
case ENGLISH_VOCAB:
case ZH_TW_VOCAB:
case ZH_VOCAB:
case ES_VOCAB:
case TRANSLITERATION:
case GREEK_VOCAB:
case TRANSLITERATE_ORIGINAL:
tsep.setParameter("vocabProvider", this.vocabProvider);
break;
case COLOUR_CODE:
tsep.setParameter("colorCodingProvider", this.colorCoder);
break;
case GREEK_ACCENTS:
if (isGreek) {
tsep.setParameter("RemovePointing", "false");
tsep.setParameter("RemoveVowels", "false");
}
break;
case HEBREW_VOWELS:
if (isHebrew) {
tsep.setParameter("RemoveVowels", "false");
}
break;
case HEBREW_ACCENTS:
if (isHebrew) {
tsep.setParameter("RemovePointing", "false");
tsep.setParameter("RemoveVowels", "false");
}
break;
}
}
}
// if no greek or hebrew, then override to false
if (!isGreek && !isHebrew) {
tsep.setParameter("RemovePointing", false);
tsep.setParameter("RemoveVowels", false);
}
if (!books[0].getBookMetaData().isLeftToRight()) {
tsep.setParameter(LookupOption.VERSE_NEW_LINE.getXsltParameterName(), true);
}
tsep.setParameter("direction", books[0].getBookMetaData().isLeftToRight() ? "ltr" : "rtl");
tsep.setParameter("baseVersion", this.resolver.getShortName(books[0].getInitials()));
}
use of com.tyndalehouse.step.core.models.LookupOption in project step by STEPBible.
the class JSwordSearchServiceImpl method getResultsFromTrimmedKeys.
public SearchResult getResultsFromTrimmedKeys(final SearchQuery sq, final String[] versions, final int total, final Key newResults, final LookupOption... options) {
final long startRefRetrieval = System.currentTimeMillis();
// if context > 0, then we need to add verse numbers:
final List<LookupOption> lookupOptions = new ArrayList<LookupOption>();
Collections.addAll(lookupOptions, options);
lookupOptions.add(LookupOption.CHAPTER_BOOK_VERSE_NUMBER);
lookupOptions.add(LookupOption.HEBREW_VOWELS);
lookupOptions.add(LookupOption.GREEK_ACCENTS);
// lookupOptions.add(LookupOption.HEBREW_ACCENTS); Removed because we want to show Hebrew accents only if the user has selected this option.
final SearchResult r = new SearchResult();
getPassagesForResults(r, versions, newResults, sq.getContext(), lookupOptions, sq.getInterlinearMode());
return getSearchResult(r, total, System.currentTimeMillis() - startRefRetrieval);
}
use of com.tyndalehouse.step.core.models.LookupOption in project step by STEPBible.
the class JSwordPassageServiceImplTest method testXslTransformation.
/**
* tests that the XSLT transformation is handled correctly
*
* @throws BookException uncaught exception
* @throws NoSuchKeyException uncaught exception
* @throws IOException uncaught exception
* @throws JDOMException uncaught exception
*/
@Test
public void testXslTransformation() throws BookException, NoSuchKeyException, JDOMException, IOException {
final Book currentBook = Books.installed().getBook("KJV");
final BookData bookData = new BookData(currentBook, currentBook.getKey("Romans 1:4"));
final Element osisFragment = bookData.getOsisFragment();
final XMLOutputter xmlOutputter = new XMLOutputter(Format.getPrettyFormat());
LOGGER.trace(xmlOutputter.outputString(osisFragment));
// do the test
final List<LookupOption> options = new ArrayList<LookupOption>();
final String osisText = this.jsi.getOsisText("KJV", "Romans 1:4", options, "", InterlinearMode.NONE).getValue();
final SAXBuilder sb = new SAXBuilder();
final Document d = sb.build(new StringReader(osisText));
LOGGER.trace("\n {}", xmlOutputter.outputString(d));
Assert.assertTrue(osisText.contains("span"));
}
use of com.tyndalehouse.step.core.models.LookupOption in project step by STEPBible.
the class JSwordPassageServiceImplTest method testInterlinearTransformation.
/**
* tests what happens when we select interlinear
*
* @throws NoSuchKeyException uncaught exceptions
* @throws BookException uncaught exception
* @throws IOException uncaught exception
* @throws JDOMException uncaught exception
*/
@Test
public void testInterlinearTransformation() throws NoSuchKeyException, BookException, JDOMException, IOException {
final Book currentBook = Books.installed().getBook("OSMHB");
final BookData bookData = new BookData(currentBook, currentBook.getKey("Ps.51"));
final Element osisFragment = bookData.getOsisFragment();
final XMLOutputter xmlOutputter = new XMLOutputter(Format.getPrettyFormat());
LOGGER.trace(xmlOutputter.outputString(osisFragment));
// do the test
final List<LookupOption> options = new ArrayList<LookupOption>();
// options.add(INTERLINEAR);
final String osisText = this.jsi.getOsisText("OSMHB", "Ps.51", options, "ESV_th", InterlinearMode.INTERLINEAR).getValue();
final SAXBuilder sb = new SAXBuilder();
final Document d = sb.build(new StringReader(osisText));
LOGGER.trace("\n {}", xmlOutputter.outputString(d));
Assert.assertTrue(osisText.contains("span class='interlinear'"));
}
Aggregations