Changeset 3912


Ignore:
Timestamp:
May 2, 2016, 9:22:41 AM (7 years ago)
Author:
Nicklas Nordborg
Message:

References #883: Add support for progress reporting to the Reggie wizard API

Added progress reporter to the 'Stray files wizard'.

Location:
extensions/net.sf.basedb.reggie/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/resources/admin/stray-files.js

    r3843 r3912  
    2828    Events.addEventHandler('wizard', 'wizard-submit', sf.submit);
    2929
    30     Wizard.showLoadingAnimation('Searching for stray folders...');
     30    Wizard.showLoadingAnimation('Searching for stray folders...', 'stray-files-progress');
    3131    var url = '../Admin.servlet?ID='+App.getSessionId();
    3232    url += '&cmd=FindStrayFolders';
  • extensions/net.sf.basedb.reggie/trunk/resources/admin/stray-files.jsp

    r3843 r3912  
    138138 
    139139  <div id="wizard-status"></div>
     140  <div id="wizard-progress"></div>
    140141
    141142  <table class="navigation" id="navigation">
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/counter/CounterService.java

    r3847 r3912  
    11091109    Set<String> knownFolders = new HashSet<String>();
    11101110    knownFolders.add("/debug");
    1111     AdminServlet.loadDataFileFolders(dc, manager, DerivedBioAssay.getQuery(), knownFolders);
    1112     AdminServlet.loadDataFileFolders(dc, manager, RawBioAssay.getQuery(), knownFolders);
     1111    AdminServlet.loadDataFileFolders(dc, manager, DerivedBioAssay.getQuery(), knownFolders, null);
     1112    AdminServlet.loadDataFileFolders(dc, manager, RawBioAssay.getQuery(), knownFolders, null);
    11131113   
    11141114    // List all folders in the file server archives
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/AdminServlet.java

    r3844 r3912  
    77import java.util.HashMap;
    88import java.util.HashSet;
     9import java.util.Iterator;
    910import java.util.List;
    1011import java.util.Map;
     
    2829import net.sf.basedb.core.InvalidDataException;
    2930import net.sf.basedb.core.ItemQuery;
     31import net.sf.basedb.core.ProgressReporter;
    3032import net.sf.basedb.core.RawBioAssay;
    3133import net.sf.basedb.core.SessionControl;
     34import net.sf.basedb.core.SimpleProgressReporter;
    3235import net.sf.basedb.core.query.Annotations;
    3336import net.sf.basedb.core.snapshot.SnapshotManager;
     
    4144import net.sf.basedb.reggie.ssh.SshHost;
    4245import net.sf.basedb.reggie.ssh.SshUtil;
     46import net.sf.basedb.util.ChainedProgressReporter;
    4347import net.sf.basedb.util.error.ThrowableUtil;
    4448
     
    8387       
    8488        SnapshotManager manager = new SnapshotManager();
     89        SimpleProgressReporter progress = new SimpleProgressReporter(null);
     90        ChainedProgressReporter chained = new ChainedProgressReporter(progress);
     91       
     92        sc.setSessionSetting("stray-files-progress", progress);
    8593       
    8694        // Load known folders from the "DataFilesFolder" annotation
    8795        Set<String> knownFolders = new HashSet<String>();
    8896        knownFolders.add("/debug");
    89         loadDataFileFolders(dc, manager, DerivedBioAssay.getQuery(), knownFolders);
    90         loadDataFileFolders(dc, manager, RawBioAssay.getQuery(), knownFolders);
     97        progress.display(1, "Loading known folders...");
     98        chained.setRange(5, 19);
     99        loadDataFileFolders(dc, manager, DerivedBioAssay.getQuery(), knownFolders, chained);
     100        progress.display(20, "Loading known folders...");
     101        chained.setRange(21, 29);
     102        loadDataFileFolders(dc, manager, RawBioAssay.getQuery(), knownFolders, chained);
    91103       
    92104        // List all folders in the file server archives
    93105        Set<RemoteFolder> remoteFolders = new TreeSet<RemoteFolder>();
     106        progress.display(30, "Checking ProjectArchive...");
    94107        loadRemoteFolders(dc, Fileserver.PROJECT_ARCHIVE, remoteFolders);
     108        progress.display(60, "Checking ExternalArchive...");
    95109        loadRemoteFolders(dc, Fileserver.EXTERNAL_ARCHIVE, remoteFolders);
    96110       
     111        progress.display(90, "Comparing known folders with actual folders...");
    97112        List<RemoteFolder> strayFolders = findStrayFolders(remoteFolders, knownFolders);
    98113
     
    102117          jsonStray.add(rf.asJSONObject());
    103118        }
     119        progress.display(100, "Done");
    104120       
    105121        // Keep the folders in the session scope so we can reference them by index
     
    132148    {
    133149      if (dc != null) dc.close();
     150      if (sc != null) sc.setSessionSetting("stray-files-progress", null);
    134151      json.writeJSONString(resp.getWriter());
    135152    }
     
    251268    @return The number of new paths loaded
    252269   */
    253   public static int loadDataFileFolders(DbControl dc, SnapshotManager manager, ItemQuery<? extends Annotatable> query, Set<String> knownFolders)
     270  public static int loadDataFileFolders(DbControl dc, SnapshotManager manager, ItemQuery<? extends Annotatable> query, Set<String> knownFolders, ProgressReporter progress)
    254271  {
    255272    int sizeBefore = knownFolders.size();
     
    257274    query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT);
    258275    query.join(Annotations.innerJoin(Annotationtype.DATA_FILES_FOLDER.load(dc), "dff"));
    259    
    260     for (Annotatable dba : query.list(dc))
    261     {
     276    long totalCount = query.count(dc);
     277    long count = 0;
     278   
     279    Iterator<? extends Annotatable> it = query.iterate(dc);
     280    while (it.hasNext())
     281    {
     282      if (count % 100 == 0 && progress != null)
     283            {
     284        progress.display((int)((100 * count) / totalCount), null);
     285            }
     286      count++;
     287     
     288      Annotatable dba = it.next();
    262289      String path = (String)Annotationtype.DATA_FILES_FOLDER.getAnnotationValue(dc, manager, dba);         
    263290      knownFolders.add(path);
Note: See TracChangeset for help on using the changeset viewer.