Changeset 6092
- Timestamp:
- Aug 27, 2012, 11:16:54 AM (11 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/DerivedBioAssay.java
r6085 r6092 34 34 import java.util.Set; 35 35 36 import net.sf.basedb.core.Transactional.Action; 36 37 import net.sf.basedb.core.data.ArrayBatchData; 37 38 import net.sf.basedb.core.data.ArrayDesignData; 38 39 import net.sf.basedb.core.data.ArraySlideData; 39 40 import net.sf.basedb.core.data.DerivedBioAssayData; 41 import net.sf.basedb.core.data.ExtractData; 40 42 import net.sf.basedb.core.data.HardwareData; 41 43 import net.sf.basedb.core.data.PhysicalBioAssayData; … … 263 265 return used || super.isUsed(); 264 266 } 267 268 /** 269 Automatically try to assign an extract from parent items at 270 creation time. 271 */ 272 @Override 273 void onBeforeCommit(Action action) 274 { 275 super.onBeforeCommit(action); 276 277 if (action == Action.CREATE && !extractHasBeenSet && !isRoot()) 278 { 279 ExtractData extract = null; 280 for (DerivedBioAssayData parent : getData().getParents()) 281 { 282 ExtractData e = parent.getExtract(); 283 if (extract == null) 284 { 285 extract = e; 286 } 287 else if (e != null && !extract.equals(e)) 288 { 289 // Different extracts on different parents --> do not assign 290 extract = null; 291 break; 292 } 293 } 294 if (extract != null) getData().setExtract(extract); 295 } 296 297 } 265 298 266 299 /** … … 614 647 } 615 648 649 private boolean extractHasBeenSet; 650 616 651 /** 617 652 Set the extract that is the parent of data in this bioassay. The extract … … 624 659 checkPermission(Permission.WRITE); 625 660 if (extract != null) extract.checkPermission(Permission.USE); 661 extractHasBeenSet = true; 626 662 getData().setExtract(extract == null ? null : extract.getData()); 627 663 } -
trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/DerivedBioAssayImporter.java
r5986 r6092 30 30 import net.sf.basedb.core.Path; 31 31 import net.sf.basedb.core.PathParameterType; 32 import net.sf.basedb.core.PermissionDeniedException;33 32 import net.sf.basedb.core.PhysicalBioAssay; 34 33 import net.sf.basedb.core.Item; … … 73 72 "type is not specified, the importer will try to guess a parent type from the " + 74 73 "item subtype. Example: \\Parent type\\\n\n" + 75 "NOTE! The parent can't be changed for existing bioassays.",74 "NOTE! The parent type can't be changed for existing bioassays.", 76 75 optionalColumnMapping 77 76 ); … … 86 85 "Mapping that picks the name or id of the parent item (physical or derived bioassay) " + 87 86 "in the data columns. Example: \\Parent\\\n\n" + 88 "NOTE! The parent can't be changed for existing bioassays.",87 "NOTE! The importer can only add parents, not replace or remove existing parents.", 89 88 optionalColumnMapping 90 89 ); … … 312 311 parentType = parentSubtype.getMainItemType(); 313 312 } 314 315 DerivedBioAssay bioAssay = null; 316 317 String nameOrId = parentMapper.getValue(data); 318 if (parentType == Item.DERIVEDBIOASSAY) 319 { 320 DerivedBioAssay parent = findDerivedBioAssay(dc, FallbackIdMethod.NAME_OR_ID, nameOrId, parentSubtype); 321 bioAssay = DerivedBioAssay.getNew(dc, parent, job.getJob()); 322 } 323 else 324 { 325 PhysicalBioAssay pba = findPhysicalBioAssay(dc, FallbackIdMethod.NAME_OR_ID, nameOrId, parentSubtype); 326 bioAssay = DerivedBioAssay.getNew(dc, pba, job.getJob()); 327 } 328 313 boolean isRoot = parentType != Item.DERIVEDBIOASSAY; 314 DerivedBioAssay bioAssay = DerivedBioAssay.getNew(dc, isRoot, job.getJob()); 315 329 316 if (subtype != null) bioAssay.setItemSubtype(subtype); 330 317 updateItem(dc, bioAssay, data); … … 343 330 ItemSubtype type = ItemSubtype.getRelatedSubtype(dc, bioAssay, Item.EXTRACT, 0); 344 331 Extract extract = findExtract(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId, type); 345 if (extract == null && !bioAssay.isRoot())346 {347 // No explicit extract found, try the extract on the parent bioassay348 try349 {350 extract = bioAssay.getParent().getExtract();351 }352 catch (PermissionDeniedException ex)353 {}354 }355 332 if (nameOrId == null || extract != null) bioAssay.setExtract(extract); 356 333 } … … 410 387 } 411 388 } 412 } 389 390 if (parentMapper != null) 391 { 392 String nameOrId = parentMapper.getValue(data); 393 Item parentType = bioAssay.isRoot() ? Item.PHYSICALBIOASSAY : Item.DERIVEDBIOASSAY; 394 395 ItemSubtype parentSubtype = ItemSubtype.getRelatedSubtype(dc, bioAssay, parentType); 396 if (parentType == Item.DERIVEDBIOASSAY) 397 { 398 DerivedBioAssay parent = findDerivedBioAssay(dc, FallbackIdMethod.NAME_OR_ID, nameOrId, parentSubtype); 399 bioAssay.addParent(parent); 400 } 401 else 402 { 403 PhysicalBioAssay pba = findPhysicalBioAssay(dc, FallbackIdMethod.NAME_OR_ID, nameOrId, parentSubtype); 404 bioAssay.addPhysicalBioAssay(pba); 405 } 406 } 407 } 408 413 409 /** 414 410 Validate data files if they have been set. -
trunk/src/test/TestDerivedBioAssay.java
r6082 r6092 23 23 import net.sf.basedb.core.*; 24 24 25 import java.util.ArrayList; 25 26 import java.util.Date; 26 27 import java.util.Set; … … 390 391 if (!TestUtil.getSilent()) 391 392 { 392 write(" \tID \tName \tType\tDescription\tParent \tPhysical bioassay\tProtocol\tHardware\tSoftware");393 write("-- \t-- \t--------- \t----\t-----------\t------ \t----------------\t---------\t--------\t--------");393 write(" \tID \tName \tType\tDescription\tParents\tPhysical bioassays\tProtocol\tHardware\tSoftware"); 394 write("-- \t-- \t--------- \t----\t-----------\t-------\t------------------\t--------\t--------\t--------"); 394 395 } 395 396 } … … 399 400 if (!TestUtil.getSilent()) 400 401 { 402 DbControl dc = dbas.getDbControl(); 401 403 System.out.println(i+":\t"+dbas.getId()+"\t"+dbas.getName()+"\t"+dbas.getItemSubtype()+"\t"+dbas.getDescription()+ 402 "\t"+dbas.getParent()+"\t"+dbas.getPhysicalBioAssay()+ 404 "\t"+new ArrayList<DerivedBioAssay>(dbas.getParents().list(dc))+ 405 "\t"+new ArrayList<PhysicalBioAssay>(dbas.getPhysicalBioAssays().list(dc))+ 403 406 "\t"+dbas.getProtocol()+"\t"+dbas.getHardware()+"\t"+dbas.getSoftware()); 404 407 } -
trunk/src/test/data/test.batchimport.scans.txt
r5696 r6092 3 3 Scan 2 Scan The second Hyb 2 Labeled 2.1 Scanning Scanner 4 4 Scan 3 Scan Hyb all 5 Child bioassay 1 ChildScan A child to Scan 1 Scan 1 5 Child bioassay 1 ChildScan Merged scans Scan 1 6 Child bioassay 1 Scan 2 7 Child bioassay 1 Scan 3
Note: See TracChangeset
for help on using the changeset viewer.