Changeset 1379
- Timestamp:
- Jun 27, 2011, 3:58:52 PM (12 years ago)
- Location:
- extensions/net.sf.basedb.reggie/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.reggie/trunk/resources/specimentube.jsp
r1375 r1379 30 30 var nofDeliveredTubesIsValid = true; 31 31 var nofTubesIsValid = false; 32 var lateralityIsValid = false; 32 33 var debug = false; 33 34 var currentStep = 1; 34 35 35 36 var caseInfo = null; 36 var specimenTubeInfo = null;37 var boxInfo = null; 37 38 38 39 function init() … … 42 43 } 43 44 44 function goNext( manual)45 function goNext() 45 46 { 46 47 setInnerHTML('gonext.message', ''); 47 48 if (currentStep == 1) 48 { 49 if(step1IsValid()) 50 { 51 gotoStep2(); 52 } 53 } 54 if (currentStep == 2) 55 { 56 gotoStep3(); 57 } 49 { 50 gotoStep2(); 51 } 52 else if (currentStep == 2) 53 { 54 if (step2IsValid()) gotoStep3(); 55 } 56 } 57 58 function step2IsValid() 59 { 60 var frm = document.forms['reggie']; 61 if (!nofTubesIsValid) frm.nofTubes.focus(); 62 else if (lateralityIsValid) return true; 58 63 } 59 64 … … 61 66 { 62 67 var frm = document.forms['reggie']; 63 frm.caseName.disabled = true; 64 currentStep = 2; 68 var caseName = frm.caseName.value; 69 if (caseName == '') 70 { 71 setInputStatus('case', 'Missing', 'invalid'); 72 return; 73 } 74 setInputStatus('case', '', 'valid'); 75 76 getCaseInfo(); 77 65 78 var hasSpecimen = caseInfo.specimen && caseInfo.specimen.length > 0; 66 79 var hasLeftSpecimen = false; … … 74 87 var thisPad = null; 75 88 89 frm.caseName.disabled = true; 90 76 91 Main.show('gocancel'); 77 92 Main.show('caseSection'); 78 93 94 frm.nofTubes.focus(); 95 currentStep = 2; 96 97 // Load annotations from the actual case 98 if (hasSpecimen) 99 { 100 frm.nofTubes.value = thisNumberOfTubes; 101 frm.nofTubes.disabled = true; 102 frm.arrivalDate.focus(); 103 for (var i=0; i < caseInfo.specimen.length; i++) 104 { 105 var specimen = caseInfo.specimen[i]; 106 if (specimen.pad && !thisPad) 107 { 108 thisPad = specimen.pad; 109 } 110 if(specimen.arrivalDate && !thisArrivalDate) 111 { 112 thisArrivalDate = specimen.arrivalDate; 113 } 114 if (specimen.nofTubes && !thisNumberOfTubes) 115 { 116 thisNumberOfTubes = specimen.nofTubes; 117 } 118 if (specimen.samplingDate && !thisCaseSamplingDate) 119 { 120 thisCaseSamplingDate = specimen.samplingDate; 121 } 122 if (specimen.rnaLaterDate && !thisCaseRNALaterDate) 123 { 124 thisCaseRNALaterDate = specimen.rnaLaterDate; 125 } 126 if (specimen.laterality && !thisCaseLaterality) 127 { 128 if (specimen.laterality == 'LEFT') hasLeftSpecimen = true; 129 if (specimen.laterality == 'RIGHT') hasRightSpecimen = true; 130 thisCaseLaterality = specimen.laterality; 131 } 132 else if(!thisCaseLaterality) 133 { 134 hasUnknownSpecimen = true; 135 } 136 } 137 // If the number of tubes not is set - use the current number of specimen tubes. 138 if (!thisNumberOfTubes) thisNumberOfTubes = caseInfo.specimen.length; 139 140 // Check that all specimen tubes have the same laterality 141 var numLateralities = 0; 142 if (hasLeftSpecimen) numLateralities++; 143 if (hasRightSpecimen) numLateralities++; 144 if (hasUnknownSpecimen) numLateralities++; 145 if (numLateralities > 1) 146 { 147 setInputStatus('laterality', 'Specimen tubes with different laterality', 'warning'); 148 thisCaseLaterality = null; 149 Forms.checkRadio(frm.laterality, thisCaseLaterality); 150 } 151 Forms.checkRadio(frm.laterality, thisCaseLaterality); 152 lateralityOnChange(); 153 154 if (thisPad != null) 155 { 156 frm.pad.value = thisPad; 157 padOnChange(); 158 } 159 if (thisArrivalDate != null) 160 { 161 frm.arrivalDate.value = thisArrivalDate; 162 } 163 if (thisNumberOfTubes != null) 164 { 165 frm.nofTubes.value = thisNumberOfTubes; 166 nofTubesOnChange(); 167 } 168 if (thisCaseSamplingDate != null) 169 { 170 frm.samplingDate.value = thisCaseSamplingDate.substring(0, 8); 171 frm.samplingTime.value = thisCaseSamplingDate.substring(9, 13); 172 samplingDateTimeOnChange(); 173 } 174 if (thisCaseRNALaterDate != null) 175 { 176 frm.rnaLaterDate.value = thisCaseRNALaterDate.substring(0, 8); 177 frm.rnaLaterTime.value = thisCaseRNALaterDate.substring(9, 13); 178 rnaLaterDateTimeOnChange(); 179 } 180 } 181 182 var hasLeftCase = false; 183 var hasRightCase = false; 184 var hasUnknownCase = false; 79 185 if (caseInfo.id) 80 186 { 81 187 setInnerHTML('step2.title', 'Update Case Information'); 82 if (caseInfo.pad )188 if (caseInfo.pad && !thisPad) 83 189 { 84 frm.pad.value = caseInfo.pad;190 thisPad = caseInfo.pad; 85 191 } 86 192 if (caseInfo.laterality) 87 193 { 88 if(caseInfo.laterality == 'LEFT') hasLeftSpecimen = true; 89 if(caseInfo.laterality == 'RIGHT') hasRightSpecimen = true; 90 thisCaseLaterality = caseInfo.laterality; 91 Forms.checkRadio(frm.laterality, thisCaseLaterality); 194 var lateralityInput = ''; 195 lateralityInput += '<input type="radio" name="laterality" value="LEFT" '; 196 if (caseInfo.laterality == 'LEFT') lateralityInput += 'checked'; 197 lateralityInput += ' onChange="lateralityOnChange()">LEFT'; 198 lateralityInput += '<br>'; 199 lateralityInput += '<input type="radio" name="laterality" value="RIGHT" '; 200 if (caseInfo.laterality == 'RIGHT') lateralityInput += 'checked'; 201 lateralityInput += ' onChange="lateralityOnChange()">RIGHT'; 202 setInnerHTML('laterality.input', lateralityInput); 92 203 lateralityOnChange(); 93 }94 // Load annotations from the actual case95 if (hasSpecimen)96 {97 frm.nofTubes.value = thisNumberOfTubes;98 frm.nofTubes.disabled = true;99 for (var i=0; i < caseInfo.specimen.length; i++)100 {101 var specimen = caseInfo.specimen[i];102 if (specimen.pad && !thisPad)103 {104 thisPad = specimen.pad;105 }106 if(specimen.arrivalDate && !thisArrivalDate)107 {108 thisArrivalDate = specimen.arrivalDate;109 }110 if (specimen.nofTubes && !thisNumberOfTubes)111 {112 thisNumberOfTubes = specimen.nofTubes;113 }114 if (specimen.samplingDate && !thisCaseSamplingDate)115 {116 thisCaseSamplingDate = specimen.samplingDate;117 }118 if (specimen.rnaLaterDate && !thisCaseRNALaterDate)119 {120 thisCaseRNALaterDate = specimen.rnaLaterDate;121 }122 if (specimen.laterality)123 {124 if (specimen.laterality == 'LEFT') hasLeftSpecimen = true;125 if (specimen.laterality == 'RIGHT') hasRightSpecimen = true;126 if (!thisCaseLaterality) thisCaseLaterality = specimen.laterality;127 }128 else129 {130 hasUnknownSpecimen = true;131 }132 }133 // If the number of tubes not is set - use the current number of specimen tubes.134 if (!thisNumberOfTubes) thisNumberOfTubes = caseInfo.specimen.length;135 frm.nofTubes.value = thisNumberOfTubes;136 // Check that all specimen tubes have the same laterality137 var numLateralities = 0;138 if (hasLeftSpecimen) numLateralities++;139 if (hasRightSpecimen) numLateralities++;140 if (hasUnknownSpecimen) numLateralities++;141 if (numLateralities > 1)142 {143 setInputStatus('laterality', 'Specimen tubes with different laterality', 'warning');144 thisCaseLaterality = null;145 Forms.checkRadio(frm.laterality, thisCaseLaterality);146 }147 Forms.checkRadio(frm.laterality, thisCaseLaterality);148 lateralityOnChange();149 150 if (thisPad != null)151 {152 frm.pad.value = thisPad;153 }154 if (thisArrivalDate != null)155 {156 frm.arrivalDate.value = thisArrivalDate;157 }158 if (thisNumberOfTubes != null)159 {160 frm.nofTubes.value = thisNumberOfTubes;161 }162 if (thisCaseSamplingDate != null)163 {164 frm.samplingDate.value = thisCaseSamplingDate.substring(0, 8);165 frm.samplingTime.value = thisCaseSamplingDate.substring(9, 13);166 samplingDateTimeOnChange();167 }168 if (thisCaseRNALaterDate != null)169 {170 frm.rnaLaterDate.value = thisCaseRNALaterDate.substring(0, 8);171 frm.rnaLaterTime.value = thisCaseRNALaterDate.substring(9, 13);172 rnaLaterDateTimeOnChange();173 }174 204 } 175 205 } … … 193 223 frm.rnaLaterTime.disabled = true; 194 224 frm.samplingTime.disabled = true; 195 frm.pathNote.disabled = true; 225 frm.pathNote.disabled = true; 196 226 197 227 for (var i=0;i<nofTubes;i++) 198 228 { 199 229 var specimen = null; 230 var boxValue = ''; 231 var rowValue = ''; 232 var columnValue = ''; 200 233 if (caseInfo.specimen && caseInfo.specimen.length>0 && i<caseInfo.specimen.length) 201 234 { 202 235 specimen = caseInfo.specimen[i]; 236 boxValue = specimen.box; 237 rowValue = specimen.row; 238 columnValue = specimen.column; 203 239 } 204 240 inputTubeHtml += '<tr>'; … … 209 245 inputTubeHtml += '<tr>'; 210 246 inputTubeHtml += '<td class="subprompt">Box</td>'; 211 inputTubeHtml += '<td class="input"><input type="text" name='+box+' value=" " size="12" maxlength="10"></td>';247 inputTubeHtml += '<td class="input"><input type="text" name='+box+' value="' + boxValue + '" size="18" maxlength="12" onBlur="boxOnChange('+i+')"></td>'; 212 248 inputTubeHtml += '<td class="status" id="'+box+'.status"></td>'; 213 249 inputTubeHtml += '<td class="help"><span id="'+box+'.message" class="message" style="display: none;"></span>Box the specimen tube is located in.</td>'; 214 inputTubeHtml += '</tr>'; 250 inputTubeHtml += '</tr>'; 215 251 216 252 var row = 'row'+i; … … 218 254 inputTubeHtml += '<tr>'; 219 255 inputTubeHtml += '<td class="subprompt">Row</td>'; 220 inputTubeHtml += '<td class="input"><input type="text" name='+row+' value="" size="3" maxlength="3">'; 221 inputTubeHtml += ' Column<input type="text" name='+column+' value="" size="3" maxlength="3">'; 256 inputTubeHtml += '<td class="input"><input type="text" name='+row+' value="' + rowValue + '" size="3" maxlength="3"'; 257 inputTubeHtml += boxValue != '' ? '' : ' disabled'; 258 inputTubeHtml += ' onBlur="wellOnChange('+i+')">'; 259 inputTubeHtml += ' Column<input type="text" name='+column+' value="'+ columnValue + '" size="3" maxlength="3"'; 260 inputTubeHtml += boxValue != '' ? '' : ' disabled'; 261 inputTubeHtml += ' onBlur="wellOnChange('+i+')">'; 222 262 inputTubeHtml += '</td>'; 223 263 inputTubeHtml += '<td class="status" id="rowColumn'+i+'.status"></td>'; 224 inputTubeHtml += '<td class="help"><span id="rowColumn'+i+'.message" class="message" style="display: none;"></span> Row and column the specimen tube is located at.</td>';264 inputTubeHtml += '<td class="help"><span id="rowColumn'+i+'.message" class="message" style="display: none;"></span></td>'; 225 265 inputTubeHtml += '</tr>'; 226 266 … … 252 292 inputTubeHtml += '<tr>'; 253 293 inputTubeHtml += '<td class="subprompt">Operator comment</td>'; 254 inputTubeHtml += '<td class="input">< input type="text" name='+deliveryComment+' value="" size="12" maxlength="10"></td>';294 inputTubeHtml += '<td class="input"><textarea rows="3" cols="30" name='+deliveryComment+' value=""></textarea></td>'; 255 295 inputTubeHtml += '<td class="status" id="'+deliveryComment+'.status"></td>'; 256 296 inputTubeHtml += '<td class="help"><span id="'+deliveryComment+'.message" class="message" style="display: none;"></span>Operator delivery comment</td>'; 257 297 inputTubeHtml += '</tr>'; 258 298 } 259 260 299 setInnerHTML('tubeInputs', inputTubeHtml); 261 Main.show('tubeSection'); 300 boxInfo = Array(); 301 currentStep = 3; 302 Main.show('tubeSection'); 262 303 Main.hide('gonext'); 263 Main.show('gocreate'); 264 304 Main.show('gocreate'); 305 frm.box0.focus(); 265 306 } 266 307 … … 300 341 } 301 342 343 function boxOnChange(tubeIndex) 344 { 345 var frm = document.forms['reggie']; 346 var boxName = 'box'+tubeIndex; 347 var rowName = 'row'+tubeIndex; 348 var columnName = 'column'+tubeIndex; 349 var boxValue = frm.elements[boxName].value; 350 351 if (frm.elements[boxName].value == '') 352 { 353 frm.elements[rowName].disabled = true; 354 frm.elements[rowName].value = ''; 355 frm.elements[columnName].disabled = true; 356 frm.elements[columnName].value = ''; 357 frm.elements['his'+tubeIndex].focus(); 358 setInputStatus(boxName, '', ''); 359 setInputStatus('rowColumn'+tubeIndex, '', ''); 360 return false; 361 } 362 363 var request = Ajax.getXmlHttpRequest(); 364 var url = 'SpecimenTubeRegistration.servlet?ID=<%=ID%>&cmd=GetBoxInfo'; 365 url += '&boxName=' + boxValue; 366 request.open("GET", url, false); 367 request.send(null); 368 369 if (debug) Main.debug(request.responseText); 370 371 var response = JSON.parse(request.responseText); 372 if (response.status != 'ok') 373 { 374 setFatalError(response.message); 375 return false; 376 } 377 if (!response.boxInfo) 378 { 379 setInputStatus(boxName, response.message, 'invalid'); 380 frm.elements[rowName].value = ''; 381 frm.elements[columnName].value = ''; 382 frm.elements[rowName].disabled = true; 383 frm.elements[columnName].disabled = true; 384 return false; 385 } 386 else 387 { 388 boxInfo[tubeIndex] = response.boxInfo; 389 frm.elements[rowName].disabled = false; 390 frm.elements[columnName].disabled = false; 391 frm.elements[rowName].value = ''; 392 setInputStatus('rowColumn'+tubeIndex,'Row[A-'+response.rows+'], Columns[1-'+response.columns+']',''); 393 frm.elements[columnName].disabled = ''; 394 setInputStatus(boxName, '', 'valid'); 395 frm.elements[rowName].focus(); 396 } 397 } 398 399 function wellOnChange(tubeIndex) 400 { 401 var frm = document.forms['reggie']; 402 var boxName = 'box'+tubeIndex; 403 var rowName = 'row'+tubeIndex; 404 var columnName = 'column'+tubeIndex; 405 var rowValue = frm.elements[rowName].value; 406 var columnValue = frm.elements[columnName].value 407 var boxValue = frm.elements[boxName].value; 408 var nofTubes = frm.nofTubes.value; 409 410 if (boxValue != '' && 411 (rowValue == '' || columnValue == '')) 412 { 413 setInputStatus('rowColumn'+tubeIndex, 'Row or column cannot be empty when the box is specified.', 'invalid'); 414 return false; 415 } 416 417 var request = Ajax.getXmlHttpRequest(); 418 var url = 'SpecimenTubeRegistration.servlet?ID=<%=ID%>&cmd=ValidateWell'; 419 url += '&boxId=' + boxInfo[tubeIndex]; 420 url += '&row=' + rowValue; 421 url += '&column=' + columnValue; 422 request.open("GET", url, false); 423 request.send(null); 424 425 if (debug) Main.debug(request.responseText); 426 427 var response = JSON.parse(request.responseText); 428 if (response.status != 'ok') 429 { 430 setFatalError(response.message); 431 return false; 432 } 433 if (response.message) 434 { 435 setInputStatus('rowColumn'+tubeIndex, response.message, 'invalid') 436 return false; 437 } 438 for (var i=0;i<nofTubes;i++) 439 { 440 if (i != tubeIndex && frm.elements['box'+i].value == boxValue) 441 { 442 if (rowValue == frm.elements['row'+i].value && 443 columnValue == frm.elements['column'+i].value) 444 { 445 setInputStatus('rowColumn'+tubeIndex, 'The row and column are already used once in this wizard','invalid'); 446 return false; 447 } 448 } 449 } 450 setInputStatus('rowColumn'+tubeIndex, '', 'valid'); 451 } 452 302 453 function rnaLaterDateTimeOnChange() 303 454 { … … 372 523 } 373 524 374 function nofTubesOn Blur()525 function nofTubesOnChange() 375 526 { 376 527 var frm = document.forms['reggie']; … … 382 533 return; 383 534 } 384 setInputStatus('nofTubes','', 'valid'); 385 } 386 387 function caseNameOnBlur() 388 { 389 var frm = document.forms['reggie']; 390 var caseName = frm.caseName.value; 391 if (caseName == '') 392 { 393 setInputStatus('case', 'Missing', 'invalid'); 394 return; 395 } 396 setInputStatus('case', '', 'valid'); 397 caseIsValid = true; 398 399 getCaseInfo(); 535 setInputStatus('nofTubes','', 'valid'); 536 nofTubesIsValid = true; 400 537 } 401 538 … … 428 565 return; 429 566 } 567 setInputStatus('laterality', '', 'valid'); 568 lateralityIsValid = true; 430 569 var laterality = selectedLaterality.value; 570 431 571 // No specimen tubes? 432 572 if (!caseInfo.specimen || caseInfo.specimen.length == 0) return; … … 447 587 return; 448 588 } 589 } 590 } 591 592 function step3IsValid() 593 { 594 return false; 595 } 596 597 function goCreate() 598 { 599 if (!step3IsValid()) return; 600 601 Main.hide('gocancel'); 602 Main.hide('gocreate'); 603 var frm = document.forms['reggie']; 604 605 caseInfo.laterality = Forms.getCheckedRadio(frm.laterality).value; 606 caseInfo.pad = frm.pad.value; 607 caseInfo.samplingDate = Main.trimString(frm.samplingDate.value + ' ' + frm.samplingTime.value); 608 caseInfo.rnaLaterDate = Main.trimString(frm.rnaLaterDate.value + ' ' + frm.rnaLaterTime.value); 609 caseInfo.pathNote = frm.pathNote.value; 610 611 var nofTubes = frm.nofTubes.value; 612 for (var i=0; i<nofTubes; i++) 613 { 614 var specimenTube = new Object(); 615 if (caseInfo.specimen[i]) specimenTube = caseInfo.specimen[i]; 616 specimenTube.name = caseInfo.name+'.'+i; 617 618 caseInfo.specimen[i] = specimenTube; 619 } 620 621 var submitInfo = new Object(); 622 submitInfo.caseInfo = caseInfo; 623 624 if (debug) Main.debug(JSON.stringify(submitInfo)); 625 626 var request = Ajax.getXmlHttpRequest(); 627 var url = 'SpecimenTubeRegistration.servlet?ID=<%=ID%>&cmd='; 628 url += 'CreateSpecimenTubes'; 629 request.open("POST", url, false); 630 request.setRequestHeader("Content-Type", "application/json"); 631 request.send(JSON.stringify(submitInfo)); 632 633 if (debug) Main.debug(request.responseText); 634 635 var response = JSON.parse(request.responseText); 636 if (response.status != 'ok') 637 { 638 setFatalError(response.message); 639 return false; 449 640 } 450 641 } … … 468 659 return false; 469 660 } 470 471 661 caseInfo = response.caseInfo; 472 if (caseInfo) 473 { 474 gotoStep2(); 475 } 476 } 477 662 } 478 663 </script> 479 664 … … 511 696 <td class="prompt">Case name</td> 512 697 <td class="input"><input type="text" name="caseName" 513 size="18" maxlength="12" on blur="caseNameOnBlur()"></td>698 size="18" maxlength="12" onkeypress="doOnTabOrEnter(event, goNext)"></td> 514 699 <td class="status" id="case.status"></td> 515 700 <td class="help"><span id="case.message" class="message" style="display: none;"></span>The case (barcode) associated with this specimen tube.</td> … … 533 718 <td class="prompt">Number of tubes</td> 534 719 <td class="input"><input type="text" name="nofTubes" 535 value="" size="12" maxlength="10" onblur= "nofTubesOnBlur()"></td>720 value="" size="12" maxlength="10" onblur='nofTubesOnChange()'></td> 536 721 <td class="status" id="nofTubes.status"></td> 537 722 <td class="help"><span id="nofTubes.message" class="message" style="display:none"></span>Number of tubes in this case.</td> … … 575 760 <input type="radio" name="laterality" value="LEFT" onclick="lateralityOnChange()">LEFT<br> 576 761 <input type="radio" name="laterality" value="RIGHT" onclick="lateralityOnChange()">RIGHT<br> 577 <input type="radio" name="laterality" value="" onclick="lateralityOnChange()"><i>unknown</i>762 <input type="radio" name="laterality" value="" checked onclick="lateralityOnChange()"><i>unknown</i> 578 763 </td> 579 764 <td class="status" id="laterality.status"></td> … … 582 767 <tr> 583 768 <td class="prompt" id="pathNote.prompt">Path note</td> 584 <td class="input" id="pathNote.input"><textarea rows="3" cols="30" name="pathNote" value=""></textarea></td> 769 <td class="input" id="pathNote.input"><textarea rows="3" cols="30" 770 name="pathNote" value="" onkeypress="doOnTabOrEnter(event, goNext)"></textarea></td> 585 771 <td class="status" id="pathNote.status"></td> 586 772 <td class="help"><span id="pathNote.message" class="message" style="display: none;"></span></td> -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/Reggie.java
r1378 r1379 91 91 */ 92 92 public static final String ANNOTATION_PAD_CASE = "PADcase"; 93 94 /** 95 The name of the "PathNote" annotation type, 96 used for samples (Case). It is a string annotation type. 97 */ 98 public static final String ANNOTATION_PATH_NOTE = "PathNote"; 93 99 94 100 /** … … 135 141 */ 136 142 public static final String GROUP_PATIENT_CURATOR = "PatientCurator"; 143 144 /** 145 The name of the "OperatorComment" annotation type, used 146 for samples (Specimen tube). It is a String annotation type. 147 */ 148 public static final String ANNOTATION_OPERATOR_COMMENT = "OperatorComment"; 137 149 138 150 /** -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/SpecimenTube.java
r1372 r1379 4 4 import java.util.List; 5 5 6 import org.json.simple.JSONObject; 7 8 import net.sf.basedb.core.BioPlate; 9 import net.sf.basedb.core.BioWell; 6 10 import net.sf.basedb.core.DbControl; 7 11 import net.sf.basedb.core.Include; … … 63 67 List<SpecimenTube> tubes = new ArrayList<SpecimenTube>(); 64 68 for (Sample s : specimenQuery.list(dc)) 65 { 69 { 66 70 tubes.add(new SpecimenTube(s)); 67 71 } … … 93 97 } 94 98 99 private final String box; 100 private final Integer row; 101 private final Integer column; 102 95 103 private SpecimenTube(Sample sample) 96 104 { 97 105 super(sample); 98 } 106 if (sample.getBioWell() != null) 107 { 108 BioWell well = sample.getBioWell(); 109 box = well.getPlate().getName(); 110 row = well.getRow(); 111 column = well.getColumn(); 112 } 113 else 114 { 115 box = null; 116 row = null; 117 column = null; 118 } 119 } 120 99 121 100 122 /** … … 106 128 } 107 129 130 /** 131 Get the box where this specimen tube is located 132 */ 133 public String getBox() 134 { 135 return this.box; 136 } 137 138 /** 139 Get the row index in the box, where this specimen tube can be found. 140 */ 141 public Integer getRow() 142 { 143 return row; 144 } 145 146 /** 147 Get the column index in the box, where this specimen tube can be found. 148 */ 149 public Integer getColumn() 150 { 151 return column; 152 } 108 153 154 @SuppressWarnings("unchecked") 155 @Override 156 protected void initJSON(JSONObject json) 157 { 158 json.put("box", box); 159 json.put("row", row); 160 json.put("column", column); 161 } 109 162 } -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/InstallServlet.java
r1375 r1379 129 129 jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_NOF_DELIVERED_TUBES, Item.SAMPLE, Type.INT, 1, 130 130 null, effectiveOptions, createIfMissing)); 131 jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_OPERATOR_COMMENT, Item.SAMPLE, Type.STRING, 1, 132 null, effectiveOptions, createIfMissing)); 133 jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_PATH_NOTE, Item.SAMPLE, Type.STRING, 1, 134 null, effectiveOptions, createIfMissing)); 131 135 132 136 json.put("checks", jsonChecks); -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/SpecimenTubeServlet.java
r1375 r1379 11 11 import javax.servlet.http.HttpServletResponse; 12 12 13 import net.sf.basedb.core.AnnotationSet;14 13 import net.sf.basedb.core.AnnotationType; 15 14 import net.sf.basedb.core.Application; 15 import net.sf.basedb.core.BioPlate; 16 import net.sf.basedb.core.BioWell; 16 17 import net.sf.basedb.core.DbControl; 18 import net.sf.basedb.core.InvalidDataException; 17 19 import net.sf.basedb.core.Item; 20 import net.sf.basedb.core.ItemQuery; 18 21 import net.sf.basedb.core.Sample; 19 22 import net.sf.basedb.core.SessionControl; 23 import net.sf.basedb.core.Type; 24 import net.sf.basedb.core.query.Expression; 25 import net.sf.basedb.core.query.Expressions; 26 import net.sf.basedb.core.query.Hql; 27 import net.sf.basedb.core.query.Restrictions; 20 28 import net.sf.basedb.reggie.Reggie; 21 29 import net.sf.basedb.reggie.converter.DateToStringConverter; … … 25 33 import net.sf.basedb.util.Values; 26 34 import net.sf.basedb.util.error.ThrowableUtil; 35 import net.sf.basedb.util.formatter.WellCoordinateFormatter; 27 36 28 37 import org.json.simple.JSONArray; … … 95 104 AnnotationType arrivalDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_ARRIVAL_DATE, true); 96 105 AnnotationType nofDeliveredTubesType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_NOF_DELIVERED_TUBES, true); 106 AnnotationType operatorCommentType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_OPERATOR_COMMENT, true); 97 107 98 108 DateToStringConverter dateTimeConverter = new DateToStringConverter(new SimpleDateFormat("yyyyMMdd HHmm")); … … 106 116 tube.loadAnnotations("arrivalDate", arrivalDateType, dateConverter); 107 117 tube.loadAnnotations("nofTubes", nofDeliveredTubesType, null); 118 tube.loadAnnotations("operatorComment", operatorCommentType, null); 108 119 109 120 jsonTubes.add(tube.asJSONObject()); … … 113 124 114 125 json.put("caseInfo", jsonCase); 126 } 127 else if ("GetBoxInfo".equals(cmd)) 128 { 129 dc = sc.newDbControl(); 130 131 String boxName = req.getParameter("boxName"); 132 ItemQuery<BioPlate> boxQuery = BioPlate.getQuery(); 133 boxQuery.restrict(Restrictions.eq(Hql.property("name"), Expressions.string(boxName))); 134 List<BioPlate> boxes = boxQuery.list(dc); 135 136 if (boxes.size() == 0) 137 { 138 json.put("message", "Box does not exist."); 139 } 140 else if (boxes.size() > 1) 141 { 142 json.put("message", "More then one box were found."); 143 } 144 else 145 { 146 WellCoordinateFormatter wcfRow = new WellCoordinateFormatter(true); 147 148 json.put("boxInfo", boxes.get(0).getId()); 149 json.put("rows", wcfRow.format(boxes.get(0).getRows()-1)); 150 json.put("columns", boxes.get(0).getColumns()); 151 } 152 153 } 154 else if ("ValidateWell".equals(cmd)) 155 { 156 dc = sc.newDbControl(); 157 158 int boxId = Integer.parseInt(req.getParameter("boxId")); 159 BioPlate plate = BioPlate.getById(dc, boxId); 160 161 WellCoordinateFormatter wcfRow = new WellCoordinateFormatter(true); 162 String rowString = req.getParameter("row"); 163 int rowNumber = wcfRow.parseString(rowString); 164 165 Integer columnIndex = Integer.parseInt(req.getParameter("column")) - 1; 166 WellCoordinateFormatter wcfColumn = new WellCoordinateFormatter(false); 167 168 String msg = null; 169 if (rowNumber < 1 || rowNumber > plate.getRows()) 170 { 171 msg = "The row must be between "+ wcfRow.format(0) +" and " + wcfRow.format(plate.getRows()-1); 172 } 173 else if (columnIndex < 0 || columnIndex > plate.getColumns()) 174 { 175 msg = "The column must be between " + 1 + " and " + plate.getColumns(); 176 } 177 else if (!plate.getBioWell(rowNumber-1, columnIndex).isEmpty()) 178 { 179 msg = "Specified row:column("+rowString+":"+wcfColumn.format(columnIndex)+") is already taken."; 180 } 181 json.put("message", msg); 115 182 } 116 183 } … … 144 211 145 212 JSONArray jsonMessages = new JSONArray(); 146 147 213 final SessionControl sc = Application.getSessionControl(ID, req.getRemoteAddr()); 148 214 DbControl dc = null; … … 150 216 try 151 217 { 152 if ("CreateSpecimenTube".equals(cmd)) 153 { 154 218 if ("CreateSpecimenTubes".equals(cmd)) 219 { 220 dc = sc.newDbControl(); 221 222 JSONObject jsonReq = (JSONObject)new JSONParser().parse(req.getReader()); 223 JSONObject jsonCase = (JSONObject)jsonReq.get("caseInfo"); 224 Number caseId = (Number)jsonCase.get("id"); 225 Sample theCase = null; 226 227 if (caseId != null) 228 { 229 theCase = Sample.getById(dc, caseId.intValue()); 230 } 231 else 232 { 233 theCase = Sample.getNew(dc); 234 theCase.setName((String)jsonCase.get("name")); 235 236 dc.saveItem(theCase); 237 } 238 239 String laterality = Values.getStringOrNull((String)jsonCase.get("laterality")); 240 String padCase = Values.getStringOrNull((String)jsonCase.get("pad")); 241 String pathNote = Values.getStringOrNull((String)jsonCase.get("pathNote")); 242 StringToDateConverter dateTimeConverter = new StringToDateConverter(new SimpleDateFormat("yyyyMMdd HHmm")); 243 StringToDateConverter dateConverter = new StringToDateConverter(new SimpleDateFormat("yyyyMMdd")); 244 Date samplingDate = dateTimeConverter.convert((String)jsonCase.get("samplingDate")); 245 Date rnaLaterDate = dateTimeConverter.convert((String)jsonCase.get("rnaLaterDate")); 246 Date arrivalDate = dateConverter.convert((String)jsonCase.get("arrivalDate")); 247 248 AnnotationType padCaseType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PAD_CASE, true); 249 AnnotationType lateralityType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_LATERALITY, true); 250 // AnnotationType pathNoteType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PATH_NOTE, true); 251 AnnotationType samplingDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_SAMPLING_DATETIME, true); 252 AnnotationType rnaLaterDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_RNALATER_DATETIME, true); 253 AnnotationType arrivalDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_ARRIVAL_DATE, true); 254 255 Reggie.setAnnotationValue(theCase, lateralityType, laterality); 256 Reggie.setAnnotationValue(theCase, arrivalDateType, arrivalDate); 257 // Reggie.setAnnotationValue(theCase, pathNoteType, pathNote); 258 259 if (padCase != null) Reggie.appendAnnotationValueIfUnique(theCase, padCaseType, padCase); 155 260 156 261 dc.commit();
Note: See TracChangeset
for help on using the changeset viewer.