Commits

Daniel Blezek committed 77efa3a

Added full hierarchy. Added Scans, Reconstructions and Assessors to Experiments

Comments (0)

Files changed (6)

Source/org/xnat/xnatfs/webdav/Bundle.java

   @Override
   public Resource child ( String childName ) {
     logger.debug ( "child: create " + childName );
-    /*
-     * try { ArrayList<String> l = new ArrayList<String> (); l.add ( "URI" );
-     * l.add ( "Size" ); s = getFileMap ( mElementURL, "Name", l ); } catch (
-     * Exception e ) { logger.error ( "Failed to get child element list: " + e
-     * ); e.printStackTrace (); }
-     */
-    /*
-     * if ( false && childName.equals ( "Upload" ) ) { UploadDirectory upload =
-     * new UploadDirectory ( xnatfs, mAbsolutePath, childName, mURL + "files/"
-     * ); setChildAuthorization ( upload ); return upload; }
-     */
-    // long size = Long.valueOf ( s.get ( childName ).get ( 1 ) ).longValue
-    // ();
     VirtualResource remote = XNATFS.findInCache ( new RemoteFile ( xnatfs, mAbsolutePath, childName, mURL + "files/" + childName, -1l ), mCredentials );
     setChildAuthorization ( remote );
     return remote;

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

  */
 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 class Experiment extends VirtualDirectory {
   final static Logger logger = Logger.getLogger ( Experiment.class );
 
+  HashSet<String> mScans = new HashSet<String> (), mReconstructions = new HashSet<String> (), mAssessors = new HashSet<String> ();
+
   /**
    * @param x
    * @param path
    */
   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;
   }
 
   /*
    */
   @Override
   public Resource child ( String childName ) {
-    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;
+    VirtualDirectory d = (VirtualDirectory) XNATFS.findInCache ( new Scan ( xnatfs, mAbsolutePath, childName, mURL ), mCredentials );
+    setChildAuthorization ( d );
+    d.setVerboseDirectory ( true );
+    return d;
   }
 }

Source/org/xnat/xnatfs/webdav/Project.java

     mFallbackChildKey = "subjectid";
     mElementURL = mURL + "subjects?format=json";
     mVerboseDirectoryName = "Subjects";
+    mExtraChildren.add ( sResources );
   }
 
   /*
       // this object is not the verbose folder, but we must create one.
       if ( childName.equals ( mVerboseDirectoryName ) ) {
         Project subjects = (Project) XNATFS.findInCache ( new Project ( xnatfs, mAbsolutePath, mVerboseDirectoryName, mURL ), mCredentials );
+        setChildAuthorization ( subjects );
         subjects.setVerboseDirectory ( true );
-        setChildAuthorization ( subjects );
         return subjects;
       }
     }
+    if ( childName.equals ( sResources ) ) {
+      VirtualDirectory d = (VirtualDirectory) XNATFS.findInCache ( new Scan ( xnatfs, mAbsolutePath, childName, mURL ), mCredentials );
+      setChildAuthorization ( d );
+      d.setVerboseDirectory ( true );
+      return d;
+    }
     logger.debug ( "child: create " + childName );
     // Look up in the cache
     VirtualResource subject = XNATFS.findInCache ( new Subject ( xnatfs, mAbsolutePath, childName, mURL + "subjects/" + childName + "/" ), mCredentials );

Source/org/xnat/xnatfs/webdav/Scan.java

     mElementURL = mURL + "resources?format=json";
     mChildKey = "label";
     mFallbackChildKey = "xnat_abstractresource_id";
+    mVerboseDirectoryName = "Resources";
   }
 
   /*
    */
   @Override
   public Resource child ( String childName ) {
+    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 Scan ( xnatfs, mAbsolutePath, mVerboseDirectoryName, mURL ), mCredentials );
+        setChildAuthorization ( d );
+        d.setVerboseDirectory ( true );
+        return d;
+      }
+    }
+
     logger.debug ( "child: create " + childName );
     VirtualResource bundle = XNATFS.findInCache ( new Bundle ( xnatfs, mAbsolutePath, childName, mURL + "resources/" + childName + "/" ), mCredentials );
     setChildAuthorization ( bundle );

Source/org/xnat/xnatfs/webdav/Subject.java

     mElementURL = mURL + "experiments?format=json";
     mChildKey = "label";
     mVerboseDirectoryName = "Experiments";
+    mExtraChildren.add ( sResources );
   }
 
   public List<? extends Resource> getChildren () {
         return d;
       }
     }
+    if ( childName.equals ( sResources ) ) {
+      VirtualDirectory d = (VirtualDirectory) XNATFS.findInCache ( new Scan ( xnatfs, mAbsolutePath, childName, mURL ), mCredentials );
+      setChildAuthorization ( d );
+      d.setVerboseDirectory ( true );
+      return d;
+    }
 
     logger.debug ( "child: create " + childName );
     VirtualResource experiment = XNATFS.findInCache ( new Experiment ( xnatfs, mAbsolutePath, childName, mURL + "experiments/" + childName + "/" ), mCredentials );

Source/org/xnat/xnatfs/webdav/VirtualDirectory.java

 abstract public class VirtualDirectory extends VirtualResource implements CollectionResource, GetableResource {
   String mChildKey;
   static final Logger logger = Logger.getLogger ( VirtualDirectory.class );
+  static final String sResources = "Resources";
   String mURL;
   String mElementURL;
   String mFallbackChildKey = "xnat_abstractresource_id";