Changeset 5177
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/AbstractItemImporter.java
r4922 r5177 71 71 import net.sf.basedb.core.ProtocolType; 72 72 import net.sf.basedb.core.RawDataType; 73 import net.sf.basedb.core.RawDataTypes; 73 74 import net.sf.basedb.core.RequestInformation; 74 75 import net.sf.basedb.core.Sample; … … 1566 1567 1567 1568 /** 1569 Find a matching raw data type. This method will look in the following order: 1570 <ol> 1571 <li>The raw data type locked to the platform variant: 1572 {@link PlatformVariant#getRawDataType()} 1573 <li>The raw data type locked to the platform: 1574 {@link Platform#getRawDataType()} 1575 <li>Any registered raw data type with the given 'id': 1576 {@link RawDataTypes#getRawDataType(String)} 1577 <li>Any registered raw data type with the given 'name': 1578 {@link RawDataTypes#getRawDataTypes()} 1579 <li>The project default raw data type: 1580 {@link #getProjectDefaultRawDataType(DbControl)} 1581 </ol> 1582 If a raw data type is found by a check, the remaining checks are 1583 ignored. If no item is found or if multiple items are found (in the 'name' lookup) 1584 the settings ({@link #failIfMultipleFoundReferences} 1585 and {@link #failIfNotFoundReference}) determine if an exception is thrown 1586 or not. 1587 @param platform The current platform or null to not use a platform for lookup 1588 @param variant The current platform variant or null to not use a variant for lookup 1589 @param identifier The 'id' or 'name' of a raw data type, or null to not use this 1590 for lookup 1591 @return A raw data type or null if not found 1592 @since 2.15 1593 */ 1594 protected RawDataType findRawDataType(DbControl dc, Platform platform, PlatformVariant variant, String identifier) 1595 { 1596 RawDataType rdt = null; 1597 1598 // If a variant/platform is given, check them first 1599 if (variant != null) rdt = variant.getRawDataType(); 1600 if (rdt == null && platform != null) rdt = platform.getRawDataType(); 1601 1602 // Find by 'id' 1603 if (rdt == null && identifier != null) rdt = RawDataTypes.getRawDataType(identifier); 1604 1605 // Find by 'name' 1606 if (rdt == null && identifier != null) 1607 { 1608 for (RawDataType tmp : RawDataTypes.getRawDataTypes()) 1609 { 1610 if (identifier.equals(tmp.getName())) 1611 { 1612 if (rdt == null) 1613 { 1614 rdt = tmp; 1615 if (!failIfMultipleFoundReferences) 1616 { 1617 // It is safe to ignore the rest 1618 break; 1619 } 1620 } 1621 else 1622 { 1623 // This is the second raw data type with the same name that we find 1624 throw new BaseException("Fount >1 raw data type [name=" + identifier + "]"); 1625 } 1626 } 1627 } 1628 } 1629 1630 // Check the project default raw data type 1631 if (rdt == null) rdt = getProjectDefaultRawDataType(dc); 1632 if (rdt == null && failIfNotFoundReference) 1633 { 1634 throw new ItemNotFoundException("RawDataType[id or name=" + identifier + "]"); 1635 } 1636 return rdt; 1637 } 1638 1639 /** 1568 1640 Cache that holds loaded/created items. The cache key is item type + identifier, 1569 1641 eq. SAMPLE:My sample, EXTRACT:An extract. The same item may be cached under more -
trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/RawBioAssayImporter.java
r4836 r5177 42 42 import net.sf.basedb.core.RawBioAssay; 43 43 import net.sf.basedb.core.RawDataType; 44 import net.sf.basedb.core.RawDataTypes;45 44 import net.sf.basedb.core.Scan; 46 45 import net.sf.basedb.core.Software; … … 312 311 Platform platform = null; 313 312 PlatformVariant variant = null; 314 RawDataType rawDataType= null;313 String rawDataTypeId = null; 315 314 316 315 if (platformMapper != null) … … 330 329 variant = getProjectDefaultVariant(dc); 331 330 } 332 if (variant != null && rawDataType == null) rawDataType = variant.getRawDataType(); 333 if (platform != null && rawDataType == null) rawDataType = platform.getRawDataType(); 334 if (rawDataType == null) 335 { 336 if (rawDataTypeMapper != null) 337 { 338 rawDataType = RawDataTypes.getSafeRawDataType(rawDataTypeMapper.getValue(data)); 339 } 340 else 341 { 342 rawDataType = getProjectDefaultRawDataType(dc); 343 } 344 } 331 if (rawDataTypeMapper != null) rawDataTypeId = rawDataTypeMapper.getValue(data); 332 RawDataType rawDataType = findRawDataType(dc, platform, variant, rawDataTypeId); 345 333 346 334 RawBioAssay rba = null; … … 399 387 rba.setArrayDesign(designFromScan); 400 388 } 401 Platform platform = null; 402 PlatformVariant variant = null; 403 RawDataType rawDataType = null; 404 if (platformMapper != null) 389 // Only do this when updating since the same thing is done in 'createItem' 390 if (rba.isInDatabase()) 405 391 { 406 platform = findPlatform(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, platformMapper.getValue(data)); 407 } 408 if (variantMapper != null) 409 { 410 variant = findVariant(dc, platform, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, variantMapper.getValue(data)); 411 } 412 if (variant != null && rawDataType == null) rawDataType = variant.getRawDataType(); 413 if (platform != null && rawDataType == null) rawDataType = platform.getRawDataType(); 414 if (rawDataType == null && rawDataTypeMapper != null) 415 { 416 rawDataType = RawDataTypes.getSafeRawDataType(rawDataTypeMapper.getValue(data)); 417 } 418 if (variant != null) 419 { 420 rba.setVariant(variant, rawDataType); 421 } 422 else if (platform != null) 423 { 424 rba.setPlatform(platform, rawDataType); 392 Platform platform = null; 393 PlatformVariant variant = null; 394 String rawDataTypeId = null; 395 if (platformMapper != null) 396 { 397 platform = findPlatform(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, platformMapper.getValue(data)); 398 } 399 else 400 { 401 platform = rba.getPlatform(); 402 } 403 if (variantMapper != null) 404 { 405 variant = findVariant(dc, platform, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, variantMapper.getValue(data)); 406 } 407 else 408 { 409 variant = rba.getVariant(); 410 } 411 if (rawDataTypeMapper != null) 412 { 413 rawDataTypeId = rawDataTypeMapper.getValue(data); 414 } 415 else 416 { 417 rawDataTypeId = rba.getRawDataType().getId(); 418 } 419 RawDataType rawDataType = findRawDataType(dc, platform, variant, rawDataTypeId); 420 if (variant != null) 421 { 422 rba.setVariant(variant, rawDataType); 423 } 424 else if (platform != null) 425 { 426 rba.setPlatform(platform, rawDataType); 427 } 425 428 } 426 429 } -
trunk/src/test/data/test.batchimport.rawbioassays.txt
r4434 r5177 1 1 Name Description Array index Platform Variant Raw data type Scan Protocol Software Array design File type File 2 2 Raw data 1 The first data set 1 Generic genepix Scan 1 Feature Feature Generic.1 Generic raw data test.gpr 3 Raw data 2 The second 1 Generic Variant genepix Scan 2 Feature Feature Generic.2 Generic raw data test.gpr3 Raw data 2 The second 1 Generic Variant GenePix Scan 2 Feature Feature Generic.2 Generic raw data test.gpr 4 4 Raw data 3.1 From same hyb 1 Affymetrix Scan 3 Feature Feature Affy CEL file test.cel 5 5 Raw data 3.2 From same hyb 2 Affymetrix Scan 3 Feature Feature Affy CEL file test.cel
Note: See TracChangeset
for help on using the changeset viewer.