changeset 1210:247eab96bf04

ImageJobDescription creates an ImageSet when you only set an ImageInput.
author robcast
date Thu, 22 Aug 2013 17:59:51 +0200
parents 59d615f4e5f3
children 250cd5139121
files common/src/main/java/digilib/image/ImageJobDescription.java common/src/main/java/digilib/io/ImageFileSet.java common/src/main/java/digilib/io/ImageSet.java
diffstat 3 files changed, 40 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/common/src/main/java/digilib/image/ImageJobDescription.java	Thu Aug 22 17:14:33 2013 +0200
+++ b/common/src/main/java/digilib/image/ImageJobDescription.java	Thu Aug 22 17:59:51 2013 +0200
@@ -78,6 +78,7 @@
     String mimeType = null;
     Integer paramDW = null;
     Integer paramDH = null;
+    DocuDirCache dirCache = null;
 
     /**
      * create empty ImageJobDescription.
@@ -87,6 +88,7 @@
     public ImageJobDescription(DigilibConfiguration dlcfg) {
         super(30);
         dlConfig = dlcfg;
+        dirCache = (DocuDirCache) dlConfig.getValue("servlet.dir.cache");
     }
 
     /**
@@ -198,11 +200,18 @@
     }
 
     /**
+     * Set the current ImageInput.
+     * 
      * @param input
      *            the input to set
      */
     public void setInput(ImageInput input) {
         this.input = input;
+        // create and set ImageSet if needed
+        if (dirCache == null && imageSet == null) {
+            imageSet = new ImageSet();
+            imageSet.add(input);
+        }
     }
 
     /**
@@ -250,7 +259,6 @@
      */
     public DocuDirectory getFileDirectory() throws FileOpException {
         if (fileDir == null) {
-            DocuDirCache dirCache = (DocuDirCache) dlConfig.getValue("servlet.dir.cache");
             String fp = getFilePath();
             fileDir = dirCache.getDirectory(fp);
             if (fileDir == null) {
@@ -268,8 +276,9 @@
      */
     public ImageSet getImageSet() throws FileOpException {
         if (imageSet == null) {
-            DocuDirCache dirCache = (DocuDirCache) dlConfig.getValue("servlet.dir.cache");
-
+            if (dirCache == null) {
+                throw new FileOpException("No DirCache configured!");
+            }
             imageSet = (ImageSet) dirCache.getFile(getFilePath(), getAsInt("pn"), FileClass.IMAGE);
             if (imageSet == null) {
                 throw new FileOpException("File " + getFilePath() + "(" + getAsInt("pn") + ") not found.");
@@ -279,6 +288,16 @@
     }
 
     /**
+     * Set the current ImageSet.
+     * 
+     * @param imageSet
+     */
+    public void setImageSet(ImageSet imageSet) {
+        this.imageSet = imageSet;
+    }
+    
+    
+    /**
      * Returns the file path name from the request.
      * 
      * @return
@@ -667,6 +686,8 @@
     }
 
     /**
+     * Set the current docuImage.
+     * 
      * @param docuImage
      *            the docuImage to set
      */
--- a/common/src/main/java/digilib/io/ImageFileSet.java	Thu Aug 22 17:14:33 2013 +0200
+++ b/common/src/main/java/digilib/io/ImageFileSet.java	Thu Aug 22 17:59:51 2013 +0200
@@ -115,22 +115,6 @@
     }
 
     /**
-     * Adds an ImageFile to this Fileset.
-     * 
-     * The files should be added in the order of higher to lower resolutions.
-     * The first file is considered the hires "original".
-     * 
-     * 
-     * @param f
-     *            file to add
-     * @return true (always)
-     */
-    public boolean add(ImageInput f) {
-    	f.setParent(this);
-    	return list.add(f);
-    }
-
-    /**
      * Fill the ImageSet with files from different base directories.
      * 
      * 
--- a/common/src/main/java/digilib/io/ImageSet.java	Thu Aug 22 17:14:33 2013 +0200
+++ b/common/src/main/java/digilib/io/ImageSet.java	Thu Aug 22 17:59:51 2013 +0200
@@ -217,4 +217,20 @@
         
     }
 
+    /**
+     * Adds an ImageImput to this ImageSet.
+     * 
+     * The images should be added in the order of higher to lower resolutions.
+     * The first image is considered the hires "original".
+     * 
+     * 
+     * @param f
+     *            ImageInput to add
+     * @return true (always)
+     */
+    public boolean add(ImageInput f) {
+    	f.setParent(this);
+    	return list.add(f);
+    }
+
 }