Search in sources :

Example 16 with LookupOption

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

the class PassageOptionsValidationServiceImpl method trim.

@Override
public Set<LookupOption> trim(final List<LookupOption> options, final String version, List<String> extraVersions, final InterlinearMode mode, final InterlinearMode displayMode, final List<TrimmedLookupOption> trimmingExplanations) {
    // obtain error messages
    final ResourceBundle errors = ResourceBundle.getBundle("ErrorBundle", this.clientSessionProvider.get().getLocale());
    if (options.isEmpty()) {
        return new HashSet<>();
    }
    final Set<LookupOption> result = getUserOptionsForVersion(errors, options, version, extraVersions, trimmingExplanations);
    // now trim further depending on modes required:
    switch(displayMode) {
        case COLUMN:
        case COLUMN_COMPARE:
        case INTERLEAVED:
        case INTERLEAVED_COMPARE:
            removeInterleavingOptions(errors, trimmingExplanations, result, !mode.equals(displayMode));
            break;
        case INTERLINEAR:
            explainRemove(errors, NOTES, result, trimmingExplanations, !mode.equals(displayMode), errors.getString("option_not_available_interlinear"));
            result.add(LookupOption.VERSE_NEW_LINE);
            break;
        case NONE:
            break;
        default:
            break;
    }
    return result;
}
Also used : LookupOption(com.tyndalehouse.step.core.models.LookupOption) TrimmedLookupOption(com.tyndalehouse.step.core.models.TrimmedLookupOption) ResourceBundle(java.util.ResourceBundle) HashSet(java.util.HashSet)

Example 17 with LookupOption

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

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

the class BibleInformationServiceImpl method getAllFeatures.

/**
 * Gets the all features.
 *
 * @return the all features
 */
@Override
public List<EnrichedLookupOption> getAllFeatures() {
    final LookupOption[] lo = LookupOption.values();
    final List<EnrichedLookupOption> elo = new ArrayList<EnrichedLookupOption>(lo.length + 1);
    for (final LookupOption lookupOption : lo) {
        final String displayName = lookupOption.name();
        if (isNotBlank(displayName)) {
            elo.add(new EnrichedLookupOption(displayName, lookupOption.toString(), lookupOption.isEnabledByDefault()));
        }
    }
    return elo;
}
Also used : LookupOption(com.tyndalehouse.step.core.models.LookupOption) TrimmedLookupOption(com.tyndalehouse.step.core.models.TrimmedLookupOption) EnrichedLookupOption(com.tyndalehouse.step.core.models.EnrichedLookupOption) ArrayList(java.util.ArrayList) EnrichedLookupOption(com.tyndalehouse.step.core.models.EnrichedLookupOption)

Example 19 with LookupOption

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

the class InterleavedOsisReader method main.

/**
 * Just shows XML on the stdout
 *
 * @param args not used
 * @throws Exception any kind of exception
 */
public static void main(final String[] args) throws Exception {
    final String[] versions = new String[] { "OSMHB", "ESV_th" };
    final String ref = "Mic.5";
    final boolean unicodeBreakDown = false;
    final boolean compare = true;
    final InterlinearMode interlinearMode = InterlinearMode.INTERLEAVED;
    boolean format = false;
    final Format prettyFormat = format ? Format.getPrettyFormat() : Format.getRawFormat();
    final Book currentBook = Books.installed().getBook(versions[0]);
    final Book[] books = new Book[versions.length];
    for (int ii = 0; ii < versions.length; ii++) {
        books[ii] = Books.installed().getBook(versions[ii]);
    }
    final BookData bookData = new BookData(books, currentBook.getKey(ref), compare);
    final Element osisFragment = bookData.getOsisFragment();
    final XMLOutputter xmlOutputter = new XMLOutputter(prettyFormat);
    final String inputString = xmlOutputter.outputString(osisFragment);
    LOGGER.debug(inputString);
    if (unicodeBreakDown) {
        outputUnicode(inputString);
    }
    // do the test
    final JSwordPassageServiceImpl jsi = new JSwordPassageServiceImpl(TestUtils.mockVersificationService(), null, null, null, TestUtils.mockVersionResolver(), null);
    final List<LookupOption> options = new ArrayList<LookupOption>();
    options.add(LookupOption.CHAPTER_BOOK_VERSE_NUMBER);
    // options.add(LookupOption.HEADINGS_ONLY);
    // options.add(LookupOption.HEADINGS);
    // options.add(LookupOption.CHAPTER_BOOK_VERSE_NUMBER);
    final String osisText = jsi.getInterleavedVersions(versions, ref, options, interlinearMode, "en").getValue();
    LOGGER.debug(osisText);
    final SAXBuilder sb = new SAXBuilder();
    if (unicodeBreakDown) {
        outputUnicode(osisText);
    }
}
Also used : JSwordPassageServiceImpl(com.tyndalehouse.step.core.service.jsword.impl.JSwordPassageServiceImpl) XMLOutputter(org.jdom2.output.XMLOutputter) SAXBuilder(org.jdom2.input.SAXBuilder) LookupOption(com.tyndalehouse.step.core.models.LookupOption) Element(org.jdom2.Element) ArrayList(java.util.ArrayList) Format(org.jdom2.output.Format) Book(org.crosswire.jsword.book.Book) InterlinearMode(com.tyndalehouse.step.core.models.InterlinearMode) BookData(org.crosswire.jsword.book.BookData)

Example 20 with LookupOption

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

the class OsisReader method main.

/**
 * Just shows XML on the stdout
 *
 * @param args not used
 * @throws Exception any kind of exception
 */
public static void main(final String[] args) throws Exception {
    final String version = "ESV_th";
    final String ref = "Gen.2";
    boolean format = true;
    final Book currentBook = Books.installed().getBook(version);
    final BookData bookData = new BookData(currentBook, currentBook.getKey(ref));
    final Element osisFragment = bookData.getOsisFragment();
    final XMLOutputter xmlOutputter = new XMLOutputter(format ? Format.getPrettyFormat() : Format.getRawFormat());
    LOGGER.debug(xmlOutputter.outputString(osisFragment));
    // do the test
    final JSwordPassageServiceImpl jsi = new JSwordPassageServiceImpl(TestUtils.mockVersificationService(), null, null, null, TestUtils.mockVersionResolver(), null);
    final List<LookupOption> options = new ArrayList<LookupOption>();
    // options.add(LookupOption.DIVIDE_HEBREW);
    options.add(LookupOption.NOTES);
    options.add(LookupOption.HEADINGS);
    options.add(LookupOption.GREEK_ACCENTS);
    final String osisText = jsi.getOsisText(version, ref, options, "ESV_th", InterlinearMode.NONE).getValue();
    final SAXBuilder sb = new SAXBuilder();
    try {
        final Document d = sb.build(new StringReader(osisText));
        LOGGER.debug("Transformed is:\n {}", xmlOutputter.outputString(d));
        xmlOutputter.outputString(d);
    } catch (final JDOMParseException e) {
        LOGGER.debug("Transformed is:\n [{}]", osisText);
    }
    // InterleavedOsisReader.outputUnicode(osisText);
    LOGGER.debug("Double whitespace: {}", osisText.contains("  "));
}
Also used : JSwordPassageServiceImpl(com.tyndalehouse.step.core.service.jsword.impl.JSwordPassageServiceImpl) JDOMParseException(org.jdom2.input.JDOMParseException) XMLOutputter(org.jdom2.output.XMLOutputter) SAXBuilder(org.jdom2.input.SAXBuilder) LookupOption(com.tyndalehouse.step.core.models.LookupOption) Element(org.jdom2.Element) ArrayList(java.util.ArrayList) Document(org.jdom2.Document) Book(org.crosswire.jsword.book.Book) AbstractPassageBook(org.crosswire.jsword.book.basic.AbstractPassageBook) StringReader(java.io.StringReader) BookData(org.crosswire.jsword.book.BookData)

Aggregations

LookupOption (com.tyndalehouse.step.core.models.LookupOption)20 ArrayList (java.util.ArrayList)11 OsisWrapper (com.tyndalehouse.step.core.models.OsisWrapper)7 Book (org.crosswire.jsword.book.Book)7 BookData (org.crosswire.jsword.book.BookData)6 SAXBuilder (org.jdom2.input.SAXBuilder)6 XMLOutputter (org.jdom2.output.XMLOutputter)6 Test (org.junit.Test)6 TrimmedLookupOption (com.tyndalehouse.step.core.models.TrimmedLookupOption)5 StringReader (java.io.StringReader)5 Document (org.jdom2.Document)5 Element (org.jdom2.Element)5 BibleBook (org.crosswire.jsword.versification.BibleBook)4 EnrichedLookupOption (com.tyndalehouse.step.core.models.EnrichedLookupOption)3 InterlinearMode (com.tyndalehouse.step.core.models.InterlinearMode)3 StepInternalException (com.tyndalehouse.step.core.exceptions.StepInternalException)2 JSwordPassageServiceImpl (com.tyndalehouse.step.core.service.jsword.impl.JSwordPassageServiceImpl)2 HashSet (java.util.HashSet)2 AbstractPassageBook (org.crosswire.jsword.book.basic.AbstractPassageBook)2 Key (org.crosswire.jsword.passage.Key)2