diff --git a/Kitodo-DataFormat/src/main/java/org/kitodo/dataformat/access/DivXmlElementAccess.java b/Kitodo-DataFormat/src/main/java/org/kitodo/dataformat/access/DivXmlElementAccess.java index 7ebd2327d83..df63a7350e7 100644 --- a/Kitodo-DataFormat/src/main/java/org/kitodo/dataformat/access/DivXmlElementAccess.java +++ b/Kitodo-DataFormat/src/main/java/org/kitodo/dataformat/access/DivXmlElementAccess.java @@ -15,6 +15,7 @@ import java.net.URI; import java.nio.charset.StandardCharsets; import java.util.Collection; +import java.util.Comparator; import java.util.HashSet; import java.util.LinkedList; import java.util.List; @@ -254,8 +255,9 @@ DivType toDiv(Map physicalDivisionIDs, LinkedList Pair.of(metsReferrerId, physicalDivisionId)).collect(Collectors.toList())); + smLinkData.addAll(super.getViews().stream().map(View::getPhysicalDivision) + .sorted(Comparator.comparing(PhysicalDivision::getOrder)).map(physicalDivisionIDs::get) + .map(physicalDivisionId -> Pair.of(metsReferrerId, physicalDivisionId)).collect(Collectors.toList())); Optional optionalDmdSec = createMdSec(super.getMetadata(), MdSec.DMD_SEC); if (optionalDmdSec.isPresent()) { diff --git a/Kitodo-DataFormat/src/main/java/org/kitodo/dataformat/access/MetsXmlElementAccess.java b/Kitodo-DataFormat/src/main/java/org/kitodo/dataformat/access/MetsXmlElementAccess.java index f27a6fb5642..52a8f45ec59 100644 --- a/Kitodo-DataFormat/src/main/java/org/kitodo/dataformat/access/MetsXmlElementAccess.java +++ b/Kitodo-DataFormat/src/main/java/org/kitodo/dataformat/access/MetsXmlElementAccess.java @@ -427,18 +427,19 @@ private DivType generatePhysicalStructMapRecursive(PhysicalDivision physicalDivi */ private StructLink createStructLink(LinkedList> smLinkData) { StructLink structLink = new StructLink(); - structLink.getSmLinkOrSmLinkGrp().addAll(smLinkData.parallelStream().map(entry -> { - if (Objects.isNull(entry.getLeft())) { - throw new IllegalArgumentException("smLinkData.entry[?].left must not be null"); + List content = structLink.getSmLinkOrSmLinkGrp(); + for (Pair link : smLinkData) { + if (Objects.isNull(link.getLeft())) { + throw new IllegalArgumentException("link.left must not be null"); } - if (Objects.isNull(entry.getRight())) { - throw new IllegalArgumentException("smLinkData.entry[?].right must not be null"); + if (Objects.isNull(link.getRight())) { + throw new IllegalArgumentException("link.right must not be null"); } SmLink smLink = new SmLink(); - smLink.setFrom(entry.getLeft()); - smLink.setTo(entry.getRight()); - return smLink; - }).collect(Collectors.toList())); + smLink.setFrom(link.getLeft()); + smLink.setTo(link.getRight()); + content.add(smLink); + } return structLink; }