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