Commits

Anonymous committed c843f16

Fix for XNAT-1528 Selecting cancel when finding session data seems to do nothing

Comments (0)

Files changed (4)

src/main/java/org/nrg/io/MasterTrawler.java

         final Iterator<File> filei = new FileWalkIterator(roots, pm);   // TODO: progress monitor
         final Iterator<Trawler> trawleri = new ArrayIterator<Trawler>(trawlers);
         final Collection<File> remaining = Sets.newLinkedHashSet();
-        sessions.addAll(trawleri.next().trawl(filei, remaining));
+        sessions.addAll(trawleri.next().trawl(filei, remaining, pm));
         while (trawleri.hasNext()) {
             final Collection<File> files = Lists.newArrayList(remaining);
             logger.trace("trawling {}", files);
             remaining.clear();
-            sessions.addAll(trawleri.next().trawl(files.iterator(), remaining));
+            sessions.addAll(trawleri.next().trawl(files.iterator(), remaining, pm));
             if (null != pm && pm.isCanceled()) {
                 logger.debug("user canceled file search");
                 sessions.clear();

src/main/java/org/nrg/io/Trawler.java

 import java.util.Iterator;
 
 import org.nrg.upload.data.Session;
+import org.nrg.util.EditProgressMonitor;
 
 /**
  * @author Kevin A. Archie <karchie@npg.wustl.edu>
 	 * @param files Iterator over files to be examined
 	 * @return any Sessions that could be identified
 	 */
-	Collection<Session> trawl(final Iterator<File> files);
-	Collection<Session> trawl(final Iterator<File> files, final Collection<File> remaining);
+	Collection<Session> trawl(final Iterator<File> files, EditProgressMonitor pm);
+	Collection<Session> trawl(final Iterator<File> files, final Collection<File> remaining, EditProgressMonitor pm);
 }

src/main/java/org/nrg/io/dcm/DicomTrawler.java

 import org.nrg.dcm.Study;
 import org.nrg.io.Trawler;
 import org.nrg.upload.data.Session;
+import org.nrg.util.EditProgressMonitor;
 import org.nrg.util.MapRegistry;
 import org.nrg.util.Registry;
 
  *
  */
 public final class DicomTrawler implements Trawler {
+	
 	/* (non-Javadoc)
 	 * @see org.nrg.io.Trawler#trawl(java.util.Iterator)
 	 */
-	public Collection<Session> trawl(final Iterator<File> files) {
-		return trawl(files, null);
+	public Collection<Session> trawl(final Iterator<File> files, EditProgressMonitor pm) {
+		return trawl(files, null, pm);
 	}
 
 	/* (non-Javadoc)
 	 * @see org.nrg.io.Trawler#trawl(java.util.Iterator, java.util.Collection)
 	 */
 	public Collection<Session> trawl(final Iterator<File> files,
-			final Collection<File> remaining) {
+			final Collection<File> remaining, EditProgressMonitor pm) {
 		final Registry<Study> studies = new MapRegistry<Study>();
 		while (files.hasNext()) {
+			if (null != pm && pm.isCanceled()) {
+				return new ArrayList<Session>();
+			}
 			final File f = files.next();
 			if (f.isFile()) {
 				final DicomObject o;

src/main/java/org/nrg/io/ecat/EcatTrawler.java

 import org.nrg.ecat.MatrixDataFile;
 import org.nrg.io.Trawler;
 import org.nrg.upload.data.Session;
+import org.nrg.util.EditProgressMonitor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
     /* (non-Javadoc)
      * @see org.nrg.io.Trawler#trawl(java.util.Iterator)
      */
-    public Collection<Session> trawl(final Iterator<File> files) {
-        return trawl(files, null);
+    public Collection<Session> trawl(final Iterator<File> files, EditProgressMonitor pm) {
+        return trawl(files, null, pm);
     }
 
     /* (non-Javadoc)
      * @see org.nrg.io.Trawler#trawl(java.util.Iterator, java.util.Collection)
      */
-    public Collection<Session> trawl(final Iterator<File> files, final Collection<File> remaining) {
+    public Collection<Session> trawl(final Iterator<File> files, final Collection<File> remaining, EditProgressMonitor pm) {
         final ListMultimap<String,MatrixDataFile> filesets = ArrayListMultimap.create();
         while (files.hasNext()) {
+        	if (null != pm && pm.isCanceled()) {
+				return new ArrayList<Session>();
+			}
             final File f = files.next();
             logger.trace("checking {}", f);
             try {