Search in sources :

Example 6 with MCRMetsFile

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);
    });
}
Also used : MCRMetsPage(org.mycore.mets.model.simple.MCRMetsPage) MCRException(org.mycore.common.MCRException) GsonBuilder(com.google.gson.GsonBuilder) MCRMetsFile(org.mycore.mets.model.simple.MCRMetsFile) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) 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) MCRMetsAltoLink(org.mycore.mets.model.simple.MCRMetsAltoLink) MCRException(org.mycore.common.MCRException)

Example 7 with MCRMetsFile

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;
}
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) MCRException(org.mycore.common.MCRException) MCRMetsAltoLink(org.mycore.mets.model.simple.MCRMetsAltoLink) MCRMetsFile(org.mycore.mets.model.simple.MCRMetsFile) MCRMetsSection(org.mycore.mets.model.simple.MCRMetsSection)

Example 8 with MCRMetsFile

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;
}
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

MCRMetsFile (org.mycore.mets.model.simple.MCRMetsFile)8 MCRMetsFileUse (org.mycore.mets.model.simple.MCRMetsFileUse)6 MCRMetsPage (org.mycore.mets.model.simple.MCRMetsPage)6 MCRMetsSection (org.mycore.mets.model.simple.MCRMetsSection)6 MCRMetsSimpleModel (org.mycore.mets.model.simple.MCRMetsSimpleModel)6 Hashtable (java.util.Hashtable)5 List (java.util.List)5 Map (java.util.Map)4 MCRException (org.mycore.common.MCRException)4 MCRMetsAltoLink (org.mycore.mets.model.simple.MCRMetsAltoLink)4 MCRMetsLink (org.mycore.mets.model.simple.MCRMetsLink)4 Document (org.jdom2.Document)3 Mets (org.mycore.mets.model.Mets)3 GsonBuilder (com.google.gson.GsonBuilder)2 AbstractMap (java.util.AbstractMap)2 ArrayList (java.util.ArrayList)2 Collectors.toList (java.util.stream.Collectors.toList)2 FileGrp (org.mycore.mets.model.files.FileGrp)2 IStructMap (org.mycore.mets.model.struct.IStructMap)2 LogicalDiv (org.mycore.mets.model.struct.LogicalDiv)2