Search in sources :

Example 6 with MCRMetsPage

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();
}
Also used : PhysicalDiv(org.mycore.mets.model.struct.PhysicalDiv) MCRMetsPage(org.mycore.mets.model.simple.MCRMetsPage) StructLink(org.mycore.mets.model.struct.StructLink) LOCTYPE(org.mycore.mets.model.struct.LOCTYPE) Area(org.mycore.mets.model.struct.Area) MCRException(org.mycore.common.MCRException) Document(org.jdom2.Document) FileGrp(org.mycore.mets.model.files.FileGrp) Map(java.util.Map) MCRMetsFileUse(org.mycore.mets.model.simple.MCRMetsFileUse) File(org.mycore.mets.model.files.File) Hashtable(java.util.Hashtable) PhysicalStructMap(org.mycore.mets.model.struct.PhysicalStructMap) Mets(org.mycore.mets.model.Mets) UUID(java.util.UUID) Seq(org.mycore.mets.model.struct.Seq) LogicalDiv(org.mycore.mets.model.struct.LogicalDiv) PhysicalSubDiv(org.mycore.mets.model.struct.PhysicalSubDiv) SmLink(org.mycore.mets.model.struct.SmLink) List(java.util.List) Fptr(org.mycore.mets.model.struct.Fptr) LogicalStructMap(org.mycore.mets.model.struct.LogicalStructMap) FLocat(org.mycore.mets.model.files.FLocat) MCRMetsSection(org.mycore.mets.model.simple.MCRMetsSection) MCRMetsSimpleModel(org.mycore.mets.model.simple.MCRMetsSimpleModel) SmLink(org.mycore.mets.model.struct.SmLink) Mets(org.mycore.mets.model.Mets) Hashtable(java.util.Hashtable) MCRMetsPage(org.mycore.mets.model.simple.MCRMetsPage) StructLink(org.mycore.mets.model.struct.StructLink) MCRMetsSection(org.mycore.mets.model.simple.MCRMetsSection)

Example 7 with MCRMetsPage

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;
}
Also used : MCRMetsPage(org.mycore.mets.model.simple.MCRMetsPage) Mets(org.mycore.mets.model.Mets) MCRException(org.mycore.common.MCRException) IStructMap(org.mycore.mets.model.struct.IStructMap) LogicalDiv(org.mycore.mets.model.struct.LogicalDiv) PhysicalSubDiv(org.mycore.mets.model.struct.PhysicalSubDiv) ArrayList(java.util.ArrayList) Document(org.jdom2.Document) MCRMetsFile(org.mycore.mets.model.simple.MCRMetsFile) AbstractMap(java.util.AbstractMap) List(java.util.List) FileGrp(org.mycore.mets.model.files.FileGrp) LogicalStructMap(org.mycore.mets.model.struct.LogicalStructMap) Map(java.util.Map) MCRMetsAltoLink(org.mycore.mets.model.simple.MCRMetsAltoLink) MCRMetsFileUse(org.mycore.mets.model.simple.MCRMetsFileUse) MCRMetsSection(org.mycore.mets.model.simple.MCRMetsSection) MCRMetsSimpleModel(org.mycore.mets.model.simple.MCRMetsSimpleModel) Hashtable(java.util.Hashtable) MCRMetsLink(org.mycore.mets.model.simple.MCRMetsLink) PhysicalStructMap(org.mycore.mets.model.struct.PhysicalStructMap) AbstractMap(java.util.AbstractMap) PhysicalStructMap(org.mycore.mets.model.struct.PhysicalStructMap) MCRMetsPage(org.mycore.mets.model.simple.MCRMetsPage) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) PhysicalSubDiv(org.mycore.mets.model.struct.PhysicalSubDiv)

Aggregations

MCRMetsPage (org.mycore.mets.model.simple.MCRMetsPage)7 MCRMetsSection (org.mycore.mets.model.simple.MCRMetsSection)5 Hashtable (java.util.Hashtable)4 MCRMetsFile (org.mycore.mets.model.simple.MCRMetsFile)4 MCRMetsFileUse (org.mycore.mets.model.simple.MCRMetsFileUse)4 MCRMetsSimpleModel (org.mycore.mets.model.simple.MCRMetsSimpleModel)4 List (java.util.List)3 Map (java.util.Map)3 MCRException (org.mycore.common.MCRException)3 Mets (org.mycore.mets.model.Mets)3 FileGrp (org.mycore.mets.model.files.FileGrp)3 MCRMetsLink (org.mycore.mets.model.simple.MCRMetsLink)3 PhysicalStructMap (org.mycore.mets.model.struct.PhysicalStructMap)3 PhysicalSubDiv (org.mycore.mets.model.struct.PhysicalSubDiv)3 Document (org.jdom2.Document)2 FLocat (org.mycore.mets.model.files.FLocat)2 File (org.mycore.mets.model.files.File)2 MCRMetsAltoLink (org.mycore.mets.model.simple.MCRMetsAltoLink)2 Fptr (org.mycore.mets.model.struct.Fptr)2 LogicalDiv (org.mycore.mets.model.struct.LogicalDiv)2