Changeset 7490


Ignore:
Timestamp:
May 28, 2018, 2:47:24 PM (5 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #2122: Item overview should load more child derived and raw bioassays from extracts

The direct links should now be loaded also for bioassays with a parent as long as that parent doesn't lead to the originating extract. Only the top-most derived bioassay is loaded and directly and children to that are loaded as normal.

Location:
branches/3.12-stable/src/core/net/sf/basedb/util/overview/loader
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3.12-stable/src/core/net/sf/basedb/util/overview/loader/DerivedBioAssayLoader.java

    r7303 r7490  
    5050import net.sf.basedb.util.overview.OverviewUtil;
    5151import net.sf.basedb.util.overview.Validator;
     52import net.sf.basedb.util.overview.filter.BasicItemFilter;
    5253import net.sf.basedb.util.overview.filter.ItemTypeFilter;
    5354import net.sf.basedb.util.overview.node.ChildNodeDirection;
     
    157158  protected void loadPropertyChildNodes(DbControl dc, OverviewContext context, Node bioAssayNode)
    158159  {
    159     getNodeLoader(context, Item.EXTRACT).createReverseNode(dc, context, bioAssayNode);
     160    Extract e = getExtract((DerivedBioAssay)bioAssayNode.getItem());
     161    if (e == null || bioAssayNode.getFirstParent(new BasicItemFilter(e)) == null)
     162    {
     163      // Only load the extract if it is not already a parent node
     164      getNodeLoader(context, Item.EXTRACT).createReverseNode(dc, context, bioAssayNode);
     165    }
    160166    getNodeLoader(context, Item.ANNOTATION).createPropertyNode(dc, context, bioAssayNode);
    161167    getNodeLoader(context, Item.FILESETMEMBER).createPropertyNode(dc, context, bioAssayNode);
     
    281287    NodeFactory<DerivedBioAssay> nf = getNodeFactory(dc, context);
    282288    Node folderNode = null;
     289    // Load derived bioassays linked to the 'extract' if:
     290    // they have no parent bioassay OR
     291    // the parent bioassay has no parent extract OR
     292    // the parent bioassay has a different parent extract
    283293    ItemQuery<DerivedBioAssay> query = DerivedBioAssay.getQuery();
    284294    query.restrict(Restrictions.eq(Hql.property("extract"), Hql.entity(extract)));
    285295    query.join(Hql.leftJoin("parents", "parent"));
    286     query.restrict(Restrictions.eq(Hql.alias("parent"), null));
     296    query.join(Hql.leftJoin("parent", "extract", "parentExtract", null, false));
     297    query.restrict(
     298      Restrictions.or(
     299        Restrictions.eq(Hql.alias("parent"), null),
     300        Restrictions.eq(Hql.alias("parentExtract"), null),
     301        Restrictions.neq(Hql.alias("parentExtract"), Hql.entity(extract))
     302        ));
     303    query.setDistinct(true); // left joins may create multiple hits for items with more than one parent
    287304    context.initQuery(query, "name");
    288305    ItemResultIterator<DerivedBioAssay> it = query.iterate(dc);
  • branches/3.12-stable/src/core/net/sf/basedb/util/overview/loader/RawBioAssayLoader.java

    r7303 r7490  
    4747import net.sf.basedb.util.overview.NodeAttribute;
    4848import net.sf.basedb.util.overview.OverviewContext;
     49import net.sf.basedb.util.overview.filter.BasicItemFilter;
    4950import net.sf.basedb.util.overview.filter.ItemTypeFilter;
    5051import net.sf.basedb.util.overview.node.ChildNodeDirection;
     
    169170  protected void loadPropertyChildNodes(DbControl dc, OverviewContext context, Node rawBioAssayNode)
    170171  {
    171     getNodeLoader(context, Item.EXTRACT).createReverseNode(dc, context, rawBioAssayNode);
     172    Extract e = getExtract((RawBioAssay)rawBioAssayNode.getItem());
     173    if (e == null || rawBioAssayNode.getFirstParent(new BasicItemFilter(e)) == null)
     174    {
     175      // Only load the extract if it is not already a parent node
     176      getNodeLoader(context, Item.EXTRACT).createReverseNode(dc, context, rawBioAssayNode);
     177    }
    172178    getNodeLoader(context, Item.ANNOTATION).createPropertyNode(dc, context, rawBioAssayNode);
    173179    getNodeLoader(context, Item.FILESETMEMBER).createPropertyNode(dc, context, rawBioAssayNode);
     
    235241    NodeFactory<RawBioAssay> nf = getNodeFactory(dc, context);
    236242    Node folderNode = null;
     243    // Load raw bioassays linked to the 'extract' if:
     244    // they have no parent bioassay OR
     245    // the parent bioassay has no parent extract OR
     246    // the parent bioassay has a different parent extract
    237247    ItemQuery<RawBioAssay> query = RawBioAssay.getQuery();
    238248    query.restrict(Restrictions.eq(Hql.property("parentExtract"), Hql.entity(extract)));
    239     query.restrict(Restrictions.eq(Hql.property("parentBioAssay"), null));
     249    query.join(Hql.leftJoin("parentBioAssay", "parent"));
     250    query.join(Hql.leftJoin("parent", "extract", "parentExtract", null, false));
     251    query.restrict(
     252        Restrictions.or(
     253          Restrictions.eq(Hql.alias("parent"), null),
     254          Restrictions.eq(Hql.alias("parentExtract"), null),
     255          Restrictions.neq(Hql.alias("parentExtract"), Hql.entity(extract))
     256          ));
    240257    context.initQuery(query, "name");
    241258    ItemResultIterator<RawBioAssay> it = query.iterate(dc);
     
    253270  }
    254271 
     272  /**
     273    Get the extract that is associated with the current raw bioassay
     274    @return The extract or null if none was found
     275  */
     276  private Extract getExtract(RawBioAssay bioAssay)
     277  {
     278    Extract extract = null;
     279    try
     280    {
     281      extract = bioAssay.getParentExtract();
     282    }
     283    catch (PermissionDeniedException ex)
     284    {}
     285    return extract;
     286  }
     287
    255288  private Set<Integer> getExtractChain(DbControl dc, Node node)
    256289  {
Note: See TracChangeset for help on using the changeset viewer.