X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FBasicLibrary.java;h=328ef656e444fbe4686dca82e08fafa204590d0d;hb=99ccbdf63b539f1f40e070f5833f2d15fcf79830;hp=63ffdb655bafa658b4bad2dcec37e5671fd4d867;hpb=14b574483b51d3859acef6a269f8841b5a4eb5f8;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/library/BasicLibrary.java b/src/be/nikiroo/fanfix/library/BasicLibrary.java index 63ffdb6..328ef65 100644 --- a/src/be/nikiroo/fanfix/library/BasicLibrary.java +++ b/src/be/nikiroo/fanfix/library/BasicLibrary.java @@ -29,6 +29,17 @@ import be.nikiroo.utils.Progress; * @author niki */ abstract public class BasicLibrary { + /** + * Return a name for this library (the UI may display this). + *

+ * Must not be NULL. + * + * @return the name, or an empty {@link String} if none + */ + public String getLibraryName() { + return ""; + } + /** * Retrieve the main {@link File} corresponding to the given {@link Story}, * which can be passed to an external reader or instance. @@ -340,6 +351,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. *