private void stitch( Episode subjectEpisode, EquivalenceSummary equivalenceSummary, Multimap<Container, Episode> equivalentsChildren, ReadableDescription desc) { String subjectUri = subjectEpisode.getCanonicalUri(); desc.startStage(subjectUri); Map<Publisher, ContentRef> equivalents = equivalenceSummary.getEquivalents(); Set<ContentRef> additionalEquivs = Sets.newHashSet(); for (Entry<Container, Collection<Episode>> contentHierarchy : equivalentsChildren.asMap().entrySet()) { Container container = contentHierarchy.getKey(); for (Episode equivChild : contentHierarchy.getValue()) { if (matchingSequenceNumbers(subjectEpisode, equivChild)) { Publisher publisher = equivChild.getPublisher(); ContentRef existingEquiv = equivalents.get(publisher); if (existingEquiv != null) { desc.appendText( "existing strong equiv %s not overwritten by %s", existingEquiv, equivChild); } else { desc.appendText("adding %s (%s)", equivChild, container); additionalEquivs.add(ContentRef.valueOf(equivChild)); } break; } } } if (!additionalEquivs.isEmpty()) { additionalEquivs.addAll(equivalents.values()); lookupWriter.writeLookup(ContentRef.valueOf(subjectEpisode), additionalEquivs, publishers); } desc.finishStage(); }
@Override public String apply(ContentRef input) { return input.getParentUri(); }