@Override public ScoredCandidates<Container> generate(Container content, ResultDescription desc) { OptionalMap<String, EquivalenceSummary> childSummaries = summaryStore.summariesForUris(Iterables.transform(content.getChildRefs(), ChildRef.TO_URI)); Multiset<String> parents = HashMultiset.create(); for (EquivalenceSummary summary : Optional.presentInstances(childSummaries.values())) { Iterables.addAll( parents, Iterables.filter( Iterables.transform(summary.getEquivalents().values(), TO_PARENT), Predicates.notNull())); } return scoreContainers(parents, childSummaries.size(), desc); }
@Override public ScoredCandidates<Item> generate(Item subject, ResultDescription desc) { Builder<Item> result = DefaultScoredCandidates.fromSource("Container"); ParentRef parent = subject.getContainer(); if (parent != null) { String parentUri = parent.getUri(); OptionalMap<String, EquivalenceSummary> containerSummary = parentSummary(parentUri); Optional<EquivalenceSummary> optional = containerSummary.get(parentUri); if (optional.isPresent()) { EquivalenceSummary summary = optional.get(); for (Item child : childrenOf(summary.getCandidates())) { result.addEquivalent(child, Score.NULL_SCORE); } } } return result.build(); }