From: David ‘Bombe’ Roden Date: Sat, 12 Oct 2013 15:34:17 +0000 (+0200) Subject: Store album and image relationship. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=d281599e1585af0ed80ac8beb154b6b401e3ecd5;p=Sone.git Store album and image relationship. --- diff --git a/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java b/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java index fa29e64..e7c380a 100644 --- a/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java +++ b/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java @@ -50,6 +50,8 @@ import net.pterodactylus.util.config.Configuration; import net.pterodactylus.util.config.ConfigurationException; import com.google.common.base.Optional; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.ListMultimap; import com.google.common.collect.SortedSetMultimap; import com.google.common.collect.TreeMultimap; import com.google.common.util.concurrent.AbstractService; @@ -103,6 +105,8 @@ public class MemoryDatabase extends AbstractService implements Database { private final Map allAlbums = new HashMap(); + private final ListMultimap albumImages = ArrayListMultimap.create(); + private final Map allImages = new HashMap(); /** @@ -479,6 +483,7 @@ public class MemoryDatabase extends AbstractService implements Database { lock.writeLock().lock(); try { allImages.put(image.getId(), image); + albumImages.put(image.getAlbum().getId(), image.getId()); } finally { lock.writeLock().unlock(); } @@ -489,6 +494,7 @@ public class MemoryDatabase extends AbstractService implements Database { lock.writeLock().lock(); try { allImages.remove(image.getId()); + albumImages.remove(image.getAlbum().getId(), image.getId()); } finally { lock.writeLock().unlock(); }