Skip to content

Commit

Permalink
Merge pull request kitodo#5966 from matthias-ronge/issue-5964_master
Browse files Browse the repository at this point in the history
Save SM links in order
  • Loading branch information
solth authored Apr 11, 2024
2 parents b416e9c + 72654e6 commit 2c9a15c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -254,8 +255,9 @@ DivType toDiv(Map<PhysicalDivision, String> physicalDivisionIDs, LinkedList<Pair
}
div.setORDERLABEL(super.getOrderlabel());
div.setTYPE(super.getType());
smLinkData.addAll(super.getViews().stream().map(View::getPhysicalDivision).map(physicalDivisionIDs::get)
.map(physicalDivisionId -> 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<MdSecType> optionalDmdSec = createMdSec(super.getMetadata(), MdSec.DMD_SEC);
if (optionalDmdSec.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,18 +427,19 @@ private DivType generatePhysicalStructMapRecursive(PhysicalDivision physicalDivi
*/
private StructLink createStructLink(LinkedList<Pair<String, String>> 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<Object> content = structLink.getSmLinkOrSmLinkGrp();
for (Pair<String, String> 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;
}

Expand Down

0 comments on commit 2c9a15c

Please sign in to comment.