use of org.mycore.mets.model.simple.MCRMetsPage in project mycore by MyCoRe-Org.
the class MCRSimpleModelXMLConverter method toXML.
/**
* Converts MetsSimpleModel to XML
* @param msm the MetsSimpleModel which should be converted
* @return xml
*/
public static Document toXML(MCRMetsSimpleModel msm) {
Mets mets = new Mets();
Hashtable<MCRMetsPage, String> pageIdMap = new Hashtable<>();
Map<String, String> idToNewIDMap = new Hashtable<>();
buildPhysicalPages(msm, mets, pageIdMap, idToNewIDMap);
Hashtable<MCRMetsSection, String> sectionIdMap = new Hashtable<>();
buildLogicalPages(msm, mets, sectionIdMap, idToNewIDMap);
StructLink structLink = mets.getStructLink();
msm.getSectionPageLinkList().stream().map((metsLink) -> {
MCRMetsSection section = metsLink.getFrom();
MCRMetsPage page = metsLink.getTo();
String fromId = sectionIdMap.get(section);
String toId = pageIdMap.get(page);
return new SmLink(fromId, toId);
}).forEach(structLink::addSmLink);
return mets.asDocument();
}
use of org.mycore.mets.model.simple.MCRMetsPage 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