use of org.mycore.mets.model.simple.MCRMetsFile in project mycore by MyCoRe-Org.
the class MCRJSONSimpleModelConverter method processSections.
private static void processSections(MCRMetsSection current, Hashtable<String, MCRMetsSection> idSectionTable, Map<String, MCRMetsFile> idFileMap) {
idSectionTable.put(current.getId(), current);
final List<MCRMetsAltoLink> altoLinks = current.getAltoLinks().stream().map(altoLink -> {
if (altoLink instanceof MCRAltoLinkTypeAdapter.MCRAltoLinkPlaceHolder) {
MCRAltoLinkTypeAdapter.MCRAltoLinkPlaceHolder ph = (MCRAltoLinkTypeAdapter.MCRAltoLinkPlaceHolder) altoLink;
if (!idFileMap.containsKey(ph.getFileID())) {
throw new MCRException("Could not parse link from section to alto! (FileID of alto not found in file list)");
}
return new MCRMetsAltoLink(idFileMap.get(ph.getFileID()), ph.getBegin(), ph.getEnd());
}
return altoLink;
}).collect(toList());
current.setAltoLinks(altoLinks);
current.getMetsSectionList().forEach((child) -> {
child.setParent(current);
processSections(child, idSectionTable, idFileMap);
});
}
use of org.mycore.mets.model.simple.MCRMetsFile in project mycore by MyCoRe-Org.
the class MCRXMLSimpleModelConverter method buildSection.
private static MCRMetsSection buildSection(LogicalDiv current, Map<String, MCRMetsSection> idSectionMap, MCRMetsSection parent, Map<String, MCRMetsFile> idFileMap) {
MCRMetsSection metsSection = new MCRMetsSection();
metsSection.setId(current.getId());
metsSection.setLabel(current.getLabel());
metsSection.setType(current.getType());
metsSection.setParent(parent);
current.getFptrList().forEach(fptr -> fptr.getSeqList().forEach(seq -> {
seq.getAreaList().forEach(area -> {
String fileId = area.getFileId();
String begin = area.getBegin();
String end = area.getEnd();
if (!idFileMap.containsKey(fileId)) {
throw new MCRException("No file with id " + fileId + " found!");
}
MCRMetsFile file = idFileMap.get(fileId);
MCRMetsAltoLink e = new MCRMetsAltoLink(file, begin, end);
metsSection.addAltoLink(e);
});
}));
if (idSectionMap != null) {
idSectionMap.put(current.getId(), metsSection);
}
List<MCRMetsSection> childSectionList = metsSection.getMetsSectionList();
current.getChildren().stream().map(section -> MCRXMLSimpleModelConverter.buildSection(section, idSectionMap, metsSection, idFileMap)).forEachOrdered(metsSection::addSection);
return metsSection;
}
use of org.mycore.mets.model.simple.MCRMetsFile in project mycore by MyCoRe-Org.
the class MCRXMLSimpleModelConverter method buildPageList.
private static List<MCRMetsPage> buildPageList(Mets mets, Map<String, MCRMetsPage> idPageMap, Map<String, MCRMetsFile> idFileMap) {
PhysicalStructMap physicalStructMap = (PhysicalStructMap) mets.getStructMap(PhysicalStructMap.TYPE);
List<PhysicalSubDiv> physicalSubDivs = physicalStructMap.getDivContainer().getChildren();
List<MCRMetsPage> result = new ArrayList<>();
physicalSubDivs.stream().map((physicalSubDiv) -> {
// Convert PhysicalSubDiv to MetsPage
MCRMetsPage metsPage = new MCRMetsPage();
metsPage.setId(physicalSubDiv.getId());
metsPage.setOrderLabel(physicalSubDiv.getOrderLabel());
metsPage.setContentIds(physicalSubDiv.getContentids());
// Add all MetsFile to the MetsPage
List<MCRMetsFile> fileList = metsPage.getFileList();
physicalSubDiv.getChildren().stream().map(file -> idFileMap.get(file.getFileId())).forEachOrdered(fileList::add);
// return a entry of physicalSubDiv.id and MetsPage
return new AbstractMap.SimpleEntry<>(physicalSubDiv.getId(), metsPage);
}).forEachOrdered((entry) -> {
// Put page to list
result.add(entry.getValue());
// Put that generated entry to a Hashtable
idPageMap.put(entry.getKey(), entry.getValue());
});
return result;
}
Aggregations