use of biblemulticonverter.schema.versification.openscriptures.BibleVersificationSystem in project BibleMultiConverter by schierlm.
the class OpenScriptures method doImport.
@Override
public void doImport(VersificationSet versifications, String... importArgs) throws Exception {
File inputFile = new File(importArgs[0]);
ValidateXML.validateFileBeforeParsing(getSchema(), inputFile);
JAXBContext ctx = JAXBContext.newInstance(ObjectFactory.class.getPackage().getName());
Unmarshaller u = ctx.createUnmarshaller();
BibleVersificationSystem doc = (BibleVersificationSystem) u.unmarshal(inputFile);
List<Reference> allRefs = new ArrayList<>();
for (BibleBookVersification bbv : doc.getBibleBookVersification()) {
BookID bid = REFERENCE_ABBREVIATIONS.get(bbv.getReferenceAbbreviation());
if (bid == null) {
System.out.println("WARNING: Skipping " + bbv.getNameEnglish() + " [" + bbv.getReferenceAbbreviation() + "]");
continue;
}
if (bbv.getNumChapters() != bbv.getNumVerses().size())
System.out.println("WARNING: Chapter count " + bbv.getNumChapters() + " of " + bid + " does not match verse info " + bbv.getNumVerses().size());
for (NumVerses nv : bbv.getNumVerses()) {
if (nv.getChapter() == 0 && bbv.getNumVerses().size() == 1) {
System.out.println("WARNING: Changing chapter " + bid + " 0 to 1");
nv.setChapter(1);
}
if (nv.getCombinedVerses() != null || nv.getReorderedVerses() != null)
System.out.println("WARNING: Unsupported attribute for " + bid + " " + nv.getChapter());
Set<Integer> omitted = new HashSet<>();
if (nv.getOmittedVerses() != null) {
for (String num : nv.getOmittedVerses().split(",")) {
omitted.add(Integer.parseInt(num));
}
}
for (int j = 1; j <= nv.getValue(); j++) {
if (!omitted.contains(j)) {
allRefs.add(new Reference(bid, nv.getChapter(), "" + j));
}
}
}
}
versifications.getVersifications().add(Versification.fromReferenceList(importArgs[1], doc.getHeader().getWork().getTitle(), null, allRefs));
}
Aggregations