X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FBasicLibrary.java;h=cf17a2bef49fce8591150c6e93eb50eb9b41a30b;hb=b89dfb6ece936486563734818ed62488a59e5897;hp=de3dbb64890dd53df4bad285c198693e8f061348;hpb=fa4dcafe32a95f725eb2573e42c7c2990cbeacd1;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/library/BasicLibrary.java b/src/be/nikiroo/fanfix/library/BasicLibrary.java index de3dbb6..cf17a2b 100644 --- a/src/be/nikiroo/fanfix/library/BasicLibrary.java +++ b/src/be/nikiroo/fanfix/library/BasicLibrary.java @@ -52,6 +52,35 @@ abstract public class BasicLibrary { */ public abstract BufferedImage getCover(String luid); + /** + * Return the cover image associated to this source. + *

+ * By default, return the cover of the first story with this source. + * + * @param source + * the source + * + * @return the cover image or NULL + */ + public BufferedImage getSourceCover(String source) { + List metas = getListBySource(source); + if (metas.size() > 0) { + return getCover(metas.get(0).getLuid()); + } + + return null; + } + + /** + * Fix the source cover to the given story cover. + * + * @param source + * the source to change + * @param luid + * the story LUID + */ + public abstract void setSourceCover(String source, String luid); + /** * Return the list of stories (represented by their {@link MetaData}, which * MAY not have the cover included). @@ -311,6 +340,41 @@ abstract public class BasicLibrary { return save(support.process(url, pg), null); } + /** + * Import the story from one library to another, and keep the same LUID. + * + * @param other + * the other library to import from + * @param luid + * the Library UID + * @param pg + * the optional progress reporter + * + * @throws IOException + * in case of I/O error + */ + public void imprt(BasicLibrary other, String luid, Progress pg) + throws IOException { + Progress pgGetStory = new Progress(); + Progress pgSave = new Progress(); + if (pg == null) { + pg = new Progress(); + } + + pg.setMinMax(0, 2); + pg.addProgress(pgGetStory, 1); + pg.addProgress(pgSave, 1); + + Story story = other.getStory(luid, pgGetStory); + if (story != null) { + story = this.save(story, luid, pgSave); + pg.done(); + } else { + pg.done(); + throw new IOException("Cannot find story in Library: " + luid); + } + } + /** * Export the {@link Story} to the given target in the given format. * @@ -401,7 +465,7 @@ abstract public class BasicLibrary { if (getInfo(luid) != null) { delete(luid); } - + doSave(story, pg); clearCache();