Store album relationships.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 12 Oct 2013 19:57:05 +0000 (21:57 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Feb 2014 21:25:24 +0000 (22:25 +0100)
src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java

index e7c380a..c778de2 100644 (file)
@@ -104,7 +104,7 @@ public class MemoryDatabase extends AbstractService implements Database {
        private final Set<String> knownPostReplies = new HashSet<String>();
 
        private final Map<String, Album> allAlbums = new HashMap<String, Album>();
-
+       private final ListMultimap<String, String> albumChildren = ArrayListMultimap.create();
        private final ListMultimap<String, String> albumImages = ArrayListMultimap.create();
 
        private final Map<String, Image> allImages = new HashMap<String, Image>();
@@ -445,6 +445,7 @@ public class MemoryDatabase extends AbstractService implements Database {
                lock.writeLock().lock();
                try {
                        allAlbums.put(album.getId(), album);
+                       albumChildren.put(album.getParent().getId(), album.getId());
                } finally {
                        lock.writeLock().unlock();
                }
@@ -455,6 +456,7 @@ public class MemoryDatabase extends AbstractService implements Database {
                lock.writeLock().lock();
                try {
                        allAlbums.remove(album.getId());
+                       albumChildren.remove(album.getParent().getId(), album.getId());
                } finally {
                        lock.writeLock().unlock();
                }