Changeset 5456
- Timestamp:
- Oct 28, 2010, 2:12:26 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/common-queries.xml
r5454 r5456 3821 3821 </query> 3822 3822 3823 <query id="CLEAR_ORIGINAL_BIOMATERIAL_ON_BIOWELLS" type="HQL"> 3824 <sql> 3825 UPDATE BioWellData bw 3826 SET bw.originalBioMaterial = null 3827 WHERE bw.originalBioMaterial = :bioMaterial 3828 </sql> 3829 <description> 3830 An HQL update-query that for a given biomaterial clears the 3831 link on all biowells were it is set as the original biomaterial. 3832 </description> 3833 </query> 3834 3823 3835 </predefined-queries> -
trunk/src/core/net/sf/basedb/core/BioPlate.java
r5454 r5456 158 158 /** 159 159 Check if there are any <code>MeasuredBioMaterial</code> on 160 this plate or if this plate has any child plates (note that 161 child events may exists but they are automatically deleted) 160 this plate. 162 161 */ 163 162 @Override -
trunk/src/core/net/sf/basedb/core/BioPlateType.java
r5452 r5456 238 238 239 239 /** 240 A flag indicating if plates with this type have locked wells or not. 241 If the wells are locked it is not possible to change the biomaterial 242 in them. 243 @return TRUE if the wells should be locked, FALSE otherwise 244 */ 245 public boolean getLockedWells() 246 { 247 return getData().getLockedWells(); 248 } 249 /** 250 Set the flag to lock/unlock wells on the plates of this type. 251 */ 252 public void setLockedWells(boolean lockedWells) 253 { 254 checkPermission(Permission.WRITE); 255 getData().setLockedWells(lockedWells); 240 Get the lock mode for wells located on plates of this plate type. 241 The lock mode determines if biomaterial may be changed in the 242 well. 243 244 @return A lock mode 245 */ 246 public BioWell.LockMode getLockMode() 247 { 248 return BioWell.LockMode.fromValue(getData().getLockMode()); 249 } 250 /** 251 Set the lock mode for wells on plates of this plate type. 252 @param lockMode A lock mode, null is not allowed 253 */ 254 public void setLockMode(BioWell.LockMode lockMode) 255 { 256 checkPermission(Permission.WRITE); 257 if (lockMode == null) throw new InvalidUseOfNullException("lockMode"); 258 getData().setLockMode(lockMode.getValue()); 256 259 } 257 260 -
trunk/src/core/net/sf/basedb/core/BioWell.java
r5348 r5456 23 23 24 24 import net.sf.basedb.core.data.BioWellData; 25 import net.sf.basedb.core.data.MeasuredBioMaterialData; 25 26 import net.sf.basedb.core.data.SharedData; 26 27 import net.sf.basedb.core.query.Hql; … … 28 29 import net.sf.basedb.util.Coordinate; 29 30 31 import java.util.HashMap; 32 import java.util.Map; 30 33 import java.util.Set; 31 34 … … 208 211 209 212 /** 210 Is this well locked or not? A well is locked if there is biomaterial in it and 211 the plate type has locked wells. 213 If the original biomaterial in this well has been moved to 214 another plate (eg. for final storage in a freezer). This property 215 is only defined for well with lock mode={@link LockMode#LOCKED_AFTER_MOVE}. 216 @return TRUE if the original biomaterial has been moved 212 217 @since 2.16 213 @see BioPlateType#getLockedWells() 214 */ 215 public boolean isLocked() 216 { 217 return getData().getBioPlate().getBioPlateType().getLockedWells() && getData().getBioMaterial() != null; 218 } 218 */ 219 public boolean hasBeenMoved() 220 { 221 return getData().getBioMaterial() == null && getData().getOriginalBioMaterial() != null; 222 } 223 224 /** 225 Get the original biomaterial that was placed in this biowell. This 226 property is only defined for well with lock mode={@link LockMode#LOCKED_AFTER_MOVE} 227 after the biomaterial has been moved. 228 229 @return The original biomaterial 230 @since 2.16 231 */ 232 public MeasuredBioMaterial getOriginalBioMaterial() 233 { 234 return getDbControl().getItem(MeasuredBioMaterial.class, getData().getOriginalBioMaterial()); 235 } 236 237 /** 238 The lock mode for a well is determined by the plate's bio 239 plate type. See {@link BioPlateType#getLockMode()}. The lock-mode 240 is used to determine if the well can be assigned to a biomaterial 241 or not. 242 243 @since 2.16 244 */ 245 public enum LockMode 246 { 247 /** 248 The well is not locked. It is possible to change the biomaterial 249 any number of times. 250 */ 251 UNLOCKED(0) 252 { 253 /** 254 @return Always true 255 */ 256 @Override 257 boolean canClear(BioWellData well) 258 { 259 return true; 260 } 261 /** 262 @return Always true 263 */ 264 @Override 265 boolean canAdd(BioWellData well) 266 { 267 return true; 268 } 269 }, 270 271 /** 272 It is allowed to add biomaterial once to the well. It can not be replaced 273 by a new biomaterial but it is possible to clear it. The original biomaterial 274 is then saved in the {@link BioWell#getOriginalBioMaterial()}. 275 */ 276 LOCKED_AFTER_MOVE(1) 277 { 278 /** 279 @return Always true 280 */ 281 @Override 282 boolean canClear(BioWellData well) 283 { 284 return true; 285 } 286 /** 287 Can only add if there is no original biomaterial. 288 */ 289 @Override 290 boolean canAdd(BioWellData well) 291 { 292 return well.getOriginalBioMaterial() == null; 293 } 294 /** 295 This lockmode will save the original biomaterial in 296 {@link BioWell#getOriginalBioMaterial()} when it is cleared. 297 After that, it is not possible to add biomaterial to the well again. 298 */ 299 @Override 300 void onClear(BioWellData well, MeasuredBioMaterialData biomaterial) 301 { 302 well.setOriginalBioMaterial(biomaterial); 303 } 304 }, 305 306 /** 307 It is allowed to add biomaterial once to the well. It can't be replaced 308 by a new biomaterial and it is not possible to clear it. It is possible to 309 add biomaterial to empty wells at any time. 310 */ 311 LOCKED_AFTER_ADD(2) 312 { 313 /** 314 @return Always false 315 */ 316 @Override 317 boolean canClear(BioWellData well) 318 { 319 return false; 320 } 321 /** 322 @return Always true 323 */ 324 @Override 325 boolean canAdd(BioWellData well) 326 { 327 return true; 328 } 329 }, 330 331 /** 332 It is allowed to add biomaterial once to the well, but it most be done 333 at the same time the plate is creted. Once the transaction has been 334 committed to the database, all wells become locked. 335 */ 336 LOCKED_AFTER_CREATE(3) 337 { 338 /** 339 @return Always false 340 */ 341 @Override 342 boolean canClear(BioWellData well) 343 { 344 return false; 345 } 346 /** 347 Can only add to unsaved items. 348 */ 349 @Override 350 boolean canAdd(BioWellData well) 351 { 352 return well.getId() == 0; 353 } 354 }; 355 356 /** 357 Maps an integer to a lock mode. 358 */ 359 private static final Map<Integer, LockMode> valueMapping = new HashMap<Integer, LockMode>(); 360 361 static 362 { 363 for (LockMode lockMode : LockMode.values()) 364 { 365 LockMode lm = valueMapping.put(lockMode.getValue(), lockMode); 366 assert lm == null : "Another lock mode with the value "+lockMode.getValue()+" already exists"; 367 } 368 } 369 370 /** 371 The integer value of this lock mode. 372 */ 373 private final int value; 374 375 private LockMode(int value) 376 { 377 this.value = value; 378 } 379 380 /** 381 Get the integer value that is used when storing a lock mode to the database. 382 @return The integer value for this lock mode 383 */ 384 public int getValue() 385 { 386 return value; 387 } 388 389 /** 390 Get the <code>Lock mode</code> object when you know the integer code. 391 392 @param value The integer value 393 @return The location for the integer value 394 */ 395 public static LockMode fromValue(int value) 396 { 397 LockMode lockMode = valueMapping.get(value); 398 assert lockMode != null : "lockMode == null for value "+value; 399 return lockMode; 400 } 401 402 /** 403 Is it allowed to clear a well that already has biomaterial in it? If 404 this method is called with an empty well as parameter the result 405 is undefined. 406 @param well The biowell, which should already have biomaterial in it 407 */ 408 public boolean canClear(BioWell well) 409 { 410 return canClear(well.getData()); 411 } 412 413 abstract boolean canClear(BioWellData well); 414 415 /** 416 Called when a well is cleared from an existing biomaterial. The 417 default implementation of this method does nothing, but it may be 418 overriden by some lock modes. 419 420 @param well The well that is cleared 421 @param biomaterial The biomaterial that is currently located on the well 422 */ 423 void onClear(BioWellData well, MeasuredBioMaterialData biomaterial) 424 {} 425 426 /** 427 Is it allowed to add biomaterial to the (empty) well? If this 428 method is called with a non-empty well as parameter the result 429 is undefined. 430 @param well An empty biowell 431 */ 432 public boolean canAdd(BioWell well) 433 { 434 return canAdd(well.getData()); 435 } 436 437 abstract boolean canAdd(BioWellData well); 438 439 /** 440 Called when biomaterial is added to a well. The 441 default implementation of this method does nothing, but it may be 442 overriden by some lock modes. 443 444 @param well The well the biomaterial is added to 445 @param biomaterial The biomaterial that is going to be added to the well 446 */ 447 void onAdd(BioWellData well, MeasuredBioMaterialData biomaterial) 448 {} 449 450 } 451 219 452 } -
trunk/src/core/net/sf/basedb/core/Install.java
r5454 r5456 583 583 progressStep++; 584 584 if (progress != null) progress.display((int)(progressStep*progress_factor), "--Creating bioplate types..."); 585 BioPlateTypeData storagePlate = createBioPlateType("Storage plate", "A generic storage plate for all types of biomaterial.", null, false); 586 BioPlateTypeData sampleReactionPlate = createBioPlateType("Sample reaction plate", "A generic reaction plate for samples.", Item.SAMPLE, true); 587 BioPlateTypeData extractReactionPlate = createBioPlateType("Extract reaction plate", "A generic reaction plate for extracts.", Item.EXTRACT, true); 585 BioPlateTypeData storagePlate = createBioPlateType("Storage plate", "A generic storage plate for all types of biomaterial.", 586 null, BioWell.LockMode.UNLOCKED); 587 BioPlateTypeData sampleReactionPlate = createBioPlateType("Sample reaction plate", "A generic reaction plate for samples.", 588 Item.SAMPLE, BioWell.LockMode.LOCKED_AFTER_ADD); 589 BioPlateTypeData extractReactionPlate = createBioPlateType("Extract reaction plate", "A generic reaction plate for extracts.", 590 Item.EXTRACT, BioWell.LockMode.LOCKED_AFTER_ADD); 588 591 BioPlateTypeData labeledExtractReactionPlate = 589 createBioPlateType("Labeled extract reaction plate", "A generic reaction plate for labeled extracts.", Item.LABELEDEXTRACT, true); 592 createBioPlateType("Labeled extract reaction plate", "A generic reaction plate for labeled extracts.", 593 Item.LABELEDEXTRACT, BioWell.LockMode.LOCKED_AFTER_ADD); 590 594 591 595 // Labels … … 1788 1792 */ 1789 1793 private static BioPlateTypeData createBioPlateType(String name, String description, 1790 Item biomaterialType, boolean lockedWells)1794 Item biomaterialType, BioWell.LockMode lockedMode) 1791 1795 throws BaseException 1792 1796 { … … 1815 1819 pt.setDescription(description); 1816 1820 pt.setBioMaterialType(biomaterialType == null ? null : biomaterialType.getValue()); 1817 pt.setLock edWells(lockedWells);1821 pt.setLockMode(lockedMode.getValue()); 1818 1822 HibernateUtil.saveData(session, pt); 1819 1823 HibernateUtil.commit(tx); -
trunk/src/core/net/sf/basedb/core/MeasuredBioMaterial.java
r5452 r5456 132 132 { 133 133 getCreationEvent().clearSources(); 134 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(getDbControl().getHibernateSession(), 135 "CLEAR_ORIGINAL_BIOMATERIAL_ON_BIOWELLS"); 136 /* 137 UPDATE BioWellData bw 138 SET bw.originalBioMaterial = null 139 WHERE bw.originalBioMaterial = :bioMaterial 140 */ 141 query.setEntity("bioMaterial", getData()); 142 query.executeUpdate(); 134 143 } 135 144 } … … 344 353 345 354 /** 346 Sets the <code>BioWell</code> where this biomaterial is located. This 347 method also updates the plate event associated with the creation event 348 of this biomaterial, if the new well is located on a plate which was 349 created by an event. 355 Sets the <code>BioWell</code> where this biomaterial is located. 350 356 351 357 @param well The <code>BioWell</code> to set. … … 362 368 { 363 369 checkPermission(Permission.WRITE); 364 BioWellData currentWell = getData().getBioWell(); 370 MeasuredBioMaterialData myData = getData(); 371 BioWellData currentWell = myData.getBioWell(); 365 372 BioWellData newWell = well != null ? well.getData() : null; 366 373 if (EqualsHelper.equals(currentWell, newWell)) return; // early exit if no change 367 374 368 375 // Check if current biowell is locked 369 if (currentWell != null )376 if (currentWell != null && currentWell.getId() != 0) 370 377 { 371 378 BioPlateData currentPlate = currentWell.getBioPlate(); 372 if (currentPlate.getBioPlateType().getLockedWells()) 379 BioWell.LockMode lockMode = BioWell.LockMode.fromValue(currentPlate.getBioPlateType().getLockMode()); 380 381 if (!lockMode.canClear(currentWell)) 373 382 { 374 383 throw new PermissionDeniedException(Permission.WRITE, this + 375 ". Wells on plate '" + currentPlate.getName() + "'' are locked."); 376 } 384 ". Well on plate '" + currentPlate.getName() + "'' is locked: " + currentWell); 385 } 386 lockMode.onClear(currentWell, myData); 377 387 } 378 388 … … 397 407 Item.fromValue(biomaterialType)); 398 408 } 409 // Check that the lock mode allows adding biomaterial to the well 410 BioWell.LockMode lockMode = BioWell.LockMode.fromValue(newPlateType.getLockMode()); 411 if (!lockMode.canAdd(newWell)) 412 { 413 throw new PermissionDeniedException(Permission.WRITE, this + 414 ". Well on plate '" + newPlate.getName() + "'' is locked: " + well); 415 } 416 lockMode.onAdd(newWell, myData); 399 417 } 400 418 if (currentWell != null) currentWell.setBioMaterial(null); 401 if (newWell != null) newWell.setBioMaterial( getData());402 getData().setBioWell(newWell);419 if (newWell != null) newWell.setBioMaterial(myData); 420 myData.setBioWell(newWell); 403 421 } 404 422 -
trunk/src/core/net/sf/basedb/core/Update.java
r5454 r5456 41 41 import net.sf.basedb.core.data.BioPlateData; 42 42 import net.sf.basedb.core.data.BioPlateTypeData; 43 import net.sf.basedb.core.data.BioWellData; 43 44 import net.sf.basedb.core.data.ChangeHistoryData; 44 45 import net.sf.basedb.core.data.ChangeHistoryDetailData; … … 882 883 <td>80</td> 883 884 <td> 884 Added {@link BioPlateTypeData} .885 Added {@link BioPlateTypeData}, {@link BioWellData#getOriginalBioMaterial()}. 885 886 All existing bio plates are assigned "Storage plate" as their 886 887 plate type. -
trunk/src/core/net/sf/basedb/core/data/BioPlateTypeData.java
r5389 r5456 101 101 } 102 102 103 private boolean lockedWells;103 private int lockMode; 104 104 /** 105 If bioplates that uses this type must have locked wells or not. 106 @hibernate.property column="`locked_wells`" type="boolean" not-null="true" 105 A flag indicating if plates with this type have locked wells or not. 106 0 = not locked; 1 = locked-after-move; 2 = locked-after-add; 3=locked-after-create 107 @hibernate.property column="`lock_mode`" type="int" not-null="true" 107 108 */ 108 public boolean getLockedWells()109 public int getLockMode() 109 110 { 110 return lock edWells;111 return lockMode; 111 112 } 112 public void setLock edWells(boolean lockedWells)113 public void setLockMode(int lockMode) 113 114 { 114 this.lock edWells = lockedWells;115 this.lockMode = lockMode; 115 116 } 116 117 -
trunk/src/core/net/sf/basedb/core/data/BioWellData.java
r5119 r5456 80 80 } 81 81 82 private MeasuredBioMaterialData originalBioMaterial; 83 /** 84 The {@link MeasuredBioMaterialData} used in this well. 85 @since 2.16 86 @hibernate.many-to-one column="`original_biomaterial_id`" not-null="false" outer-join="false" 87 */ 88 public MeasuredBioMaterialData getOriginalBioMaterial() 89 { 90 return originalBioMaterial; 91 } 92 public void setOriginalBioMaterial(MeasuredBioMaterialData originalBioMaterial) 93 { 94 this.originalBioMaterial = originalBioMaterial; 95 } 96 82 97 private MeasuredBioMaterialData bioMaterial; 83 98 /** -
trunk/src/test/TestBioPlate.java
r5452 r5456 71 71 write_header(); 72 72 73 int sampleId = TestSample.test_create(0, "Sample A", true); 73 int sampleId = TestSample.test_create(0, "Sample A.1", true); 74 int sample2Id = TestSample.test_create(0, "Sample A.2", true); 75 int sample3Id = TestSample.test_create(0, "Sample A.3", true); 74 76 int extractId = TestExtract.test_create(sampleId, true); 75 77 int labelId = TestLabel.test_create(true); … … 83 85 // Standard tests: create, load, list 84 86 int plateGeometryId = TestPlateGeometry.test_create(8, 12, false); 85 int bioPlateTypeId = TestBioPlateType.test_create("Test for bioplate", null, false); 87 int bioPlateTypeId = TestBioPlateType.test_create("Test for bioplate", null, BioWell.LockMode.UNLOCKED); 88 int addOnlyTypeId = TestBioPlateType.test_create("Add-only plate type", null, BioWell.LockMode.LOCKED_AFTER_ADD); 89 int moveTypeId = TestBioPlateType.test_create("Move plate type", null, BioWell.LockMode.LOCKED_AFTER_MOVE); 86 90 int id = test_create("Test BioPlate", plateGeometryId, bioPlateTypeId, freezerId, true); 91 int id2 = test_create("Add-only plate", plateGeometryId, addOnlyTypeId, 0, false); 92 int id3 = test_create("Move plate", plateGeometryId, moveTypeId, 0, false); 87 93 test_load(id); 88 94 test_list(-1); 89 95 90 // Wells 91 test_set_well(id, 0, 0, Item.SAMPLE, sampleId); 92 test_set_well(id, 0, 1, Item.EXTRACT, extractId); 96 // Wells -- unlocked plate 97 boolean FAIL = true; 98 test_set_well(id, 0, 0, Item.SAMPLE, sampleId, !FAIL); 99 test_set_well(id, 0, 1, Item.EXTRACT, extractId, !FAIL); 93 100 test_list_wells(id, 2); 101 test_clear_well(id, 0, 0, !FAIL); 102 test_clear_well(id, 0, 1, !FAIL); 103 test_list_wells(id, 0); 104 105 // Wells -- add-only plate 106 test_set_well(id2, 0, 0, Item.SAMPLE, sample2Id, !FAIL); 107 test_clear_well(id2, 0, 0, FAIL); 108 test_set_well(id2, 0, 0, Item.SAMPLE, sample3Id, FAIL); 109 110 // Wells -- locked-after-move plate 111 test_set_well(id3, 0, 0, Item.SAMPLE, sample3Id, !FAIL); 112 test_clear_well(id3, 0, 0, !FAIL); 113 test_list_wells(id3, 0); 114 test_list_original_biomaterial(id3, 1); 115 test_set_well(id3, 0, 0, Item.SAMPLE, sample3Id, FAIL); 94 116 95 117 if (TestUtil.waitBeforeDelete()) TestUtil.waitForEnter(); … … 99 121 TestExtract.test_delete(extractId); 100 122 TestSample.test_delete(sampleId); 123 TestSample.test_delete(sample2Id); 124 TestSample.test_delete(sample3Id); 101 125 test_delete(id); 126 test_delete(id2); 127 test_delete(id3); 128 102 129 TestPlateGeometry.test_delete(plateGeometryId); 103 130 TestBioPlateType.test_delete(bioPlateTypeId); 131 TestBioPlateType.test_delete(addOnlyTypeId); 132 TestBioPlateType.test_delete(moveTypeId); 104 133 TestHardware.test_delete(freezerId); 105 134 TestProtocol.test_delete(protocolId); … … 283 312 { 284 313 if (!TestUtil.getSilent()) System.out.println(i+":\t"+well.getId()+"\t["+well.getRow()+ 285 ","+well.getColumn()+"]\t"+well.getBioMaterial() );286 } 287 288 289 static int test_set_well(int bioPlateId, int row, int column, Item bioMaterialType, int bioMaterialId )314 ","+well.getColumn()+"]\t"+well.getBioMaterial()+"\t"+well.getOriginalBioMaterial()); 315 } 316 317 318 static int test_set_well(int bioPlateId, int row, int column, Item bioMaterialType, int bioMaterialId, boolean shouldFail) 290 319 { 291 320 if (bioPlateId == 0 || bioMaterialId == 0) … … 297 326 try 298 327 { 299 dc = TestUtil.getDbControl(); 300 BioPlate plate = BioPlate.getById(dc, bioPlateId); 301 MeasuredBioMaterial bm = (MeasuredBioMaterial)bioMaterialType.getById(dc, bioMaterialId); 302 BioWell well = plate.getBioWell(row, column); 303 bm.setBioWell(well); 304 dc.commit(); 305 wellId = well.getId(); 306 write("--Set well " + plate + "[" + row + "," + column + "] OK"); 328 Throwable t = null; 329 BioPlate plate = null; 330 try 331 { 332 dc = TestUtil.getDbControl(); 333 plate = BioPlate.getById(dc, bioPlateId); 334 MeasuredBioMaterial bm = (MeasuredBioMaterial)bioMaterialType.getById(dc, bioMaterialId); 335 BioWell well = plate.getBioWell(row, column); 336 bm.setBioWell(well); 337 dc.commit(); 338 wellId = well.getId(); 339 } 340 catch (Throwable t1) 341 { 342 t = t1; 343 } 344 if (shouldFail) 345 { 346 if (t == null) throw new RuntimeException("Well shuld be locked"); 347 write("--Set well " + plate + "[" + row + "," + column + "] OK (well was locked)"); 348 } 349 else 350 { 351 if (t != null) throw t; 352 write("--Set well " + plate + "[" + row + "," + column + "] OK"); 353 } 307 354 } 308 355 catch (Throwable ex) … … 318 365 return wellId; 319 366 } 367 368 369 static void test_clear_well(int bioPlateId, int row, int column, boolean shouldFail) 370 { 371 if (bioPlateId == 0) return; 372 int wellId = 0; 373 DbControl dc = null; 374 try 375 { 376 Throwable t = null; 377 BioPlate plate = null; 378 try 379 { 380 dc = TestUtil.getDbControl(); 381 plate = BioPlate.getById(dc, bioPlateId); 382 BioWell well = plate.getBioWell(row, column); 383 well.getBioMaterial().setBioWell(null); 384 dc.commit(); 385 } 386 catch (Throwable t1) 387 { 388 t = t1; 389 } 390 if (shouldFail) 391 { 392 if (t == null) throw new RuntimeException("Well shuld be locked"); 393 write("--Clear well " + plate + "[" + row + "," + column + "] OK (well was locked)"); 394 } 395 else 396 { 397 if (t != null) throw t; 398 write("--Clear well " + plate + "[" + row + "," + column + "] OK"); 399 } 400 } 401 catch (Throwable ex) 402 { 403 write("--Clear well BioPlate[id=" + bioPlateId + "][" + row + "," + column + "] FAILED"); 404 ex.printStackTrace(); 405 ok = false; 406 } 407 finally 408 { 409 if (dc != null) dc.close(); 410 } 411 } 412 320 413 321 414 static void test_list_wells(int bioPlateId, int expectedResults) … … 356 449 } 357 450 } 358 451 452 static void test_list_original_biomaterial(int bioPlateId, int expectedResults) 453 { 454 if (bioPlateId == 0) return; 455 DbControl dc = null; 456 try 457 { 458 dc = TestUtil.getDbControl(); 459 BioPlate plate = BioPlate.getById(dc, bioPlateId); 460 ItemResultList<BioWell> wells = plate.getBioWells().list(dc); 461 int numWells = 0; 462 for (int i = 0; i<wells.size(); i++) 463 { 464 BioWell well = wells.get(i); 465 if (well.getOriginalBioMaterial() != null) 466 { 467 write_item(i, well); 468 numWells++; 469 } 470 } 471 if (expectedResults >=0 && expectedResults != numWells) 472 { 473 throw new BaseException("Expected " + expectedResults + " results, " + 474 "not " + numWells); 475 } 476 write ("--List wells with original biomaterial OK (" + numWells +")"); 477 } 478 catch (Throwable ex) 479 { 480 write("--List wells with original biomaterial FAILED"); 481 ex.printStackTrace(); 482 ok = false; 483 } 484 finally 485 { 486 if (dc != null) dc.close(); 487 } 488 } 489 359 490 360 491 static List<Integer> test_fill(int bioPlateId, Item itemType, String rootName, int labelId) -
trunk/src/test/TestBioPlateType.java
r5340 r5456 4 4 import net.sf.basedb.core.BaseException; 5 5 import net.sf.basedb.core.BioPlateType; 6 import net.sf.basedb.core.BioWell; 6 7 import net.sf.basedb.core.DbControl; 7 8 import net.sf.basedb.core.Item; … … 49 50 write_header(); 50 51 // Standard tests: create, load, list 51 int id = test_create("Free for all", null, false); 52 int id2 = test_create("Locked samples", Item.SAMPLE, true); 52 int id = test_create("Free for all", null, BioWell.LockMode.UNLOCKED); 53 int id2 = test_create("Locked samples", Item.SAMPLE, BioWell.LockMode.LOCKED_AFTER_ADD); 54 int id3 = test_create("Moveable samples", Item.SAMPLE, BioWell.LockMode.LOCKED_AFTER_MOVE); 53 55 test_load(id); 54 56 test_list(-1); … … 58 60 test_delete(id); 59 61 test_delete(id2); 62 test_delete(id3); 60 63 write("++Testing bioplate types "+(ok ? "OK" : "Failed")+"\n"); 61 64 return ok; 62 65 } 63 66 64 static int test_create(String name, Item bioMaterialType, boolean lockedWells)67 static int test_create(String name, Item bioMaterialType, BioWell.LockMode lockMode) 65 68 { 66 69 if (!TestUtil.hasPermission(Permission.CREATE, Item.BIOPLATETYPE)) return 0; … … 74 77 pt.setDescription("Added at "+new Date()); 75 78 pt.setBioMaterialType(bioMaterialType); 76 pt.setLock edWells(lockedWells);79 pt.setLockMode(lockMode); 77 80 dc.saveItem(pt); 78 81 dc.commit(); … … 181 184 if (!TestUtil.getSilent()) 182 185 { 183 System.out.println(" \tID \tName \tDescription\tBiomaterial type\tLock ed wells");186 System.out.println(" \tID \tName \tDescription\tBiomaterial type\tLock mode"); 184 187 System.out.println("-- \t-- \t--------- \t-----------\t----------------\t------------"); 185 188 } … … 189 192 { 190 193 if (!TestUtil.getSilent()) System.out.println(i+":\t"+pt.getId()+"\t"+pt.getName()+"\t"+pt.getDescription()+ 191 "\t"+pt.getBioMaterialType()+"\t"+pt.getLock edWells());194 "\t"+pt.getBioMaterialType()+"\t"+pt.getLockMode()); 192 195 } 193 196 static void write(String message) -
trunk/src/test/net/sf/basedb/test/roles/PowerUserTest.java
r5260 r5456 32 32 import net.sf.basedb.core.ArraySlide; 33 33 import net.sf.basedb.core.BioPlateType; 34 import net.sf.basedb.core.BioWell; 34 35 import net.sf.basedb.core.DataFileType; 35 36 import net.sf.basedb.core.DbControl; … … 78 79 <li>Create annotation types: {@link #createAnnotationType(DbControl, String, Type, Unit, Object[], Item[])} 79 80 <li>Create plate type: {@link #createPlateType(DbControl, String, int, int)} 80 <li>Create bioplate type: {@link #createBioPlateType(DbControl, String, Item, boolean)}81 <li>Create bioplate type: {@link #createBioPlateType(DbControl, String, Item, BioWell.LockMode)} 81 82 <li>Create file formats for import: 82 83 <li>Import plates: … … 154 155 155 156 PlateType plateType = createPlateType(dc, "Plate type A", 16, 24); 156 BioPlateType bioPlateType = createBioPlateType(dc, "Bioplate type A", null, false);157 BioPlateType bioPlateType = createBioPlateType(dc, "Bioplate type A", null, BioWell.LockMode.UNLOCKED); 157 158 158 159 PluginConfiguration platesImporter = PluginUtil.createPluginConfiguration(dc, "Plates for project A", … … 395 396 Create a bioplate type. 396 397 */ 397 public static BioPlateType createBioPlateType(DbControl dc, String name, Item bioMaterialType, boolean lockedWells)398 public static BioPlateType createBioPlateType(DbControl dc, String name, Item bioMaterialType, BioWell.LockMode lockMode) 398 399 { 399 400 TestUtil.write("--Creating bioplate type: " + name + "\n"); … … 402 403 pt.setName(name); 403 404 pt.setBioMaterialType(bioMaterialType); 404 pt.setLock edWells(lockedWells);405 pt.setLockMode(lockMode); 405 406 dc.saveItem(pt); 406 407 return pt; -
trunk/www/biomaterials/bioplates/view_bioplate.jsp
r5454 r5456 152 152 location.href = 'wells/index.jsp?ID=<%=ID%>&bioplate_id=<%=itemId%>'; 153 153 } 154 function viewEvents()155 {156 location.href = 'events/index.jsp?ID=<%=ID%>&cmd=List&bioplate_id=<%=itemId%>';157 }158 154 function switchTab(tabControlId, tabId) 159 155 { … … 161 157 { 162 158 location.href = 'index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=itemId%>&tab='+tabId; 163 }164 else if (tabId == 'events')165 {166 viewEvents();167 159 } 168 160 else if (tabId == 'wells') … … 407 399 BioWell well = bioplate.getBioWell(r, c); 408 400 boolean isEmpty = well.isEmpty(); 409 boolean editable = well.hasPermission(Permission.USE) && !well.isLocked();401 boolean editable = well.hasPermission(Permission.USE); // && !well.isLocked(); 410 402 MeasuredBioMaterial bm = null; 411 403 String cls = "well"; … … 606 598 </t:tab> 607 599 <t:tab id="wells" title="Wells" /> 608 <t:tab id="events" title="Events" />609 600 <t:tab id="history" title="Change history" 610 601 tooltip="Displays a log of all modifications made to this item" -
trunk/www/biomaterials/bioplates/wells/list_biowells.jsp
r5426 r5456 99 99 final boolean createPermission = bioplate.hasPermission(Permission.WRITE); 100 100 final boolean deletePermission = createPermission; 101 final boolean lockedWells = bioPlateType.getLockedWells();101 final boolean lockedWells = false; //bioPlateType.getLockedWells(); 102 102 103 103 Enumeration<String, String> rows = new Enumeration<String,String>(); … … 164 164 { 165 165 location.href = '../index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=bioPlateId%>&tab='+tabId; 166 }167 else if (tabId == 'events')168 {169 location.href = '../events/index.jsp?ID=<%=ID%>&bioplate_id=<%=bioPlateId%>';170 166 } 171 167 else … … 505 501 506 502 </t:tab> 507 <t:tab id="events" title="Events" />508 503 <t:tab id="history" title="Change history" 509 504 tooltip="Displays a log of all modifications made to this item" -
trunk/www/biomaterials/bioplatetypes/edit_platetype.jsp
r5426 r5456 74 74 bioPlateType = BioPlateType.getById(dc, itemId); 75 75 bioPlateType.checkPermission(Permission.WRITE); 76 isLocked = bioPlateType.getLockedWells();76 //isLocked = bioPlateType.getLockedWells(); 77 77 cc.setObject("item", bioPlateType); 78 78 title = "Edit bio plate type -- " + HTML.encodeTags(bioPlateType.getName()); -
trunk/www/biomaterials/bioplatetypes/index.jsp
r5426 r5456 148 148 plateType.setName(Values.getStringOrNull(request.getParameter("name"))); 149 149 plateType.setDescription(Values.getStringOrNull(request.getParameter("description"))); 150 plateType.setLockedWells(Values.getBoolean(request.getParameter("lockedWells")));150 // plateType.setLockedWells(Values.getBoolean(request.getParameter("lockedWells"))); 151 151 dc.commit(); 152 152 cc.removeObject("item"); -
trunk/www/biomaterials/bioplatetypes/list_platetypes.jsp
r5426 r5456 400 400 <tbl:cell column="id"><%=item.getId()%></tbl:cell> 401 401 <tbl:cell column="bioMaterialType"><%=item.getBioMaterialType() == null ? "<i>- any -</i>" : item.getBioMaterialType().toString() %></tbl:cell> 402 <tbl:cell column="lockedWells"><% =item.getLockedWells() ? "yes" : "no" %></tbl:cell>402 <tbl:cell column="lockedWells"><% //item.getLockedWells() ? "yes" : "no" %></tbl:cell> 403 403 <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell> 404 404 </tbl:row> -
trunk/www/biomaterials/bioplatetypes/view_platetype.jsp
r5426 r5456 220 220 <tr> 221 221 <td class="prompt">Locked wells</td> 222 <td><% =plateType.getLockedWells() ? "yes" : "no"%></td>222 <td><% //plateType.getLockedWells() ? "yes" : "no"%></td> 223 223 </tr> 224 224 <tr> -
trunk/www/biomaterials/extracts/edit_extract.jsp
r5451 r5456 176 176 { 177 177 currentBioPlate = currentBioWell.getPlate(); 178 lockedWell = currentBioWell.isLocked();178 lockedWell = false; //currentBioWell.isLocked(); 179 179 } 180 180 } -
trunk/www/biomaterials/extracts/view_extract.jsp
r5426 r5456 354 354 %> 355 355 [<%=rowFormatter.format(bw.getRow())%>,<%=columnFormatter.format(bw.getColumn())%>] 356 <base:icon image="locked.gif" visible="<% =bw.isLocked() %>"/>356 <base:icon image="locked.gif" visible="<% //bw.isLocked() %>"/> 357 357 <% 358 358 } -
trunk/www/biomaterials/labeledextracts/edit_labeledextract.jsp
r5451 r5456 200 200 { 201 201 currentBioPlate = currentBioWell.getPlate(); 202 lockedWell = currentBioWell.isLocked();202 lockedWell = false; //currentBioWell.isLocked(); 203 203 } 204 204 } -
trunk/www/biomaterials/labeledextracts/view_labeledextract.jsp
r5426 r5456 357 357 %> 358 358 [<%=rowFormatter.format(bw.getRow())%>,<%=columnFormatter.format(bw.getColumn())%>] 359 <base:icon image="locked.gif" visible="<% =bw.isLocked() %>"/>359 <base:icon image="locked.gif" visible="<% // bw.isLocked() %>"/> 360 360 <% 361 361 } -
trunk/www/biomaterials/samples/edit_sample.jsp
r5451 r5456 177 177 { 178 178 currentBioPlate = currentBioWell.getPlate(); 179 lockedWell = currentBioWell.isLocked();179 lockedWell = false; //currentBioWell.isLocked(); 180 180 } 181 181 } -
trunk/www/biomaterials/samples/view_sample.jsp
r5426 r5456 339 339 %> 340 340 [<%=rowFormatter.format(bw.getRow())%>,<%=columnFormatter.format(bw.getColumn())%>] 341 <base:icon image="locked.gif" visible="<% =bw.isLocked() %>"/>341 <base:icon image="locked.gif" visible="<% //bw.isLocked() %>"/> 342 342 <% 343 343 }
Note: See TracChangeset
for help on using the changeset viewer.