Add filter for local/remote Sones to “Known Sones” page.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / KnownSonesPage.java
index 6ed5667..00568da 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - KnownSonesPage.java - Copyright © 2010 David Roden
+ * Sone - KnownSonesPage.java - Copyright © 2010–2012 David Roden
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,8 +25,8 @@ import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.collection.Pagination;
 import net.pterodactylus.util.collection.ReverseComparator;
-import net.pterodactylus.util.filter.Filter;
-import net.pterodactylus.util.filter.Filters;
+import net.pterodactylus.util.collection.filter.Filter;
+import net.pterodactylus.util.collection.filter.Filters;
 import net.pterodactylus.util.number.Numbers;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
@@ -91,7 +91,7 @@ public class KnownSonesPage extends SoneTemplatePage {
                                 */
                                @Override
                                public boolean filterObject(Sone sone) {
-                                       return webInterface.getCore().isNewSone(sone.getId());
+                                       return !sone.isKnown();
                                }
                        });
                } else if ("not-new".equals(filter)) {
@@ -101,9 +101,13 @@ public class KnownSonesPage extends SoneTemplatePage {
                                 */
                                @Override
                                public boolean filterObject(Sone sone) {
-                                       return !webInterface.getCore().isNewSone(sone.getId());
+                                       return sone.isKnown();
                                }
                        });
+               } else if ("own".equals(filter)) {
+                       knownSones = Filters.filteredList(knownSones, Sone.LOCAL_SONE_FILTER);
+               } else if ("not-own".equals(filter)) {
+                       knownSones = Filters.filteredList(knownSones, Filters.reverseFilter(Sone.LOCAL_SONE_FILTER));
                }
                if ("activity".equals(sortField)) {
                        if ("asc".equals(sortOrder)) {