Changeset 1552


Ignore:
Timestamp:
Mar 7, 2012, 2:37:29 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #364: Put RNA aliquots on bioplate to be used by the Caliper machine

  • Added functionality for creating new quality control plates.
  • A bit more error handling and usability improvements, but the last step still need more checking when selecting wells


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

Legend:

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

    r1551 r1552  
    4545var selectedPlate = null;
    4646
     47
     48var bioPlateNameIsValid = false;
     49
    4750var WELL_ALPHA = [ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
    4851
     
    167170}
    168171
    169 function gotoStep2()
     172function step1IsValid()
    170173{
    171174  var frm = document.forms['reggie'];
     
    183186  {
    184187    setInputStatus('rna', 'Not selected', 'invalid');
    185     return;
     188    return false;
    186189  }
    187190 
    188191  setInputStatus('rna', '', 'valid');
    189192
     193  return true;
     194}
     195
     196function gotoStep2()
     197{
     198  if (!step1IsValid()) return;
     199 
     200  var frm = document.forms['reggie'];
     201 
     202  // Disable step1 controls
    190203  frm.rnaExtracts.disabled = true;
    191204  Main.addClass(document.getElementById('btnSelectRna'), 'disabled');
    192205 
     206  // Load and populate bioplate selection list
    193207  getActiveRnaQcBioPlates();
    194  
    195208  for (var i = 0; i < rnaQcBioPlates.length; i++)
    196209  {
    197210    frm.bioPlates[frm.bioPlates.length] = new Option(rnaQcBioPlates[i].name + ' -- ' + rnaQcBioPlates[i].freeWells + ' free wells', rnaQcBioPlates[i].id);   
    198211  }
    199 
     212  frm.bioPlates[frm.bioPlates.length] = new Option('- create new -', 0);
     213
     214  // Load and populate protcol selection list
    200215  getQualityControlProtocols();
    201216  for (var i = 0; i < rnaQcProtocols.length; i++)
     
    208223  }
    209224 
     225  // Show step 2
    210226  Main.show('bioPlateSection');
    211   Main.show('gocancel'); 
     227  Main.show('gocancel');
     228  bioPlateOnChange();
     229  frm.bioPlates.focus();
    212230  currentStep = 2;
    213231}
     
    234252}
    235253
    236 function createNewPlate()
    237 {
    238   Main.viewOrEditItem('<%=ID%>', 'BIOPLATE', 0, true); 
    239 }
    240 
    241254function getQualityControlProtocols()
    242255{
     
    259272}
    260273
    261 function gotoStep3()
    262 {
    263   var frm = document.forms['reggie'];
    264  
    265   var bioPlateId = frm.bioPlates[frm.bioPlates.selectedIndex].value;
     274// If the 'create new' option is selected we need to display that section
     275function bioPlateOnChange()
     276{
     277  var frm = document.forms['reggie'];
     278 
     279  var createNewSelected = frm.bioPlates.selectedIndex == frm.bioPlates.length-1;
     280  Main.showHide('createNewBioPlateSection', createNewSelected);
     281 
     282  if (createNewSelected)
     283  {
     284    if (frm.bioPlateName.value == '') bioPlateTypeOnChange();
     285    frm.barcode.focus();
     286  }
     287}
     288
     289//  We need to get the next auto-generated name for a new CaliperPlate or BAPlate
     290function bioPlateTypeOnChange()
     291{
     292  var frm = document.forms['reggie'];
     293 
    266294  var request = Ajax.getXmlHttpRequest();
    267   var url = 'RnaQc.servlet?ID=<%=ID%>&cmd=GetFreeWellsInfo&bioPlateId='+bioPlateId;  
     295  var url = 'RnaQc.servlet?ID=<%=ID%>&cmd=GetNextAutoGeneratedPlateName&bioPlateType=' + Forms.getCheckedRadio(frm.bioPlateType).value;
    268296  request.open("GET", url, false); 
    269297  request.send(null);
     
    277305  }
    278306 
     307  frm.bioPlateName.value = response.nextPlateName;
     308  bioPlateNameOnChange();
     309}
     310
     311// Validate that the new plate name is ok
     312function bioPlateNameOnChange()
     313{
     314  var frm = document.forms['reggie'];
     315  var bioPlateName = frm.bioPlateName.value;
     316  bioPlateNameIsValid = false;
     317  if (bioPlateName == '')
     318  {
     319    setInputStatus('bioplatename', 'Missing', 'invalid');
     320    return;
     321  }
     322 
     323  bioPlateNameIsValid = true;
     324 
     325  if (bioPlateName.indexOf('CaliperPlate') != 0 && bioPlateName.indexOf('BAPlate') != 0)
     326  {
     327    setInputStatus('bioplatename', 'Should start with <i>CaliperPlate</code> or <i>BAPlate</i>.', 'warning');
     328    return;
     329  }
     330
     331  setInputStatus('bioplatename', '', 'valid');
     332}
     333
     334
     335
     336function step2IsValid()
     337{
     338  var frm = document.forms['reggie'];
     339  var bioPlateId = frm.bioPlates[frm.bioPlates.selectedIndex].value;
     340  alert(bioPlateNameIsValid);
     341  if (bioPlateId == 0)
     342  {
     343    return bioPlateNameIsValid;
     344  }
     345
     346  return true;
     347}
     348
     349function gotoStep3()
     350{
     351  if (!step2IsValid()) return;
     352 
     353  var frm = document.forms['reggie'];
     354 
     355  var bioPlateId = frm.bioPlates[frm.bioPlates.selectedIndex].value;
     356  var request = Ajax.getXmlHttpRequest();
     357  var url = 'RnaQc.servlet?ID=<%=ID%>&cmd=GetFreeWellsInfo&bioPlateId='+bioPlateId;
     358  if (bioPlateId == 0)
     359  {
     360    url += '&bioPlateType=' + Forms.getCheckedRadio(frm.bioPlateType).value;
     361  }
     362  request.open("GET", url, false); 
     363  request.send(null);
     364 
     365  if (debug) Main.debug(request.responseText);
     366  var response = JSON.parse(request.responseText); 
     367  if (response.status != 'ok')
     368  {
     369    setFatalError(response.message);
     370    return false;
     371  }
    279372  selectedBioPlate = response.bioPlate;
    280  
     373  if (selectedBioPlate.id == 0)
     374  {
     375    selectedBioPlate.name = frm.bioPlateName.value;
     376    selectedBioPlate.barcode = frm.bioPlateBarcode.value;
     377  }
    281378 
    282379  frm.bioPlates.disabled = true;
    283   Main.addClass(document.getElementById('btnCreatePlate'), 'disabled');
     380  frm.protocols.disabled = true;
     381  frm.bioPlateName.disabled = true;
     382  frm.bioPlateBarcode.disabled = true;
     383  frm.bioPlateType[0].disabled = true;
     384  frm.bioPlateType[1].disabled = true;
    284385 
    285386  var html = '';
     
    307408    }
    308409
    309     html += i == 0 ? '<tr class="highlight">' :  '<tr  class="highlight" style="border-top: 1px dotted #A0A0A0;">';
     410    html += i == 0 ? '<tr>' :  '<tr style="xborder-top: 1px dotted #A0A0A0;">';
    310411    html += '<td class="prompt">'+rna.nextRnaQcName+'</td>';
    311     html += '<td class="input">Row <input style="text-transform:uppercase;" type="text"  onkeypress="focusOnEnter(event, \''+column+'\')" name='+row+' value="' + rowValue + '" size="3" maxlength="2" ';
     412    html += '</tr>';
     413    html += '<tr><td class="subprompt">Row</td>'
     414    html += '<td style="width:600px;"><input style="text-transform:uppercase;" type="text"  onkeypress="focusOnEnter(event, \''+column+'\')" name='+row+' value="' + rowValue + '" size="3" maxlength="2" ';
    312415    html += ' onBlur="wellOnChange('+i+')">';
    313416    html += '&nbsp;Column<input type="text" onkeypress="focusOnEnter(event, \''+i+'\')" name='+column+' value="'+ columnValue + '" size="3" maxlength="3" ';
    314417    html += ' onBlur="wellOnChange('+i+')">';
    315     html += '&nbsp;<a href="javascript:suggestWellOnClick('+i+')">Suggest</a><br>';
     418    html += '&nbsp;<a href="javascript:suggestWellOnClick('+i+')">Suggest</a>&nbsp;&nbsp;';
    316419    html += '<input type="checkbox" name="'+hiSense+'" id="' + hiSense + '" value="1" ' + hiSenseChecked + '>';
    317420    html += '<label for="'+hiSense+'">HiSense</label>';
    318421    if (ndConc) html += ' (' + ndConc + ' ng/μl)';
    319422    html += '</td>';
    320     html += '<td class="status" id="well'+i+'.status"></td>';
    321     html += '<td class="help"><span id="well'+i+'.message" class="message" style="display: none;"></span></td>';   
     423    html += '<td class="status" id="well'+i+'.status" rowspan="2"></td>';
     424    html += '</tr>'
     425    html += '<tr><td></td>'
     426    html += '<td class="help" style="width:600px;"><span id="well'+i+'.message" class="message"></span></td>';   
    322427    html += '</tr>';
    323428   
     
    338443  var bioWells = selectedBioPlate.bioWells;
    339444 
     445  // Find first unused well not followed by any used well
     446  var lastUnused = -1;
    340447  for (var i = 0; i < bioWells.length; i++)
    341448  {
    342449    var well = bioWells[i];
    343     if (well.canAdd && !well.isSuggested)
     450    if (well.canAdd && !well.isSuggested && lastUnused == -1)
    344451    {
    345       well.isSuggested = true;
    346       frm['row'+index].value = WELL_ALPHA[well.row];
    347       frm['column'+index].value = well.column+1;
    348       wellOnChange(index);
    349       return;
     452      lastUnused = i;
    350453    }
     454    else if (!well.canAdd || well.isSuggested)
     455    {
     456      lastUnused = -1;
     457    }
     458  }
     459 
     460  if (lastUnused >= 0)
     461  {
     462    var well = bioWells[lastUnused];
     463    well.isSuggested = true;
     464    frm['row'+index].value = WELL_ALPHA[well.row];
     465    frm['column'+index].value = well.column+1;
     466    wellOnChange(index);
    351467  }
    352468 
     
    376492  }
    377493 
    378   setInputStatus('well'+index, '', 'valid')
     494 
     495  setInputStatus('well'+index, ' ', 'valid')
    379496 
    380497}
     
    390507 
    391508  var submitInfo = new Object();
    392  
    393   var bioplate = new Object();
    394   bioplate.id = parseInt(frm.bioPlates[frm.bioPlates.selectedIndex].value);
    395   submitInfo.bioplate = bioplate;
     509  selectedBioPlate.bioWells = null;
     510  submitInfo.bioplate = selectedBioPlate;
    396511 
    397512  var protocol = new Object();
     
    416531
    417532  if (debug) Main.debug(JSON.stringify(submitInfo));
    418  
     533
    419534  var request = Ajax.getXmlHttpRequest();
    420535  var url = 'RnaQc.servlet?ID=<%=ID%>&cmd=PlaceRnaQcAliquots';
     
    511626        <table border="0" cellspacing="0" cellpadding="0" width="100%">
    512627        <tr valign="top">
    513           <td class="prompt">Active bioplates</td>
     628          <td class="prompt">Use existing bioplate</td>
    514629          <td class="input">
    515             <select style="width:90%" name="bioPlates" id="bioPlates" onkeypress='doOnTab(event, goNextAuto)'></select>
    516             <base:buttongroup style="margin-top: 0.5em;">
    517               <base:button title="Create new plate&hellip;" onclick="createNewPlate()" image="add.png" id="btnCreatePlate" />
    518             </base:buttongroup>
     630            <select style="width:90%" name="bioPlates" id="bioPlates" onchange="bioPlateOnChange()"></select>
    519631          </td>
    520632          <td class="status" id="bioplates.status"></td>
     
    523635            RNAQC bioplates without quality score data (determined by absence of
    524636            QCRunDate annotation) with at least enough free wells to place the selected RNA extracts.
    525             Use the <b>Create new plate</b> button to create a new plate.
     637            Select the <b>create new</b> option to create a new plate.
    526638          </td>
    527639        </tr>
     640        <tbody id="createNewBioPlateSection" style="display: none;">
     641          <tr valign="top">
     642            <td class="prompt">Create new bioplate</td>
     643            <td class="input">
     644              <input type="radio" name="bioPlateType" value="CALIPER_RNAQC" id="CALIPER_RNAQC" checked onchange="bioPlateTypeOnChange()"><label for="CALIPER_RNAQC">Caliper</label>
     645              <input type="radio" name="bioPlateType" value="BA_RNAQC" id="BA_RNAQC" onchange="bioPlateTypeOnChange()"><label for="BA_RNAQC">Bioanalyzer</label>
     646             
     647            </td>
     648            <td class="status"></td>
     649            <td class="help">Select the type of bioplate to create</td>
     650          </tr>
     651          <tr valign="top">
     652            <td class="subprompt">Name</td>
     653            <td class="input"><input type="text" class="required" name="bioPlateName" onblur="bioPlateNameOnChange()"></td>
     654            <td class="status" id="bioplatename.status"></td>
     655            <td class="help">
     656              <span id="bioplatename.message" class="message" style="display: none;"></span>
     657              The name of the bioplate should match <i>CaliperPlateNNNN</i> or <i>BAPlateNNNN</i>.
     658              Using a different name pattern may cause other wizards to fail.
     659            </td>
     660          </tr>
     661          <tr valign="top">
     662            <td class="subprompt">Barcode</td>
     663            <td class="input"><input type="text"name="bioPlateBarcode"></td>
     664            <td class="status" id="bioplatebarcode.status"></td>
     665            <td class="help">
     666              The barcode is optional.
     667            </td>
     668          </tr>
     669        </tbody>
    528670        <tr valign="top">
    529671          <td class="prompt">Protocol</td>
     
    552694    <tr>
    553695      <td class="stepfields">
    554         <table id="rnaQc" style="width: 100%; border-collapse: collapse; ">
     696        <table id="rnaQc" style="width: 100%; border-collapse: collapse; border-top: 1px solid transparent;">
    555697        </table>
    556698      </td>
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/BioplateType.java

    r1544 r1552  
    22
    33import java.lang.reflect.Field;
     4import java.util.List;
    45
    56import net.sf.basedb.core.BioPlate;
    67import net.sf.basedb.core.BioPlateType;
    78import net.sf.basedb.core.BioWell.LockMode;
     9import net.sf.basedb.core.BioSource;
    810import net.sf.basedb.core.DbControl;
     11import net.sf.basedb.core.Include;
    912import net.sf.basedb.core.Item;
     13import net.sf.basedb.core.ItemNotFoundException;
    1014import net.sf.basedb.core.ItemQuery;
     15import net.sf.basedb.core.PlateGeometry;
    1116import net.sf.basedb.core.Type;
    1217import net.sf.basedb.core.query.Expressions;
    1318import net.sf.basedb.core.query.Hql;
     19import net.sf.basedb.core.query.Orders;
    1420import net.sf.basedb.core.query.Restrictions;
    1521import net.sf.basedb.reggie.Reggie;
     22import net.sf.basedb.util.MD5;
    1623
    1724/**
     
    2835  */
    2936  public static final BioplateType BA_RNAQC =
    30     new BioplateType("Bioanalyzer RNAQC reaction plate", Item.EXTRACT, Subtype.RNAQC, LockMode.LOCKED_AFTER_ADD);
     37    new BioplateType("Bioanalyzer RNAQC reaction plate", Item.EXTRACT, Subtype.RNAQC, LockMode.LOCKED_AFTER_ADD, 1, 12, "BAPlate");
    3138
    3239  /**
     
    3441  */
    3542  public static final BioplateType CALIPER_RNAQC =
    36     new BioplateType("Caliper RNAQC reaction plate", Item.EXTRACT, Subtype.RNAQC, LockMode.LOCKED_AFTER_ADD);
     43    new BioplateType("Caliper RNAQC reaction plate", Item.EXTRACT, Subtype.RNAQC, LockMode.LOCKED_AFTER_ADD, 8, 12, "CaliperPlate");
    3744
    3845 
     
    4047    Get the bioplate type by name of the static constant defined in this class.
    4148   
    42     @param name The name of the static constant
     49    @param cName The name of the static constant
    4350    @return A bioplate type object or null if not found
    4451   */
     
    6673  private final Subtype subtype;
    6774  private final LockMode lockMode;
     75  private final int rows;
     76  private final int columns;
     77  private final String plateNamePrefix;
    6878  private int id;
     79  private int geometryId;
    6980 
    7081  /**
     
    7485    @param subtype The subtype of biomaterial that can be placed on the bioplate
    7586  */
    76   private BioplateType(String name, Item bioMaterialType, Subtype subtype, LockMode lockMode)
     87  private BioplateType(String name, Item bioMaterialType, Subtype subtype, LockMode lockMode, int rows, int columns, String plateNamePrefix)
    7788  {
    7889    this.name = name;
     
    8091    this.subtype = subtype;
    8192    this.lockMode = lockMode;
     93    this.rows = rows;
     94    this.columns = columns;
     95    this.plateNamePrefix = plateNamePrefix;
    8296  }
    8397   
     
    134148    return plateType;
    135149  }
     150 
     151  /**
     152    Get the plate geometry this bioplate type normally uses.
     153  */
     154  public PlateGeometry getPlateGeometry(DbControl dc)
     155  {
     156    PlateGeometry geometry = null;
     157    if (geometryId == 0)
     158    {
     159      ItemQuery<PlateGeometry> query = PlateGeometry.getQuery();
     160      query.restrict(Restrictions.eq(Hql.property("rows"), Expressions.integer(rows)));
     161      query.restrict(Restrictions.eq(Hql.property("columns"), Expressions.integer(columns)));
     162      List<PlateGeometry> result = query.list(dc);
     163      if (result.size() == 0)
     164      {
     165        throw new ItemNotFoundException("PlateGeometry["+rows+","+columns+"]");
     166      }
     167      geometry = result.get(0);
     168      geometryId = geometry.getId();
     169    }
     170    else
     171    {
     172      geometry = PlateGeometry.getById(dc, geometryId);
     173    }
     174    return geometry;
     175  }
     176 
     177  /**
     178    Generate the next auto-generated bioplate name. This method will search all bioplates
     179    starting with the plate type's prefix and find the one with the highest numeric suffix.
     180    The returned name is the found plate + 1.
     181  */
     182  public String generateNextName(DbControl dc)
     183  {
     184    ItemQuery<BioPlate> query = BioPlate.getQuery();
     185    addFilter(dc, query, false);
     186    query.restrict(Restrictions.rlike(Hql.property("name"), Expressions.string("^" + plateNamePrefix + "[0-9]+$")));
     187    query.order(Orders.desc(Hql.property("name")));
     188    query.setMaxResults(1);
     189    query.include(Include.ALL);
     190    List<BioPlate> plates = query.list(dc);
     191    String name = null;
     192    if (plates.size() == 0)
     193    {
     194      name = plateNamePrefix + "0001";
     195    }
     196    else
     197    {
     198      String plateName = plates.get(0).getName().substring(plateNamePrefix.length());
     199      int nextPlateNumber = Integer.parseInt(plateName) + 1;
     200      name = plateNamePrefix + MD5.leftPad(Integer.toString(nextPlateNumber), '0', 4);
     201    }
     202    return name;
     203  }
     204
    136205 
    137206  /**
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/ReactionPlate.java

    r1544 r1552  
    2020import net.sf.basedb.core.query.Expressions;
    2121import net.sf.basedb.core.query.Hql;
    22 import net.sf.basedb.core.query.Orders;
    2322import net.sf.basedb.core.query.Restrictions;
    2423import net.sf.basedb.reggie.Reggie;
     
    8584  }
    8685 
     86  public static ReactionPlate getNew(DbControl dc, BioplateType bioplateType)
     87  {
     88    BioPlate plate = BioPlate.getNew(dc, bioplateType.getPlateGeometry(dc), bioplateType.load(dc));
     89    return new ReactionPlate(plate);
     90  }
     91 
    8792  private JSONArray jsonWells;
    8893 
     
    107112   
    108113    BioPlate plate = getItem();
    109    
    110     ItemQuery<BioWell> query = plate.getBioWells();
    111    
    112     query.order(Orders.asc(Hql.property("row")));
    113     query.order(Orders.asc(Hql.property("column")));
     114    int rows = plate.getRows();
     115    int cols = plate.getColumns();
    114116   
    115117    jsonWells = new JSONArray();
    116     for (BioWell well : query.list(dc))
     118    for (int r = 0; r < rows; ++r)
    117119    {
    118       JSONObject jsonWell = new JSONObject();
    119       jsonWell.put("id", well.getId());
    120       jsonWell.put("row", well.getRow());
    121       jsonWell.put("column", well.getColumn());
    122       jsonWell.put("canAdd", well.canAddBioMaterial());
    123       jsonWell.put("canRemove", well.canClearBioMaterial());
    124       jsonWells.add(jsonWell);
    125     }
    126    
     120      for (int c = 0; c < cols; ++c)
     121      {
     122        BioWell well = plate.getBioWell(r, c);
     123        JSONObject jsonWell = new JSONObject();
     124        jsonWell.put("id", well.getId());
     125        jsonWell.put("row", well.getRow());
     126        jsonWell.put("column", well.getColumn());
     127        jsonWell.put("canAdd", well.canAddBioMaterial());
     128        jsonWell.put("canRemove", well.canClearBioMaterial());
     129        jsonWells.add(jsonWell);
     130      }
     131    }
    127132  }
    128133 
     
    140145    json.put("usedWells", plate.getUsedWells());
    141146    json.put("barcode", plate.getBarcode());
    142     json.put("rows", geometry.getRows());
    143     json.put("columns", geometry.getColumns());
    144     json.put("bioMaterialType", plateType.getBioMaterialType().name());
     147   
     148    JSONObject jsonBioPlateType = new JSONObject();
     149    jsonBioPlateType.put("id", plateType.getId());
     150    jsonBioPlateType.put("bioMaterialType", plateType.getBioMaterialType().name());
     151    json.put("bioPlateType", jsonBioPlateType);
     152   
     153    JSONObject jsonGeometry = new JSONObject();
     154    jsonGeometry.put("id", geometry.getId());
     155    jsonGeometry.put("rows", geometry.getRows());
     156    jsonGeometry.put("columns", geometry.getColumns());
     157    json.put("geometry", jsonGeometry);
     158   
    145159    if (bioMaterialSubtype != null)
    146160    {
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/RnaQcServlet.java

    r1551 r1552  
    2323import net.sf.basedb.core.BioPlateEventParticipant;
    2424import net.sf.basedb.core.BioPlateEventType;
     25import net.sf.basedb.core.BioPlateType;
    2526import net.sf.basedb.core.BioWell;
    2627import net.sf.basedb.core.DbControl;
     
    3132import net.sf.basedb.core.ItemQuery;
    3233import net.sf.basedb.core.Path;
     34import net.sf.basedb.core.PlateGeometry;
    3335import net.sf.basedb.core.Protocol;
    3436import net.sf.basedb.core.SessionControl;
     
    148150       
    149151        json.put("protcols", jsonProtocols);
    150        
     152      }
     153      else if ("GetNextAutoGeneratedPlateName".equals(cmd))
     154      {
     155        /*
     156          Eg. CaliperPlate0001, CaliperPlate0002 and so on
     157         */
     158        BioplateType bioPlateType = BioplateType.getByCName(req.getParameter("bioPlateType"));
     159        dc = sc.newDbControl();
     160        json.put("nextPlateName", bioPlateType.generateNextName(dc));
    151161      }
    152162      else if ("GetFreeWellsInfo".equals(cmd))
     
    156166        */
    157167        int bioPlateId = Values.getInt(req.getParameter("bioPlateId"));
    158         dc = sc.newDbControl();
    159         ReactionPlate plate = ReactionPlate.getById(dc, bioPlateId);
     168
     169        dc = sc.newDbControl();
     170        ReactionPlate plate = null;
     171        if (bioPlateId == 0)
     172        {
     173          BioplateType bioPlateType = BioplateType.getByCName(req.getParameter("bioPlateType"));
     174          plate = ReactionPlate.getNew(dc, bioPlateType);
     175        }
     176        else
     177        {
     178          plate = ReactionPlate.getById(dc, bioPlateId);
     179        }
    160180       
    161181        plate.loadBioWells(dc);
     
    230250        AnnotationType qcHiSenseType = Reggie.findAnnotationType(dc, Item.EXTRACT, Reggie.ANNOTATION_QC_HISENSE, true);
    231251       
    232         Number plateId = (Number)jsonPlate.get("id");
     252        int plateId = ((Number)jsonPlate.get("id")).intValue();
    233253        Number protocolId = jsonProtocol == null ? null : (Number)jsonProtocol.get("id");   
    234254       
    235         BioPlate plate = BioPlate.getById(dc, plateId.intValue());
     255        BioPlate plate = null;
     256        if (plateId == 0)
     257        {
     258          JSONObject jsonBioPlateType = (JSONObject)jsonPlate.get("bioPlateType");
     259          JSONObject jsonGeometry = (JSONObject)jsonPlate.get("geometry");
     260         
     261          BioPlateType plateType = BioPlateType.getById(dc, ((Number)jsonBioPlateType.get("id")).intValue());
     262          PlateGeometry geometry = PlateGeometry.getById(dc, ((Number)jsonGeometry.get("id")).intValue());
     263         
     264          plate = BioPlate.getNew(dc, geometry, plateType);
     265          plate.setName((String)jsonPlate.get("name"));
     266          plate.setBarcode((String)jsonPlate.get("barcode"));
     267          dc.saveItem(plate);
     268          jsonMessages.add("Created bioplate '" + plate.getName() + "'");
     269        }
     270        else
     271        {
     272          plate = BioPlate.getById(dc, plateId);
     273        }
    236274        BioPlateEventType eventType = BioPlateEventType.getById(dc, BioPlateEventType.CREATE_BIOMATERIAL);
    237275        BioPlateEvent event = BioPlateEvent.getNew(dc, eventType);
Note: See TracChangeset for help on using the changeset viewer.