1. NRG Admin
  2. xnatfs

Commits

Daniel Blezek  committed c67c902

Reverted Experiment

  • Participants
  • Parent commits 2bd3d3a
  • Branches default

Comments (0)

Files changed (1)

File Source/org/xnat/xnatfs/webdav/Experiment.java

View file
  */
 package org.xnat.xnatfs.webdav;
 
-import java.util.ArrayList;
-import java.util.Comparator;
 import java.util.HashSet;
-import java.util.List;
 
 import org.apache.log4j.Logger;
 
 import com.bradmcevoy.http.Resource;
 
-import edu.emory.mathcs.backport.java.util.Collections;
-
 /**
  * @author blezek
  * 
    */
   public Experiment ( XNATFS x, String path, String name, String url ) {
     super ( x, path, name, url );
+    mElementURL = mURL + "scans?format=json";
+    mChildKey = "id";
+    mVerboseDirectoryName = "Scans";
   }
 
-  public List<? extends Resource> getChildren () {
-    ArrayList<Resource> list = new ArrayList<Resource> ();
-
-    list.add ( child ( "Scans" ) );
-    list.add ( child ( "Assessors" ) );
-    list.add ( child ( "Reconstructions" ) );
-    Collections.sort ( list, new Comparator<Resource> () {
-      public int compare ( Resource o1, Resource o2 ) {
-        return o1.getName ().compareTo ( o2.getName () );
-      }
-    } );
-    return list;
-  }
-
+  /*
+   * public List<? extends Resource> getChildren () { ArrayList<Resource> list =
+   * new ArrayList<Resource> ();
+   * 
+   * list.add ( child ( "Scans" ) ); list.add ( child ( "Assessors" ) );
+   * list.add ( child ( "Reconstructions" ) ); Collections.sort ( list, new
+   * Comparator<Resource> () { public int compare ( Resource o1, Resource o2 ) {
+   * return o1.getName ().compareTo ( o2.getName () ); } } ); return list; }
+   */
   /*
    * (non-Javadoc)
    * 
    */
   @Override
   public Resource child ( String childName ) {
-    VirtualDirectory d = (VirtualDirectory) XNATFS.findInCache ( new Scan ( xnatfs, mAbsolutePath, childName, mURL ), mCredentials );
-    setChildAuthorization ( d );
-    d.setVerboseDirectory ( true );
-    return d;
+    // VirtualDirectory d = (VirtualDirectory) XNATFS.findInCache ( new Scan (
+    // xnatfs, mAbsolutePath, childName, mURL ), mCredentials );
+    // setChildAuthorization ( d );
+    // d.setVerboseDirectory ( true );
+    // return d;
+    if ( xnatfs.useVerboseFolders () && !mVerboseDirectory ) {
+      // this object is not the verbose folder, but we must create one.
+      if ( childName.equals ( mVerboseDirectoryName ) ) {
+        VirtualDirectory d = (VirtualDirectory) XNATFS.findInCache ( new Experiment ( xnatfs, mAbsolutePath, mVerboseDirectoryName, mURL ), mCredentials );
+        setChildAuthorization ( d );
+        d.setVerboseDirectory ( true );
+        return d;
+      }
+    }
+
+    logger.debug ( "child: create " + childName + " in directory " + mAbsolutePath );
+    VirtualResource scan = XNATFS.findInCache ( new Scan ( xnatfs, mAbsolutePath, childName, mURL + "scans/" + childName + "/" ), mCredentials );
+    setChildAuthorization ( scan );
+    return scan;
   }
 }