Changeset 5647


Ignore:
Timestamp:
May 27, 2011, 3:01:15 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #1597: Subtypes of items

Added subtype functionality to the sample importer. The importer uses the "related subtypes" feature when looking for protocols, biosources and parent samples. So, if the imported sample has subtype S1 that is related to the protocol subtype P1 the importer will first try to find a protocol with that subtype.

Re-organized code in the abstract item importer to avoid code duplication.

Discovered a flaw in how the cachec system works when used with subtypes. The cache would not consider the subtype setting and could possible return an item with a different subtype.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/core/ItemSubtype.java

    r5645 r5647  
    111111 
    112112  /**
     113    Utility method for loading a subtype that is related to the subtype of the given item.
     114    @param dc A DbControl to use for database access
     115    @param item A subtypable item
     116    @param relatedItem The main item type of the related subtype we are looking for
     117    @param defaultRelatedId An ID of the subtype to return if no related subtype is found
     118     
     119    @return An ItemSubtype or null
     120  */
     121  public static ItemSubtype getRelatedSubtype(DbControl dc, Subtypable item, Item relatedItem, int defaultRelatedId)
     122  {
     123    ItemSubtype related = null;
     124    ItemSubtype subtype = item.getItemSubtype();
     125    if (subtype != null)
     126    {
     127      related = subtype.getRelatedSubtype(relatedItem);
     128    }
     129    if (related == null && defaultRelatedId > 0)
     130    {
     131      related = getById(dc, defaultRelatedId);
     132    }
     133    return related;
     134  }
     135 
     136  /**
    113137    Create a new item subtype item.
    114138 
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/AbstractItemImporter.java

    r5646 r5647  
    10981098    if (subtypeQuery == null)
    10991099    {
    1100       subtypeQuery = initReferenceQuery(dc, idMethod, ItemSubtype.getQuery(null));
     1100      subtypeQuery = initReferenceQuery(dc, idMethod, ItemSubtype.getQuery(null), false);
    11011101      subtypeQuery.restrictPermanent(
    11021102        Restrictions.eq(
     
    11071107    }
    11081108    subtypeQuery.setParameter("itemType", mainType.getValue(), Type.INT);
    1109     return findReferencedItem(dc, idMethod, subtypeQuery, identifier, true);
     1109    return findReferencedItem(dc, idMethod, subtypeQuery, identifier, 0, false);
    11101110  }
    11111111 
     
    11431143    if (protocolQuery == null)
    11441144    {
    1145       // where ... (itemSubtype = :subtype AND checkType = 1) || checkType = 0
    1146       Expression checkType = Expressions.parameter("checkType");
    1147       protocolQuery = initReferenceQuery(dc, idMethod, Protocol.getQuery());
    1148       protocolQuery.restrictPermanent(
    1149         Restrictions.or(
    1150           Restrictions.and(
    1151             Restrictions.eq(Hql.property("itemSubtype"), Expressions.parameter("subtype")),
    1152             Restrictions.eq(checkType, Expressions.integer(1))
    1153           ),
    1154           Restrictions.eq(checkType, Expressions.integer(0))
    1155         )
    1156       );
    1157     }
    1158     protocolQuery.setParameter("subtype", subtype == null ? 0 : subtype.getId(), Type.INT);
    1159     protocolQuery.setParameter("checkType", subtype == null ? 0 : 1, Type.INT);
    1160     Protocol protocol = findReferencedItem(dc, idMethod, protocolQuery, identifier, true);
    1161     if (protocol == null)
    1162     {
    1163       protocolQuery.setParameter("checkType", 0, Type.INT);
    1164       protocol = findReferencedItem(dc, idMethod, protocolQuery, identifier, false);
    1165     }
    1166     return protocol;
     1145      protocolQuery = initReferenceQuery(dc, idMethod, Protocol.getQuery(), true);
     1146    }
     1147    return findReferencedItemWithSubtype(dc, idMethod, protocolQuery, identifier, subtype, false);
    11671148  }
    11681149
     
    12001181    if (tagQuery == null)
    12011182    {
    1202       // where ... (itemSubtype = :subtype AND checkType = 1) || checkType = 0
    1203       Expression checkType = Expressions.parameter("checkType");
    1204       tagQuery = initReferenceQuery(dc, idMethod, Tag.getQuery());
    1205       tagQuery.restrictPermanent(
    1206         Restrictions.or(
    1207           Restrictions.and(
    1208             Restrictions.eq(Hql.property("itemSubtype"), Expressions.parameter("subtype")),
    1209             Restrictions.eq(checkType, Expressions.integer(1))
    1210           ),
    1211           Restrictions.eq(checkType, Expressions.integer(0))
    1212         )
    1213       );
    1214     }
    1215     tagQuery.setParameter("subtype", subtype == null ? 0 : subtype.getId(), Type.INT);
    1216     tagQuery.setParameter("checkType", subtype == null ? 0 : 1, Type.INT);
    1217     Tag tag = findReferencedItem(dc, idMethod, tagQuery, identifier, true);
    1218     if (tag == null)
    1219     {
    1220       tagQuery.setParameter("checkType", 0, Type.INT);
    1221       tag = findReferencedItem(dc, idMethod, tagQuery, identifier, false);
    1222     }
    1223     return tag;
     1183      tagQuery = initReferenceQuery(dc, idMethod, Tag.getQuery(), true);
     1184    }
     1185    return findReferencedItemWithSubtype(dc, idMethod, tagQuery, identifier, subtype, false);
    12241186  }
    12251187 
     
    12581220    if (hardwareQuery == null)
    12591221    {
    1260       // where ... (itemSubtype = :subtype AND checkType = 1) || checkType = 0
    1261       Expression checkType = Expressions.parameter("checkType");
    1262       hardwareQuery = initReferenceQuery(dc, idMethod, Hardware.getQuery());
    1263       hardwareQuery.restrictPermanent(
    1264         Restrictions.or(
    1265           Restrictions.and(
    1266             Restrictions.eq(Hql.property("itemSubtype"), Expressions.parameter("subtype")),
    1267             Restrictions.eq(checkType, Expressions.integer(1))
    1268           ),
    1269           Restrictions.eq(checkType, Expressions.integer(0))
    1270         )
    1271       );
    1272     }
    1273     hardwareQuery.setParameter("subtype", subtype == null ? 0 : subtype.getId(), Type.INT);
    1274     hardwareQuery.setParameter("checkType", subtype == null ? 0 : 1, Type.INT);
    1275     Hardware hardware = findReferencedItem(dc, idMethod, hardwareQuery, identifier, true);
    1276     if (hardware == null)
    1277     {
    1278       hardwareQuery.setParameter("checkType", 0, Type.INT);
    1279       hardware = findReferencedItem(dc, idMethod, hardwareQuery, identifier, false);
    1280     }
    1281     return hardware;
     1222      hardwareQuery = initReferenceQuery(dc, idMethod, Hardware.getQuery(), true);
     1223    }
     1224    return findReferencedItemWithSubtype(dc, idMethod, hardwareQuery, identifier, subtype, false);
    12821225  }
    12831226
     
    13151258    if (softwareQuery == null)
    13161259    {
    1317       // where ... (itemSubtype = :subtype AND checkType = 1) || checkType = 0
    1318       Expression checkType = Expressions.parameter("checkType");
    1319       softwareQuery = initReferenceQuery(dc, idMethod, Software.getQuery());
    1320       softwareQuery.restrictPermanent(
    1321         Restrictions.or(
    1322           Restrictions.and(
    1323             Restrictions.eq(Hql.property("itemSubtype"), Expressions.parameter("subtype")),
    1324             Restrictions.eq(checkType, Expressions.integer(1))
    1325           ),
    1326           Restrictions.eq(checkType, Expressions.integer(0))
    1327         )
    1328       );
    1329     }
    1330     softwareQuery.setParameter("subtype", subtype == null ? 0 : subtype.getId(), Type.INT);
    1331     softwareQuery.setParameter("checkType", subtype == null ? 0 : 1, Type.INT);
    1332     Software software = findReferencedItem(dc, idMethod, softwareQuery, identifier, true);
    1333     if (software == null)
    1334     {
    1335       softwareQuery.setParameter("checkType", 0, Type.INT);
    1336       software = findReferencedItem(dc, idMethod, softwareQuery, identifier, false);
    1337     }
    1338     return software;
     1260      softwareQuery = initReferenceQuery(dc, idMethod, Software.getQuery(), true);
     1261    }
     1262    return findReferencedItemWithSubtype(dc, idMethod, softwareQuery, identifier, subtype, false);
    13391263  }
    13401264 
     
    13581282    if (platformQuery == null)
    13591283    {
    1360       platformQuery = initReferenceQuery(dc, idMethod, Platform.getQuery());
    1361     }
    1362     return findReferencedItem(dc, idMethod, platformQuery, identifier, false);
     1284      platformQuery = initReferenceQuery(dc, idMethod, Platform.getQuery(), false);
     1285    }
     1286    return findReferencedItem(dc, idMethod, platformQuery, identifier, 0, false);
    13631287  }
    13641288  /**
     
    14081332    if (variantQuery == null)
    14091333    {
    1410       variantQuery = initReferenceQuery(dc, idMethod, PlatformVariant.getQuery());
     1334      variantQuery = initReferenceQuery(dc, idMethod, PlatformVariant.getQuery(), false);
    14111335      // variant.platform = :platform or 1 = :anyplatform
    14121336      variantQuery.restrict(
     
    14191343    variantQuery.setParameter("platform", platform == null ? 0 : platform.getId(), Type.INT);
    14201344    variantQuery.setParameter("anyplatform", platform == null ? 1 : 0, Type.INT);
    1421     return findReferencedItem(dc, idMethod, variantQuery, identifier, false);
     1345    return findReferencedItem(dc, idMethod, variantQuery, identifier, 0, false);
    14221346  }
    14231347 
     
    14551379    if (fileTypeQuery == null)
    14561380    {
    1457       fileTypeQuery = initReferenceQuery(dc, idMethod, DataFileType.getQuery());
    1458     }
    1459     return findReferencedItem(dc, idMethod, fileTypeQuery, identifier, false);
     1381      fileTypeQuery = initReferenceQuery(dc, idMethod, DataFileType.getQuery(), false);
     1382    }
     1383    return findReferencedItem(dc, idMethod, fileTypeQuery, identifier, 0, false);
    14601384  }
    14611385 
     
    14791403    if (permissionTemplateQuery == null)
    14801404    {
    1481       permissionTemplateQuery = initReferenceQuery(dc, idMethod, PermissionTemplate.getQuery());
    1482     }
    1483     return findReferencedItem(dc, idMethod, permissionTemplateQuery, identifier, false);
     1405      permissionTemplateQuery = initReferenceQuery(dc, idMethod, PermissionTemplate.getQuery(), false);
     1406    }
     1407    return findReferencedItem(dc, idMethod, permissionTemplateQuery, identifier, 0, false);
    14841408  }
    14851409
    14861410 
    14871411  private ItemQuery<BioSource> bioSourceQuery;
     1412  /**
     1413    Same as {@link #findBioSource(DbControl, IdMethod, String, ItemSubtype)} with
     1414    a null item subtype.
     1415  */
     1416  protected BioSource findBioSource(DbControl dc, IdMethod idMethod, String identifier)
     1417  {
     1418    return findBioSource(dc, idMethod, identifier, null);
     1419  }
     1420   
    14881421  /**
    14891422    Find a biosource with a given identifier. This is a utility method that
     
    14941427    Subsequent calls uses the same query. Thus, this method should always be
    14951428    called with the same id method object, otherwise the result is undefined.
     1429    <p>
     1430    NOTE! If this method is called with a non-null item subtype parameter and
     1431    no biosource is found the query will be retried without any subtype.
    14961432   
    14971433    @param dc The DbControl to use for database access
    14981434    @param identifier The identifier protocol
     1435    @param subtype The biosource subtype, or null if the type doesn't matter
    14991436    @return A biosource, or null if no item could be found
    1500   */
    1501   protected BioSource findBioSource(DbControl dc, IdMethod idMethod, String identifier)
     1437    @since 3.0
     1438  */
     1439  protected BioSource findBioSource(DbControl dc, IdMethod idMethod, String identifier, ItemSubtype subtype)
    15021440  {
    15031441    if (identifier == null) return null;
    1504     if (bioSourceQuery == null) bioSourceQuery = initReferenceQuery(dc, idMethod, BioSource.getQuery());
    1505     return findReferencedItem(dc, idMethod, bioSourceQuery, identifier, false);
    1506   }
     1442    if (bioSourceQuery == null)
     1443    {
     1444      // where ... (itemSubtype = :subtype AND checkType = 1) || checkType = 0
     1445      bioSourceQuery = initReferenceQuery(dc, idMethod, BioSource.getQuery(), true);
     1446    }
     1447    return findReferencedItemWithSubtype(dc, idMethod, bioSourceQuery, identifier, subtype, false); }
    15071448
    15081449  private ItemQuery<Sample> sampleQuery;
     1450  /**
     1451    Same as {@link #findSample(DbControl, IdMethod, String, ItemSubtype)}
     1452    with a null subtype.
     1453  */
     1454  protected Sample findSample(DbControl dc, IdMethod idMethod, String identifier)
     1455  {
     1456    return findSample(dc, idMethod, identifier, null);
     1457  }
     1458
    15091459  /**
    15101460    Find a sample with a given identifier. This is a utility method that
     
    15151465    Subsequent calls uses the same query. Thus, this method should always be
    15161466    called with the same id method object, otherwise the result is undefined.
     1467    <p>
     1468    NOTE! If this method is called with a non-null item subtype parameter and
     1469    no sample is found the query will be retried without any subtype.
    15171470   
    15181471    @param dc The DbControl to use for database access
    15191472    @param identifier The identifier protocol
     1473    @param subtype The biosource subtype, or null if the type doesn't matter
    15201474    @return A sample, or null if no item could be found
    1521   */
    1522   protected Sample findSample(DbControl dc, IdMethod idMethod, String identifier)
     1475    @since 3.0
     1476  */
     1477  protected Sample findSample(DbControl dc, IdMethod idMethod, String identifier, ItemSubtype subtype)
    15231478  {
    15241479    if (identifier == null) return null;
    1525     if (sampleQuery == null) sampleQuery = initReferenceQuery(dc, idMethod, Sample.getQuery());
    1526     return findReferencedItem(dc, idMethod, sampleQuery, identifier, false);
    1527   }
    1528 
     1480    if (sampleQuery == null)
     1481    {
     1482      sampleQuery = initReferenceQuery(dc, idMethod, Sample.getQuery(), true);
     1483    }
     1484    return findReferencedItemWithSubtype(dc, idMethod, sampleQuery, identifier, subtype, false);
     1485  }
     1486 
    15291487  private ItemQuery<Extract> extractQuery;
    15301488  /**
     
    15461504    if (extractQuery == null)
    15471505    {
    1548       extractQuery = initReferenceQuery(dc, idMethod, Extract.getQuery());
    1549       extractQuery.restrictPermanent(Restrictions.eq(Hql.property("itemSubtype"), null));
    1550 
    1551     }
    1552     return findReferencedItem(dc, idMethod, extractQuery, identifier, false);
     1506      extractQuery = initReferenceQuery(dc, idMethod, Extract.getQuery(), false);
     1507    }
     1508    return findReferencedItem(dc, idMethod, extractQuery, identifier, 0, false);
    15531509  }
    15541510
     
    15721528    if (labeledExtractQuery == null)
    15731529    {
    1574       labeledExtractQuery = initReferenceQuery(dc, idMethod, Extract.getQuery());
     1530      labeledExtractQuery = initReferenceQuery(dc, idMethod, Extract.getQuery(), false);
    15751531      labeledExtractQuery.restrictPermanent(
    15761532        Restrictions.eq(
     
    15801536      );
    15811537    }
    1582     return findReferencedItem(dc, idMethod, labeledExtractQuery, identifier, false);
     1538    return findReferencedItem(dc, idMethod, labeledExtractQuery, identifier, 0, false);
    15831539  }
    15841540 
     
    16021558    if (bioPlateQuery == null)
    16031559    {
    1604       bioPlateQuery = initReferenceQuery(dc, idMethod, BioPlate.getQuery());
    1605     }
    1606     return findReferencedItem(dc, idMethod, bioPlateQuery, identifier, false);
     1560      bioPlateQuery = initReferenceQuery(dc, idMethod, BioPlate.getQuery(), false);
     1561    }
     1562    return findReferencedItem(dc, idMethod, bioPlateQuery, identifier, 0, false);
    16071563  }
    16081564 
     
    16531609    if (arraySlideQuery == null)
    16541610    {
    1655       arraySlideQuery = initReferenceQuery(dc, idMethod, ArraySlide.getQuery());
    1656     }
    1657     return findReferencedItem(dc, idMethod, arraySlideQuery, identifier, false);
     1611      arraySlideQuery = initReferenceQuery(dc, idMethod, ArraySlide.getQuery(), false);
     1612    }
     1613    return findReferencedItem(dc, idMethod, arraySlideQuery, identifier, 0, false);
    16581614  }
    16591615 
     
    16771633    if (hybQuery == null)
    16781634    {
    1679       hybQuery = initReferenceQuery(dc, idMethod, PhysicalBioAssay.getQuery());
    1680     }
    1681     return findReferencedItem(dc, idMethod, hybQuery, identifier, false);
     1635      hybQuery = initReferenceQuery(dc, idMethod, PhysicalBioAssay.getQuery(), false);
     1636    }
     1637    return findReferencedItem(dc, idMethod, hybQuery, identifier, 0, false);
    16821638  }
    16831639
     
    17011657    if (scanQuery == null)
    17021658    {
    1703       scanQuery = initReferenceQuery(dc, idMethod, Scan.getQuery());
    1704     }
    1705     return findReferencedItem(dc, idMethod, scanQuery, identifier, false);
     1659      scanQuery = initReferenceQuery(dc, idMethod, Scan.getQuery(), false);
     1660    }
     1661    return findReferencedItem(dc, idMethod, scanQuery, identifier, 0, false);
    17061662  }
    17071663 
     
    17791735    if (designQuery == null)
    17801736    {
    1781       designQuery = initReferenceQuery(dc, idMethod, ArrayDesign.getQuery());
    1782     }
    1783     return findReferencedItem(dc, idMethod, designQuery, identifier, false);
     1737      designQuery = initReferenceQuery(dc, idMethod, ArrayDesign.getQuery(), false);
     1738    }
     1739    return findReferencedItem(dc, idMethod, designQuery, identifier, 0, false);
    17841740  }
    17851741
     
    18031759    if (batchQuery == null)
    18041760    {
    1805       batchQuery = initReferenceQuery(dc, idMethod, ArrayBatch.getQuery());
    1806     }
    1807     return findReferencedItem(dc, idMethod, batchQuery, identifier, false);
     1761      batchQuery = initReferenceQuery(dc, idMethod, ArrayBatch.getQuery(), false);
     1762    }
     1763    return findReferencedItem(dc, idMethod, batchQuery, identifier, 0, false);
    18081764  }
    18091765
     
    18291785    if (geometryQuery == null)
    18301786    {
    1831       geometryQuery = initReferenceQuery(dc, idMethod, PlateGeometry.getQuery());
    1832     }
    1833     return findReferencedItem(dc, idMethod, geometryQuery, identifier, false);
     1787      geometryQuery = initReferenceQuery(dc, idMethod, PlateGeometry.getQuery(), false);
     1788    }
     1789    return findReferencedItem(dc, idMethod, geometryQuery, identifier, 0, false);
    18341790  }
    18351791
     
    18541810    if (bioPlateTypeQuery == null)
    18551811    {
    1856       bioPlateTypeQuery = initReferenceQuery(dc, idMethod, BioPlateType.getQuery());
    1857     }
    1858     return findReferencedItem(dc, idMethod, bioPlateTypeQuery, identifier, false);
     1812      bioPlateTypeQuery = initReferenceQuery(dc, idMethod, BioPlateType.getQuery(), false);
     1813    }
     1814    return findReferencedItem(dc, idMethod, bioPlateTypeQuery, identifier, 0, false);
    18591815  }
    18601816 
     
    19461902    @param idMethod The identification method to use
    19471903    @param query The query to initialised
     1904    @param subtype If TRUE a restriction for subtype is added to the query
    19481905    @return The initialised query
    19491906  */
    1950   protected <T extends BasicItem> ItemQuery<T> initReferenceQuery(DbControl dc, IdMethod idMethod, ItemQuery<T> query)
     1907  protected <T extends BasicItem> ItemQuery<T> initReferenceQuery(DbControl dc, IdMethod idMethod,
     1908    ItemQuery<T> query, boolean subtype)
    19511909  {
    19521910    query = idMethod.prepareQuery(dc, query);
    19531911    query.include(Include.MINE, Include.IN_PROJECT, Include.SHARED, Include.OTHERS);
     1912    if (subtype)
     1913    {
     1914      // where ... (itemSubtype = :subtype AND checkType = 1) || checkType = 0
     1915      Expression checkType = Expressions.parameter("checkType");
     1916      query.restrictPermanent(
     1917          Restrictions.or(
     1918            Restrictions.and(
     1919              Restrictions.eq(Hql.property("itemSubtype"), Expressions.parameter("subtype")),
     1920              Restrictions.eq(checkType, Expressions.integer(1))
     1921            ),
     1922            Restrictions.eq(checkType, Expressions.integer(0))
     1923          )
     1924        );
     1925    }
    19541926    return query;
     1927  }
     1928 
     1929  /**
     1930    Find a referenced item with a subtype. This method may
     1931    call the {@link #findReferencedItem(DbControl, IdMethod, ItemQuery, String, int, boolean)}
     1932    method two times. First, with a query limited to return items of the given subtype,
     1933    then a second time without the limit. The query must have been created by
     1934    the {@link #initReferenceQuery(DbControl, IdMethod, ItemQuery, boolean)} method with
     1935    TRUE for the last parameter. If the subtype parameter is null the first query is
     1936    skipped.
     1937  */
     1938  protected <T extends BasicItem> T findReferencedItemWithSubtype(DbControl dc, IdMethod idMethod,
     1939      ItemQuery<T> query, String identifier, ItemSubtype subtype, boolean ignoreNotFound)
     1940  {
     1941    T item = null;
     1942    if (subtype != null)
     1943    {
     1944      query.setParameter("subtype", subtype.getId(), Type.INT);
     1945      query.setParameter("checkType", 1, Type.INT);
     1946      item = findReferencedItem(dc, idMethod, query, identifier, subtype.getId(), true);
     1947    }
     1948    if (item == null)
     1949    {
     1950      query.setParameter("subtype", 0, Type.INT);
     1951      query.setParameter("checkType", 0, Type.INT);
     1952      item = findReferencedItem(dc, idMethod, query, identifier, 0, ignoreNotFound);
     1953    }
     1954    return item;
    19551955  }
    19561956 
     
    19741974  @SuppressWarnings("unchecked")
    19751975  protected <T extends BasicItem> T findReferencedItem(DbControl dc, IdMethod idMethod,
    1976     ItemQuery<T> query, String identifier, boolean ignoreNotFound)
     1976    ItemQuery<T> query, String identifier, int subtypeId, boolean ignoreNotFound)
    19771977  {
    19781978    T item = null;
    19791979    Item itemType = query.getItemType();
    1980     String cacheKey = itemType.name() + ":" + identifier;
     1980    String cacheKey = itemType.name() + ":" + identifier + ":" + subtypeId;
    19811981    if (itemCache.containsKey(cacheKey))
    19821982    {
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/SampleImporter.java

    r5630 r5647  
    216216  }
    217217 
     218  @Override
     219  protected Item getItemForSubtypes()
     220  {
     221    return Item.SAMPLE;
     222  }
     223
    218224  /**
    219225    Adds column mappings for name, externalId, description,
     
    226232    parameters.add(internalIdColumnMapping);
    227233    parameters.add(nameColumnMapping);
     234    parameters.add(subtypeColumnMapping);
    228235    parameters.add(externalIdColumnMapping);
    229236    parameters.add(descriptionColumnMapping);
     
    287294    BioMaterialEvent creationEvent = sample.getCreationEvent();
    288295    if (createdMapper != null) creationEvent.setEventDate(parseDate(createdMapper.getValue(data)));
     296    updateItemSubtype(dc, sample, data);
    289297    if (protocolMapper != null)
    290298    {
    291299      String nameOrId = protocolMapper.getValue(data);
    292       ItemSubtype type = ItemSubtype.getById(dc,
     300      ItemSubtype type = ItemSubtype.getRelatedSubtype(dc, sample, Item.PROTOCOL,
    293301          SystemItems.getId(sample.isPooled() ? Protocol.POOLING : Protocol.SAMPLING));
    294302      Protocol protocol = findProtocol(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId, type);
     
    316324      {
    317325        String nameOrId = parentMapper.getValue(data);
    318         BioSource bioSource = findBioSource(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId);
     326        ItemSubtype type = ItemSubtype.getRelatedSubtype(dc, sample, Item.BIOSOURCE, 0);
     327        BioSource bioSource = findBioSource(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId, type);
    319328        if (nameOrId == null || bioSource != null) sample.setBioSource(bioSource);
    320329      }
     
    336345    {
    337346      String nameOrId = parentMapper.getValue(data);
    338       Sample parent = findSample(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId);
     347      ItemSubtype type = ItemSubtype.getRelatedSubtype(dc, sample, Item.SAMPLE, 0);
     348      Sample parent = findSample(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId, type);
    339349      if (parent != null)
    340350      {
Note: See TracChangeset for help on using the changeset viewer.