Update nikiroo-utils (Progress) + GuiReader perf
[fanfix.git] / src / be / nikiroo / fanfix / library / BasicLibrary.java
index 63ffdb655bafa658b4bad2dcec37e5671fd4d867..cf17a2bef49fce8591150c6e93eb50eb9b41a30b 100644 (file)
@@ -340,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.
         *