X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;ds=inline;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FBasicLibrary.java;h=328ef656e444fbe4686dca82e08fafa204590d0d;hb=e604986c4208da0091d26bc0e1c4feb4ff3c588f;hp=9ac16ea2a45ba16e058d81f6d950b85e54bc8ea6;hpb=e42573a004fac26378c693ce9ef0d6319713c682;p=nikiroo-utils.git
diff --git a/src/be/nikiroo/fanfix/library/BasicLibrary.java b/src/be/nikiroo/fanfix/library/BasicLibrary.java
index 9ac16ea..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.
@@ -52,6 +63,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 +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.
*
@@ -338,7 +413,7 @@ abstract public class BasicLibrary {
pg.addProgress(pgOut, 1);
}
- BasicOutput out = BasicOutput.getOutput(type, true);
+ BasicOutput out = BasicOutput.getOutput(type, false);
if (out == null) {
throw new IOException("Output type not supported: " + type);
}
@@ -401,6 +476,7 @@ abstract public class BasicLibrary {
if (getInfo(luid) != null) {
delete(luid);
}
+
doSave(story, pg);
clearCache();