Search in sources :

Example 1 with Seq

use of org.mycore.mets.model.struct.Seq in project mycore by MyCoRe-Org.

the class MCRMETSHierarchyGenerator method copyFptr.

private Optional<Fptr> copyFptr(FileGrp oldGrp, FileGrp newGrp, Fptr oldFptr) {
    Fptr newFptr = new Fptr();
    for (Seq oldSeq : oldFptr.getSeqList()) {
        Seq newSeq = new Seq();
        for (Area oldArea : oldSeq.getAreaList()) {
            if (oldArea.getBetype() == null) {
                continue;
            }
            String oldFileID = oldArea.getFileId();
            File oldFile = oldGrp.getFileById(oldFileID);
            String href = oldFile.getFLocat().getHref();
            File newFile = newGrp.getFileByHref(href);
            Area newArea = new Area();
            newArea.setBegin(oldArea.getBegin());
            newArea.setEnd(oldArea.getEnd());
            newArea.setFileId(newFile.getId());
            newArea.setBetype("IDREF");
            newSeq.getAreaList().add(newArea);
        }
        if (!newSeq.getAreaList().isEmpty()) {
            newFptr.getSeqList().add(newSeq);
        }
    }
    return newFptr.getSeqList().isEmpty() ? Optional.empty() : Optional.of(newFptr);
}
Also used : Area(org.mycore.mets.model.struct.Area) Fptr(org.mycore.mets.model.struct.Fptr) File(org.mycore.mets.model.files.File) Seq(org.mycore.mets.model.struct.Seq)

Example 2 with Seq

use of org.mycore.mets.model.struct.Seq in project mycore by MyCoRe-Org.

the class MCRSimpleModelXMLConverter method buildLogicalSubDiv.

private static void buildLogicalSubDiv(MCRMetsSection metsSection, LogicalDiv parent, Map<MCRMetsSection, String> sectionIdMap, Map<String, String> idToNewIDMap) {
    String id = metsSection.getId();
    LogicalDiv logicalSubDiv = new LogicalDiv(id, metsSection.getType(), metsSection.getLabel());
    if (metsSection.getAltoLinks().size() > 0) {
        Fptr fptr = new Fptr();
        List<Seq> seqList = fptr.getSeqList();
        Seq seq = new Seq();
        seqList.add(seq);
        metsSection.getAltoLinks().forEach(al -> {
            Area area = new Area();
            seq.getAreaList().add(area);
            area.setBetype("IDREF");
            area.setBegin(al.getBegin());
            area.setEnd(al.getEnd());
            String oldID = al.getFile().getId();
            if (!idToNewIDMap.containsKey(oldID)) {
                throw new MCRException("Could not get new id for: " + oldID);
            }
            area.setFileId(idToNewIDMap.get(oldID));
        });
        logicalSubDiv.getFptrList().add(fptr);
    }
    sectionIdMap.put(metsSection, id);
    parent.add(logicalSubDiv);
    int count = 1;
    for (MCRMetsSection section : metsSection.getMetsSectionList()) {
        buildLogicalSubDiv(section, logicalSubDiv, sectionIdMap, idToNewIDMap);
    }
}
Also used : LogicalDiv(org.mycore.mets.model.struct.LogicalDiv) Area(org.mycore.mets.model.struct.Area) MCRException(org.mycore.common.MCRException) Fptr(org.mycore.mets.model.struct.Fptr) Seq(org.mycore.mets.model.struct.Seq) MCRMetsSection(org.mycore.mets.model.simple.MCRMetsSection)

Aggregations

Area (org.mycore.mets.model.struct.Area)2 Fptr (org.mycore.mets.model.struct.Fptr)2 Seq (org.mycore.mets.model.struct.Seq)2 MCRException (org.mycore.common.MCRException)1 File (org.mycore.mets.model.files.File)1 MCRMetsSection (org.mycore.mets.model.simple.MCRMetsSection)1 LogicalDiv (org.mycore.mets.model.struct.LogicalDiv)1