Changeset 1449


Ignore:
Timestamp:
Nov 2, 2011, 3:31:39 PM (12 years ago)
Author:
Martin Svensson
Message:

References #330 Following changes are included in this commit.

  • Tubes in step3(weight input table) are now sorted by the tubes' box-positions.
  • Selection list in step1 is sorting the tubes by their BASE-id in descending order.
  • Samples that already have child-extracts are no longer included in the step1 selection list.
  • A csv-file with label-names can now be downloaded in step2.
  • Also fixed a bugg that occoured when default partition date contained month or date less then 10.
Location:
extensions/net.sf.basedb.reggie/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/resources/partitionform.jsp

    r1430 r1449  
    102102}
    103103
     104function sortTubesByPosition(t1, t2)
     105{
     106  var box1 = t1.box;
     107  var box2 = t2.box;
     108  if (box1 < box2) return -1;
     109  else if (box1>box2) return 1;
     110  else
     111  {
     112    var row1 = t1.row;
     113    var row2 = t2.row;
     114    if (row1 < row2) return -1;
     115    else if (row1>row2) return 1;
     116    else
     117    {
     118      var col1 = t1.column;
     119      var col2 = t2.column;
     120      return col1 - col2;
     121    }
     122  }
     123}
     124
    104125function gotoStep2()
    105126{
     
    112133      selectedTubes.push(specimenTubes[i]);
    113134  }   
    114  
     135  selectedTubes.sort(sortTubesByPosition);
    115136  if (selectedTubes.length == 0)
    116137  {
     
    126147  Main.show('gocancel');
    127148  var currentTime = new Date();
    128   frm.partitionDate.value = currentTime.getFullYear().toString()+(currentTime.getMonth()+1).toString()+currentTime.getDate().toString();
     149  var currentYear = currentTime.getFullYear().toString();
     150  var currentMonth = (currentTime.getMonth()+1).toString();
     151  currentMonth = currentMonth.length < 2 ? '0'+currentMonth : currentMonth;
     152  var currentDate = currentTime.getDate().toString();
     153  currentDate = currentDate.length < 2 ? '0'+currentDate : currentDate;
     154 
     155  var dateString = currentYear + currentMonth + currentDate;
     156 
     157  frm.partitionDate.value = dateString;
    129158  frm.partitionDate.setSelectionRange(0,frm.partitionDate.value.length);
    130159  frm.partitionDate.focus();
     
    136165  var frm = document.forms['reggie'];
    137166  frm.partitionDate.disabled = true; 
    138    
     167 
    139168  var inputWeightHtml; 
    140169  if (selectedTubes.length > 0)
     
    145174    nofPiecesAreValid = Array();
    146175    oneOrMoreWeightsAreSet = Array();
     176   
    147177    for (var i=0;i<selectedTubes.length;i++)
    148178    {
     
    151181      hisWeightsAreValid[i] = true;
    152182      nofPiecesAreValid[i] = false;
    153       oneOrMoreWeightsAreSet[i] = false;
    154     }
    155        
     183      oneOrMoreWeightsAreSet[i] = false;     
     184    }
     185   
    156186    inputWeightHtml = '';
    157 
    158187    var spTitle = 'SpWeight<br>';
    159188    var apTitle = 'ApWeight<br>';
     
    225254  Main.hide('gonext');
    226255  Main.show('gocreate');
    227   frm.bloody0.focus(); 
     256  frm.bloody0.focus();
    228257}
    229258
     
    529558  submitInfo.tubeInfo = tubeInfo;
    530559 
    531   if (debug) Main.debug(JSON.stringify(caseInfo));
    532  
     560  if (debug) Main.debug(JSON.stringify(caseInfo));     
    533561  var request = Ajax.getXmlHttpRequest();
    534562  var url = 'PartitionRegistration.servlet?ID=<%=ID%>&cmd=CreatePartitions';
     
    557585  Main.show('done');
    558586  Main.show('gorestart');
     587}
     588
     589function downloadLabelFile()
     590{
     591  var downloadFileInput = 'PartitionRegistration.servlet?ID=<%=ID%>&cmd=GetLabelFile';
     592  downloadFileInput += '&tubes=';
     593  var separator = '';
     594  for (i in selectedTubes)
     595  {
     596    downloadFileInput += separator + selectedTubes[i].name;
     597    separator = ',';
     598  }
     599  window.location = downloadFileInput;
    559600}
    560601</script>
     
    593634      <tr valign="top">
    594635        <td class="prompt">Specimen tubes</td>
    595         <td class="input"><select style="width:50%" name="tubeSelect" id="tubesSelect" multiple="multiple" size="5" onkeypress='doOnTab(event, goNext)'></select></td>
     636        <td class="input"><select style="width:50%" name="tubeSelect" id="tubesSelect" multiple="multiple" size="12" onkeypress='doOnTab(event, goNext)'></select></td>
    596637        <td class="status" id="tubes.status"></td>
    597638        <td class="help"><span id="tubes.message" class="message" style="display: none;"></span>Select specimen tubes to include in the partition.</td>
     
    608649    <tr>
    609650      <td rowspan="2" class="stepno">2</td>
    610       <td class="steptitle">Enter partition information</td>
     651      <td class="steptitle">General partition information</td>
    611652    </tr>
    612653    <tr>
     
    616657          <td class="prompt">Partition date</td>
    617658          <td class="input"><input type="text" name="partitionDate"
    618              onkeypress="doOnTabOrEnter(event, goNext)" size="12" maxlength="10" onBlur="partitionDateOnBlur()"></td>
     659             onkeypress="focusOnEnter(event, 'download')" size="12" maxlength="10" onBlur="partitionDateOnBlur()"></td>
    619660          <td class="status" id="partitionDate.status"></td>
    620661          <td class="help"><span id="partitionDate.message" class="message" style="display: none;"></span>The date when the partition was done.</td>
     662        </tr>
     663        <tr>
     664          <td class="prompt">Download label file</td>
     665          <td class="input" name="downloadfile.input" id="downloadfile.input">
     666            <base:button id="downloadlabels" title="Download..." onclick="downloadLabelFile()" image="download.gif" style="width:115px"/>
     667          </td>
     668          <td class="status" id="downloadfile.status"></td>
     669          <td class="help"><span id="downloadfile.message" class="message" style="display:none;"></span>Download label file for the selected tubes.</td>
    621670        </tr>       
    622671        </table>
    623672      </td>
    624     </tr>
     673    </tr>   
    625674    </table>
    626675  </div>
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/SpecimenTube.java

    r1425 r1449  
    107107    tubeQuery.restrict(Restrictions.and(Restrictions.eq(Hql.property("originalQuantity"), null),
    108108        Restrictions.rlike(Hql.property("name"), Expressions.parameter("name", "^.+\\.[0-9]+$", Type.STRING))));
    109     tubeQuery.order(Orders.desc(Hql.property("name")));
     109    tubeQuery.order(Orders.desc(Hql.property("id")));
    110110    tubeQuery.include(Include.ALL);
    111111   
     
    113113    for (Sample tube : tubes)
    114114    {
    115       unPartitionedTubes.add(new SpecimenTube(tube));
     115      if (tube.countExtracts() == 0)
     116      {
     117        unPartitionedTubes.add(new SpecimenTube(tube));
     118      }
    116119    }
    117120    return unPartitionedTubes;
     
    121124  private final String row;
    122125  private final String column;
    123 //  private final Float originalQuantity;
    124126 
    125127  private SpecimenTube(Sample sample)
     
    134136      row = wcfRow.format(well.getRow());     
    135137      column = wcfColumn.format(well.getColumn());
    136 //      originalQuantity = sample.getOriginalQuantity();
     138
    137139    }
    138140    else
     
    141143      row = null;
    142144      column = null;
    143 //      originalQuantity = null;
    144145    }
    145146  }
     
    177178    return column;
    178179  }
    179 // 
    180 //  public Float getOriginalQuantity()
    181 //  {
    182 //    return originalQuantity;
    183 //  }
    184  
     180
    185181  @SuppressWarnings("unchecked")
    186182  @Override
     
    190186    json.put("row", row);
    191187    json.put("column", column);
    192 //    json.put("originalQuantity", originalQuantity);
    193188  }
    194189}
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/PartitionRegistrationServlet.java

    r1430 r1449  
    77
    88import javax.servlet.ServletException;
     9import javax.servlet.ServletOutputStream;
    910import javax.servlet.http.HttpServlet;
    1011import javax.servlet.http.HttpServletRequest;
     
    5859   
    5960    final SessionControl sc = Application.getSessionControl(ID, req.getRemoteAddr());
    60     DbControl dc = null;
    61        
     61    DbControl dc = null;   
     62           
    6263    try
    6364    {
     
    7576        json.put("tubeInfo", jsonTubeInfo);
    7677      }
     78      else if ("GetLabelFile".equals(cmd))
     79      {
     80        String firstPart = "";
     81        String secondPart = "";
     82       
     83       
     84        String[] tubeNames = req.getParameter("tubes").split(",");
     85       
     86        String separator = "";
     87        String labelString = "";
     88        if (tubeNames != null && tubeNames.length>0)
     89        {
     90          // Create label-text for each tube
     91          for (int i=0; i<tubeNames.length;i++)
     92          {           
     93            String tubeName = tubeNames[i];
     94            firstPart += separator + tubeName;
     95            separator = "\n";
     96            firstPart += separator + tubeName+".his";
     97            firstPart += separator + tubeName+".ap";
     98           
     99            secondPart += separator + tubeName + ".l";
     100            secondPart += separator + tubeName + ".r";
     101            secondPart += separator + tubeName + ".d";
     102            secondPart += separator + tubeName + ".ft";             
     103          }
     104          labelString = firstPart + secondPart;
     105         
     106          // Send labels in a file to the client.
     107          resp.setHeader("Content-Disposition", "attachment; filename=Partition_labels.csv");
     108          resp.setContentType("text/plain");
     109          ServletOutputStream os = resp.getOutputStream();
     110          os.print(labelString);         
     111          os.flush();
     112          os.close();
     113        }   
     114      }
    77115    }
    78116    catch (Throwable t)
     
    87125    {
    88126      if (dc!=null) dc.close();
    89       json.writeJSONString(resp.getWriter());
     127      json.writeJSONString(resp.getWriter());   
    90128    }
    91129  }
     
    209247                Reggie.setAnnotationValue(hisSample, partitionDateType, partitionDate);
    210248              }
    211             }
    212            
     249            }           
    213250            specimen.setOriginalQuantity(originalQuantity);
    214251           
     
    217254        }
    218255        dc.commit();
    219       }
     256      } 
    220257      json.put("messages", jsonMessages);
    221258    }
Note: See TracChangeset for help on using the changeset viewer.