Search in sources :

Example 1 with MCRMetsAltoLink

use of org.mycore.mets.model.simple.MCRMetsAltoLink 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 2 with MCRMetsAltoLink

use of org.mycore.mets.model.simple.MCRMetsAltoLink 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)

Aggregations

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