Search in sources :

Example 6 with FLocat

use of org.mycore.mets.model.files.FLocat in project mycore by MyCoRe-Org.

the class MCRSimpleModelXMLConverter method buildPhysicalPages.

private static void buildPhysicalPages(MCRMetsSimpleModel msm, Mets mets, Map<MCRMetsPage, String> pageIdMap, Map<String, String> idToNewIDMap) {
    List<MCRMetsPage> pageList = msm.getMetsPageList();
    PhysicalStructMap structMap = (PhysicalStructMap) mets.getStructMap(PhysicalStructMap.TYPE);
    structMap.setDivContainer(new PhysicalDiv(PHYSICAL_ID_PREFIX + UUID.randomUUID(), PhysicalDiv.TYPE_PHYS_SEQ));
    for (MCRMetsPage page : pageList) {
        String id = page.getId();
        PhysicalSubDiv physicalSubDiv = new PhysicalSubDiv(id, DEFAULT_PHYSICAL_TYPE);
        String orderLabel = page.getOrderLabel();
        if (orderLabel != null) {
            physicalSubDiv.setOrderLabel(orderLabel);
        }
        String contentIds = page.getContentIds();
        if (contentIds != null) {
            physicalSubDiv.setContentids(contentIds);
        }
        structMap.getDivContainer().add(physicalSubDiv);
        pageIdMap.put(page, id);
        page.getFileList().forEach((simpleFile) -> {
            String href = simpleFile.getHref();
            String fileID = simpleFile.getId();
            String mimeType = simpleFile.getMimeType();
            MCRMetsFileUse use = simpleFile.getUse();
            idToNewIDMap.put(simpleFile.getId(), fileID);
            File file = new File(fileID, mimeType);
            FLocat fLocat = new FLocat(LOCTYPE.URL, href);
            file.setFLocat(fLocat);
            FileGrp fileGrp = getFileGroup(mets, use);
            fileGrp.addFile(file);
            physicalSubDiv.add(new Fptr(fileID));
        });
    }
}
Also used : PhysicalStructMap(org.mycore.mets.model.struct.PhysicalStructMap) MCRMetsPage(org.mycore.mets.model.simple.MCRMetsPage) FileGrp(org.mycore.mets.model.files.FileGrp) Fptr(org.mycore.mets.model.struct.Fptr) FLocat(org.mycore.mets.model.files.FLocat) File(org.mycore.mets.model.files.File) PhysicalDiv(org.mycore.mets.model.struct.PhysicalDiv) MCRMetsFileUse(org.mycore.mets.model.simple.MCRMetsFileUse) PhysicalSubDiv(org.mycore.mets.model.struct.PhysicalSubDiv)

Aggregations

FLocat (org.mycore.mets.model.files.FLocat)6 File (org.mycore.mets.model.files.File)6 FileGrp (org.mycore.mets.model.files.FileGrp)4 URISyntaxException (java.net.URISyntaxException)3 MCRPersistenceException (org.mycore.common.MCRPersistenceException)3 Fptr (org.mycore.mets.model.struct.Fptr)3 PhysicalDiv (org.mycore.mets.model.struct.PhysicalDiv)3 PhysicalStructMap (org.mycore.mets.model.struct.PhysicalStructMap)3 PhysicalSubDiv (org.mycore.mets.model.struct.PhysicalSubDiv)3 IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Element (org.jdom2.Element)2 JDOMException (org.jdom2.JDOMException)2 MCRMetsFileUse (org.mycore.mets.model.simple.MCRMetsFileUse)2 SAXException (org.xml.sax.SAXException)2 OutputStream (java.io.OutputStream)1 URLDecoder (java.net.URLDecoder)1 FileVisitResult (java.nio.file.FileVisitResult)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1