Changeset 7303


Ignore:
Timestamp:
Mar 1, 2017, 3:36:09 PM (5 years ago)
Author:
Nicklas Nordborg
Message:

References #2058: Item overview is not working when going from extract to derived bioassay

The second fix did not work since it was going up and down among the extracts causing derived bioassays for other libraries in the pool to be loaded when they should not be loaded.

This fix changes the code so that only parent extracts from the root node are considered when loading the derived and raw bioassays.

Location:
trunk/src/core/net/sf/basedb/util/overview/loader
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/util/overview/loader/DerivedBioAssayLoader.java

    r7302 r7303  
    2222package net.sf.basedb.util.overview.loader;
    2323
     24import java.util.Collections;
    2425import java.util.HashSet;
    2526import java.util.List;
     
    211212    // We should only load derived bioassays that has a null extract or an
    212213    // extract that is found in the parent chain
    213     Set<Integer> extractIds = getExtractChain(bioAssayNode);
     214    Set<Integer> extractIds = getExtractChain(dc, bioAssayNode);
    214215    if (extractIds.size() > 0)
    215     {
    216       // Since we don't know exactly how far upstreams the given extracts are we
    217       // must first find all parent items (recursively)
    218       Set<Integer> allParents = getAllExtractParents(dc, extractIds);
    219      
     216    {     
    220217      query.restrict(
    221218        Restrictions.or(
     
    223220          Restrictions.in(Hql.property("extract"), Expressions.parameter("extracts"))
    224221        ));
    225       query.setParameter("extracts", allParents, Type.INT);
     222      query.setParameter("extracts", extractIds, Type.INT);
    226223    }
    227224
     
    254251    // We should only load derived bioassays that has a null extract or an
    255252    // extract that is found in the parent chain
    256     Set<Integer> extractIds = getExtractChain(parentNode);
     253    Set<Integer> extractIds = getExtractChain(dc, parentNode);
    257254    if (extractIds.size() > 0)
    258     {
    259       // Since we don't know exactly how far upstreams the given extracts are we
    260       // must first find all parent items (recursively)
    261       Set<Integer> allParents = getAllExtractParents(dc, extractIds);
    262      
     255    {     
    263256      query.restrict(
    264257        Restrictions.or(
     
    266259          Restrictions.in(Hql.property("extract"), Expressions.parameter("extracts"))
    267260        ));
    268       query.setParameter("extracts", allParents, Type.INT);
     261      query.setParameter("extracts", extractIds, Type.INT);
    269262    }
    270263
     
    399392  }
    400393 
    401   private Set<Integer> getExtractChain(Node node)
     394  private Set<Integer> getExtractChain(DbControl dc, Node node)
    402395  {
    403396    List<Node> extractNodes = node.findAll(new ItemTypeFilter(Item.EXTRACT));
     
    406399    {
    407400      extractIds.add(n.getItem().getId());
     401      if (n.getParent() == null)
     402      {
     403        // We have reach the root node, continue to load parent extracts from here
     404        SourceItemTransformer transformer = new ExtractToParentExtractTransformer(true);
     405        extractIds.addAll(transformer.transform(new TransformContext(dc), Collections.singleton(n.getItem().getId())));
     406       
     407      }
    408408    }
    409409    return extractIds;
    410410  }
    411  
    412   private Set<Integer> getAllExtractParents(DbControl dc, Set<Integer> extracts)
    413   {
    414     SourceItemTransformer transformer = new ExtractToParentExtractTransformer(true);
    415     return transformer.transform(new TransformContext(dc), extracts);
    416   }
    417411
    418412 
  • trunk/src/core/net/sf/basedb/util/overview/loader/RawBioAssayLoader.java

    r7302 r7303  
    2323
    2424
     25import java.util.Collections;
    2526import java.util.HashSet;
    2627import java.util.List;
     
    205206    // We should only load derived bioassays that has a null extract or an
    206207    // extract that is found in the parent chain
    207     Set<Integer> extractIds = getExtractChain(bioAssayNode);
     208    Set<Integer> extractIds = getExtractChain(dc, bioAssayNode);
    208209    if (extractIds.size() > 0)
    209210    {
    210       // Since we don't know exactly how far upstreams the given extracts are we
    211       // must first find all parent items (recursively)
    212       Set<Integer> allParents = getAllExtractParents(dc, extractIds);
    213      
    214211      query.restrict(
    215212        Restrictions.or(
     
    217214          Restrictions.in(Hql.property("parentExtract"), Expressions.parameter("extracts"))
    218215        ));
    219       query.setParameter("extracts", allParents, Type.INT);
     216      query.setParameter("extracts", extractIds, Type.INT);
    220217    }
    221218 
     
    256253  }
    257254 
    258   private Set<Integer> getExtractChain(Node node)
     255  private Set<Integer> getExtractChain(DbControl dc, Node node)
    259256  {
    260257    List<Node> extractNodes = node.findAll(new ItemTypeFilter(Item.EXTRACT));
     
    263260    {
    264261      extractIds.add(n.getItem().getId());
     262      if (n.getParent() == null)
     263      {
     264        // We have reach the root node, continue to load parent extracts from here
     265        SourceItemTransformer transformer = new ExtractToParentExtractTransformer(true);
     266        extractIds.addAll(transformer.transform(new TransformContext(dc), Collections.singleton(n.getItem().getId())));
     267       
     268      }
    265269    }
    266270    return extractIds;
    267271  }
    268  
    269   private Set<Integer> getAllExtractParents(DbControl dc, Set<Integer> extracts)
    270   {
    271     SourceItemTransformer transformer = new ExtractToParentExtractTransformer(true);
    272     return transformer.transform(new TransformContext(dc), extracts);
    273   }
    274272
    275273}
Note: See TracChangeset for help on using the changeset viewer.