cover: allow custom author covers
[fanfix.git] / src / be / nikiroo / fanfix / library / BasicLibrary.java
index 8ec4e5620655ad148fb6b4b47b2c16d0f4284ee8..78d20d654afee85ec8e1f0826abd156576fe821e 100644 (file)
@@ -119,6 +119,31 @@ abstract public class BasicLibrary {
                return null;
        }
 
+       /**
+        * Return the cover image associated to this author.
+        * <p>
+        * By default, return the custom cover if any, and if not, return the cover
+        * of the first story with this author.
+        * 
+        * @param author
+        *            the author
+        * 
+        * @return the cover image or NULL
+        */
+       public Image getAuthorCover(String author) {
+               Image custom = getCustomAuthorCover(author);
+               if (custom != null) {
+                       return custom;
+               }
+
+               List<MetaData> metas = getListByAuthor(author);
+               if (metas.size() > 0) {
+                       return getCover(metas.get(0).getLuid());
+               }
+
+               return null;
+       }
+
        /**
         * Return the custom cover image associated to this source.
         * <p>
@@ -134,7 +159,21 @@ abstract public class BasicLibrary {
        }
 
        /**
-        * Fix the source cover to the given story cover.
+        * Return the custom cover image associated to this author.
+        * <p>
+        * By default, return NULL.
+        * 
+        * @param author
+        *            the author to look for
+        * 
+        * @return the custom cover or NULL if none
+        */
+       public Image getCustomAuthorCover(@SuppressWarnings("unused") String author) {
+               return null;
+       }
+
+       /**
+        * Set the source cover to the given story cover.
         * 
         * @param source
         *            the source to change
@@ -143,6 +182,16 @@ abstract public class BasicLibrary {
         */
        public abstract void setSourceCover(String source, String luid);
 
+       /**
+        * Set the author cover to the given story cover.
+        * 
+        * @param source
+        *            the author to change
+        * @param luid
+        *            the story LUID
+        */
+       public abstract void setAuthorCover(String author, String luid);
+
        /**
         * Return the list of stories (represented by their {@link MetaData}, which
         * <b>MAY</b> not have the cover included).