From d281599e1585af0ed80ac8beb154b6b401e3ecd5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 12 Oct 2013 17:34:17 +0200 Subject: [PATCH] Store album and image relationship. --- .../java/net/pterodactylus/sone/database/memory/MemoryDatabase.java | 6 ++++++ 1 file changed, 6 insertions(+) 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(); } -- 2.7.4