Search in sources :

Example 11 with File

use of org.mycore.mets.model.files.File 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

File (org.mycore.mets.model.files.File)11 FileGrp (org.mycore.mets.model.files.FileGrp)8 FLocat (org.mycore.mets.model.files.FLocat)7 PhysicalSubDiv (org.mycore.mets.model.struct.PhysicalSubDiv)7 Fptr (org.mycore.mets.model.struct.Fptr)6 PhysicalDiv (org.mycore.mets.model.struct.PhysicalDiv)6 PhysicalStructMap (org.mycore.mets.model.struct.PhysicalStructMap)6 URISyntaxException (java.net.URISyntaxException)5 ArrayList (java.util.ArrayList)5 MCRPersistenceException (org.mycore.common.MCRPersistenceException)5 IOException (java.io.IOException)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 HashMap (java.util.HashMap)4 JDOMException (org.jdom2.JDOMException)4 Mets (org.mycore.mets.model.Mets)4 SAXException (org.xml.sax.SAXException)4 Collections (java.util.Collections)3 List (java.util.List)3 Map (java.util.Map)3 Objects (java.util.Objects)3