use of org.graylog2.contentpacks.model.Revisioned in project graylog2-server by Graylog2.
the class ContentPackPersistenceService method loadAllLatest.
public Set<ContentPack> loadAllLatest() {
final Set<ContentPack> allContentPacks = loadAll();
final ImmutableMultimap.Builder<ModelId, ContentPack> byIdBuilder = ImmutableMultimap.builder();
for (ContentPack contentPack : allContentPacks) {
byIdBuilder.put(contentPack.id(), contentPack);
}
final ImmutableMultimap<ModelId, ContentPack> contentPacksById = byIdBuilder.build();
final ImmutableSet.Builder<ContentPack> latestContentPacks = ImmutableSet.builderWithExpectedSize(contentPacksById.keySet().size());
for (ModelId id : contentPacksById.keySet()) {
final ImmutableCollection<ContentPack> contentPacks = contentPacksById.get(id);
final ContentPack latestContentPackRevision = Collections.max(contentPacks, Comparator.comparingInt(Revisioned::revision));
latestContentPacks.add(latestContentPackRevision);
}
return latestContentPacks.build();
}
Aggregations