Changeset 5186


Ignore:
Timestamp:
Nov 6, 2009, 9:39:39 AM (12 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1397: Function to inherit annotations for all experimental factors in the experimental factors table

The processing is now also done in the background while a progress bar is showing in the foreground. It should be useful as soon as there are 10 or more raw bioassays.

Side effects:

  • Added 'id' attribute to <tbl:cell> taglib so that it is possible to modify the contents with javascript.
  • Fixed a cosmetic issue with the generic progress reporter implementation. 0% and 100% didn't display a correct progress bar.
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/taglib/table/Cell.java

    r5111 r5186  
    291291    if (getClazz() != null) sb.append(" class=\"").append(getClazz()).append("\"");
    292292    if (getStyle() != null) sb.append(" style=\"").append(getStyle()).append("\"");
     293    if (getId() != null) sb.append(" id=\"").append(getId()).append("\"");
    293294    sb.append(">");
    294295    if (overflowed)
  • trunk/www/WEB-INF/table.tld

    r5111 r5186  
    633633    <tagclass>net.sf.basedb.clients.web.taglib.table.Cell</tagclass>
    634634    <attribute>
     635      <name>id</name>
     636      <required>false</required>
     637      <rtexprvalue>true</rtexprvalue>
     638    </attribute>
     639    <attribute>
    635640      <name>clazz</name>
    636641      <required>false</required>
  • trunk/www/common/progress_reporter.jsp

    r4510 r5186  
    7979        <table width="100%" class="progressbar" border=0 cellspacing=0 cellpadding=0>
    8080        <tr>
    81           <td width="<%=percentDone%>%" class="done" id="percentDone">&nbsp;</td>
    82           <td width="<%=100-percentDone%>%" class="remain" id="percentRemain">&nbsp;</td>
     81          <%if (percentDone > 0) {%><td width="<%=percentDone%>%" class="done" id="percentDone">&nbsp;</td><%}%>
     82          <%if (percentDone < 100) {%><td width="<%=100-percentDone%>%" class="remain" id="percentRemain">&nbsp;</td><%}%>
    8383        </tr>
    8484        </table>
  • trunk/www/views/experiments/index.jsp

    r5176 r5186  
    4444  import="net.sf.basedb.core.PermissionDeniedException"
    4545  import="net.sf.basedb.core.ItemAlreadyExistsException"
     46  import="net.sf.basedb.core.SimpleProgressReporter"
    4647  import="net.sf.basedb.core.snapshot.SnapshotManager"
    4748  import="net.sf.basedb.util.RemovableUtil"
     
    8687String message = null;
    8788DbControl dc = null;
    88 
    8989try
    9090{
     
    344344  else if ("AutoInherit".equals(cmd))
    345345  {
    346     // Display the edit page for a single item (should be opened in a popup)
    347     dc = sc.newDbControl();
    348     Experiment exp = Experiment.getById(dc, Values.getInt(itemId));
    349     AnnotationType at = AnnotationType.getById(dc, Values.getInt(request.getParameter("annotationtype_id")));
    350     ItemQuery<RawBioAssay> query = exp.getRawBioAssays();
    351     query.include(Include.ALL);
    352     query.setItemPermission(Permission.WRITE);
     346    Integer[] annotationTypeIds = Values.getInt(request.getParameterValues("autoinherit"));
    353347    int numInherited = 0;
    354348    int numRawBioAssays = 0;
    355     SnapshotManager manager = new SnapshotManager();
    356     List<AnnotationType> annotationTypes = Collections.singletonList(at);
    357     for (RawBioAssay rba : query.list(dc))
    358     {
    359       numRawBioAssays++;
    360       numInherited += rba.getAnnotationSet().autoInherit(dc, annotationTypes, manager, false);
    361     }
    362     dc.commit();
    363     message = numInherited + " annotation(s) inherited by " + numRawBioAssays + " raw bioassay(s)";
     349    if (annotationTypeIds.length > 0)
     350    {
     351      dc = sc.newDbControl();
     352      SimpleProgressReporter progress = new SimpleProgressReporter(null);
     353      sc.setSessionSetting("progress.autoinherit", progress);
     354      Experiment exp = Experiment.getById(dc, Values.getInt(itemId));
     355      List<AnnotationType> annotationTypes = new ArrayList<AnnotationType>(annotationTypeIds.length);
     356      for (int atId : annotationTypeIds)
     357      {
     358        annotationTypes.add(AnnotationType.getById(dc, atId));
     359      }
     360      ItemQuery<RawBioAssay> query = exp.getRawBioAssays();
     361      query.include(Include.ALL);
     362      query.setItemPermission(Permission.WRITE);
     363      SnapshotManager manager = new SnapshotManager();
     364      List<RawBioAssay> all = query.list(dc);
     365      int total = all.size();
     366      int done = 0;
     367      for (RawBioAssay rba : all)
     368      {
     369        progress.display(10+(90 * done) / total, "Processing <i>" + rba.getName() + "</i>...");
     370        ++done;
     371        int inherited = rba.getAnnotationSet().autoInherit(dc, annotationTypes, manager, false);
     372        numInherited += inherited;
     373        if (inherited > 0) numRawBioAssays++;
     374      }
     375      message = numInherited + " annotation(s) inherited by " + numRawBioAssays + " raw bioassay(s)";
     376      progress.display(100, message);
     377      dc.commit();
     378    }
     379    redirect = viewPage;
    364380  }
    365381  else
  • trunk/www/views/experiments/view_experiment.jsp

    r5131 r5186  
    215215      }
    216216    }
     217    var hasMissingFactors = false;
    217218    function showStatus(annotationTypeId, numTotal, numInherited)
    218219    {
    219220      var sss = document.getElementById('status.'+annotationTypeId);
    220221      var html;
    221       if (numTotal == numInherited)
     222      if (numInherited >= numTotal)
    222223      {
    223224        html = '<img src="../../images/ok.gif" title="All ' + numTotal +
     
    227228      {
    228229        var numMissing = numTotal - numInherited;
    229         html = '<a href="javascript:autoInherit('+annotationTypeId+')"' +
    230           ' title="Click for automatic inheritation of annotations from parents">';
    231         html += '<img src="../../images/warning.gif" border="0">&nbsp;' + numMissing + ' missing</a>';
     230        html = '<table border="0" cellspacing="0" cellpadding="0"><tr>';
     231        html += '<td width="20"><img src="../../images/warning.gif" border="0"';
     232        html += ' title="' + numMissing + ' raw bioassays are missing a value for this experimental factor"></td>';
     233        html += '<td width="20" style="text-align: center;">';
     234        html += '<input type="checkbox" name="autoinherit" value="'+annotationTypeId+'" checked';
     235        html += ' title="Select to automatically inherit annotations from parents"></td>';
     236        html += '<td>&nbsp;' + numMissing + ' missing</td>'
     237        html += '</tr></table>';
     238
     239        if (!hasMissingFactors)
     240        {
     241          hasMissingFactors = true;
     242          var checkAll = '<table border="0" cellspacing="0" cellpadding="0"><tr>';
     243          checkAll += '<td width="20"></td>';
     244          checkAll += '<td width="20" style="text-align: center;">';
     245          checkAll += '<a href="javascript:checkFactors()" title="Check/uncheck all">';
     246          checkAll += '<img src="../../images/check_uncheck.gif" border="0"></a></td>';
     247          checkAll += '<td width="20"><img src="../../images/bullet.gif" border="0"></td>';
     248          checkAll += '<td><a href="javascript:autoInherit()"';
     249          checkAll += ' title="Automatically try to inherit values for the selected experimental factors from parent items">';
     250          checkAll += 'Auto-inherit</a></td>'
     251          checkAll += '</tr></table>';
     252          document.getElementById('status').innerHTML = checkAll;
     253          Main.show('warning.missing');
     254        }
    232255      }
    233256      sss.innerHTML = html;
    234257    }
    235     function autoInherit(annotationTypeId)
    236     {
    237       var url = 'index.jsp?ID=<%=ID%>&cmd=AutoInherit&item_id=<%=itemId%>&annotationtype_id=' + annotationTypeId;
    238       Main.openPopup(url, 'AutoInherit', 400, 200);
     258    function checkFactors()
     259    {
     260      var frm = document.forms['experimentalFactors'];
     261      Forms.checkUncheck(frm, /autoinherit/);
     262    }
     263    function autoInherit()
     264    {
     265      var frm = document.forms['experimentalFactors'];
     266      if (Forms.numChecked(frm, /autoinherit/) == 0)
     267      {
     268        alert('Please select at least on experimental factor');
     269        return;
     270      }
     271      Main.openPopup('../../common/progress_reporter.jsp?ID=<%=ID%>&progress=autoinherit&title=Inheriting experimental factors', 'Progress', 400, 200);
     272      frm.cmd.value = 'AutoInherit';
     273      frm.submit();
    239274    }
    240275    </script>
     
    452487          id="experimentalFactors"
    453488          title="<%="Experimental factors (" + experimentalFactors.size() +")"%>"
    454           context="<%=cc%>">     
     489          context="<%=cc%>"
     490          >
     491        <table border="0" cellspacing="0" cellpadding="0" style="width: 100%; max-width: 1000px;"><tr><td>
    455492        <tbl:table
    456493          id="experimentalFactors"
    457494          clazz="itemlist"
    458           style="max-width: 1000px;"
    459495          columns="all"
     496          action="index.jsp"
    460497          >
     498        <tbl:hidden name="item_id" value="<%=Integer.toString(itemId)%>" />
    461499        <tbl:columndef
    462500          id="name"
     
    518556                %>
    519557              </tbl:cell>
    520               <tbl:cell column="status"><div id="status.<%=item.getId()%>"></div></tbl:cell>
     558              <tbl:cell column="status" id="<%="status." + item.getId()%>">
     559              </tbl:cell>
    521560            </tbl:row>
    522561            <%
     
    526565        </tbl:data>
    527566        </tbl:table>
    528         <base:icon image="warning.gif" /> = Some raw bioassays are missing this factor value;
    529           click to automatically try to inherit annotations from parents<br>
    530         <base:icon image="ok.gif" /> = All raw bioassays have a value for this factor
     567        <div align="right" id="warning.missing" style="display: none;">
     568          <base:icon image="warning.gif" /> = Some raw bioassays are missing this factor value<br>
     569          <base:icon image="ok.gif" /> = All raw bioassays have a value for this factor
     570        </div>
     571        </td></tr></table>
    531572        </base:section>
    532573        <%
Note: See TracChangeset for help on using the changeset viewer.