Changeset 7772


Ignore:
Timestamp:
Feb 17, 2020, 8:46:13 AM (22 months ago)
Author:
Nicklas Nordborg
Message:

References #2203: Parent-child transformations should consider the "push annotations" flag

This should now be implemented via the PushToParentsTransformer implementation. Note that this transformer is only added to the first step and move up as long as it finds items that has the "push annotations" flag set.

Location:
trunk/src/core/net/sf/basedb
Files:
1 added
11 edited

Legend:

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

    r7771 r7772  
    5252  public IdListRestriction(Set<Integer> idList)
    5353  {
    54     this.idList = idList;
     54    this.idList = new HashSet<>(idList);
    5555    this.idExpression = Hql.property("id");
    5656  }
  • trunk/src/core/net/sf/basedb/util/listable/ExtractToParentExtractTransformer.java

    r6848 r7772  
    4848  private final boolean includeSourcesInTarget;
    4949  private CollectExtracts collectedExtracts;
     50  private boolean pushOnly;
    5051 
    5152  /**
     
    5758    super(Item.EXTRACT, Item.EXTRACT);
    5859    this.includeSourcesInTarget = includeSourcesInTarget;
     60  }
     61 
     62  /**
     63    Create a new extract to parent extract transformer that only load parents
     64    to extracts that has a subtype with "push annotations" set. This functionality
     65    should only be used in the first transformation step.
     66    @see PushToParentsTransformer
     67    @since 3.16
     68  */
     69  public ExtractToParentExtractTransformer(boolean includeSourcesInTarget, boolean childrensThatPushOnly)
     70  {
     71    this(includeSourcesInTarget);
     72    this.pushOnly = childrensThatPushOnly;
    5973  }
    6074 
     
    87101      )
    88102    );
     103    if (pushOnly)
     104    {
     105      query.join(Hql.innerJoin("bm", "itemSubtype", "st"));
     106      query.restrict(Restrictions.eq(Hql.property("st", "pushAnnotations"), Expressions.bool(true)));
     107    }
    89108
    90109    // If we have collected downstream extracts we must
  • trunk/src/core/net/sf/basedb/util/listable/ExtractToSampleTransformer.java

    r6848 r7772  
    4747{
    4848
     49  private boolean pushOnly;
     50 
    4951  public ExtractToSampleTransformer()
    5052  {
    5153    super(Item.EXTRACT, Item.SAMPLE);
     54  }
     55 
     56  /**
     57    Create a new extract to sample transformer that only load parent samples
     58    to extracts that has a subtype with "push annotations" set. This functionality
     59    should only be used in the first transformation step.
     60    @see PushToParentsTransformer
     61    @since 3.16
     62  */
     63  public ExtractToSampleTransformer(boolean childrensThatPushOnly)
     64  {
     65    this();
     66    this.pushOnly = childrensThatPushOnly;
    5267  }
    5368 
     
    6883      )
    6984    );
     85    if (pushOnly)
     86    {
     87      query.join(Hql.innerJoin("ch", "itemSubtype", "st"));
     88      query.restrict(Restrictions.eq(Hql.property("st", "pushAnnotations"), Expressions.bool(true)));
     89    }
    7090    return safeIdList(context.getDbControl(), query, "extracts", source);
    7191  }
  • trunk/src/core/net/sf/basedb/util/listable/SampleToBioSourceTransformer.java

    r6848 r7772  
    4444{
    4545
     46  private boolean pushOnly;
     47 
    4648  public SampleToBioSourceTransformer()
    4749  {
    4850    super(Item.SAMPLE, Item.BIOSOURCE);
     51  }
     52 
     53  /**
     54    Create a new sample to biosource transformer that only load parent biosources
     55    to sample that has a subtype with "push annotations" set. This functionality
     56    should only be used in the first transformation step.
     57    @see PushToParentsTransformer
     58    @since 3.16
     59  */
     60  public SampleToBioSourceTransformer(boolean childrensThatPushOnly)
     61  {
     62    this();
     63    this.pushOnly = childrensThatPushOnly;
    4964  }
    5065 
     
    6580      )
    6681    );
     82    if (pushOnly)
     83    {
     84      query.join(Hql.innerJoin("ch", "itemSubtype", "st"));
     85      query.restrict(Restrictions.eq(Hql.property("st", "pushAnnotations"), Expressions.bool(true)));
     86    }
    6787    return safeIdList(context.getDbControl(), query, "samples", source);
    6888  }
  • trunk/src/core/net/sf/basedb/util/listable/SampleToParentSampleTransformer.java

    r6848 r7772  
    4747
    4848  private final boolean includeSourcesInTarget;
     49  private boolean pushOnly;
    4950 
    5051  /**
     
    5758    this.includeSourcesInTarget = includeSourcesInTarget;
    5859  }
    59  
     60
     61  /**
     62    Create a new sample to parent sample transformer that only load parents
     63    to samples that has a subtype with "push annotations" set. This functionality
     64    should only be used in the first transformation step.
     65    @see PushToParentsTransformer
     66    @since 3.16
     67  */
     68  public SampleToParentSampleTransformer(boolean includeSourcesInTarget, boolean childrensThatPushOnly)
     69  {
     70    this(includeSourcesInTarget);
     71    this.pushOnly = childrensThatPushOnly;
     72  }
     73
    6074  @Override
    6175  public Set<Integer> transform(TransformContext context, Set<Integer> source)
     
    7488      )
    7589    );
     90    if (pushOnly)
     91    {
     92      query.join(Hql.innerJoin("bm", "itemSubtype", "st"));
     93      query.restrict(Restrictions.eq(Hql.property("st", "pushAnnotations"), Expressions.bool(true)));
     94    }
    7695   
    7796    // Keep track of all seen children and parents
  • trunk/src/core/net/sf/basedb/util/listable/SourceItemTransformerWithCache.java

    r7770 r7772  
    2222package net.sf.basedb.util.listable;
    2323
     24import java.util.Collections;
    2425import java.util.List;
    2526import java.util.Set;
     
    124125        if (cache != null) cache.store(key, target);
    125126      }
    126       return target;
     127      return Collections.unmodifiableSet(target);
    127128    }
    128129  }
  • trunk/src/core/net/sf/basedb/util/listable/ToDerivedBioAssaySourceItemTransformerFactory.java

    r7219 r7772  
    7575      if (sourceItemType == Item.SAMPLE || stepBySource == Item.SAMPLE)
    7676      {
     77        // Expand source selection to parents if the children push annotations upwards
     78        if (sourceItemType == Item.SAMPLE) chain.add(new PushToParentsTransformer(sourceItemType));
    7779        // Load child samples including the original samples
    7880        chain.add(new SampleToChildSampleTransformer(true));
     
    8991          // Collect parent extracts since those are also valid when joining child derived bioassays
    9092          chain.add(collectedExtracts.collectParentsOfSource(false));
     93          // Expand source selection to parents if the children push annotations upwards
     94          chain.add(new PushToParentsTransformer(sourceItemType));
    9195        }
    9296
  • trunk/src/core/net/sf/basedb/util/listable/ToExtractSourceItemTransformerFactory.java

    r6801 r7772  
    7575      if (sourceItemType == Item.SAMPLE || stepBySource == Item.SAMPLE)
    7676      {
     77        // Expand source selection to parents if the children push annotations upwards
     78        if (sourceItemType == Item.SAMPLE) chain.add(new PushToParentsTransformer(sourceItemType));
    7779        // Load child samples and include the source samples
    7880        chain.add(new SampleToChildSampleTransformer(true));
     
    8385      if (sourceItemType == Item.EXTRACT || stepBySource == Item.EXTRACT)
    8486      {
     87        // Expand source selection to parents if the children push annotations upwards
     88        if (sourceItemType == Item.EXTRACT) chain.add(new PushToParentsTransformer(sourceItemType));
    8589        // Load child extract and maybe include source extracts
    8690        chain.add(new ExtractToChildExtractTransformer(sourceItemType != Item.EXTRACT));
  • trunk/src/core/net/sf/basedb/util/listable/ToPhysicalBioAssaySourceItemTransformerFactory.java

    r6792 r7772  
    7575      if (sourceItemType == Item.SAMPLE || stepBySource == Item.SAMPLE)
    7676      {
     77        // Expand source selection to parents if the children push annotations upwards
     78        if (sourceItemType == Item.SAMPLE) chain.add(new PushToParentsTransformer(sourceItemType));
    7779        // Load child samples including the original samples
    7880        chain.add(new SampleToChildSampleTransformer(true));
     
    8385      if (sourceItemType == Item.EXTRACT || stepBySource == Item.EXTRACT)
    8486      {
     87        // Expand source selection to parents if the children push annotations upwards
     88        if (sourceItemType == Item.EXTRACT) chain.add(new PushToParentsTransformer(sourceItemType));
    8589        // Load child extract and include the source extracts
    8690        chain.add(new ExtractToChildExtractTransformer(true));
  • trunk/src/core/net/sf/basedb/util/listable/ToRawBioAssaySourceItemTransformerFactory.java

    r6801 r7772  
    7474      if (sourceItemType == Item.SAMPLE || stepBySource == Item.SAMPLE)
    7575      {
     76        // Expand source selection to parents if the children push annotations upwards
     77        if (sourceItemType == Item.SAMPLE) chain.add(new PushToParentsTransformer(sourceItemType));
    7678        // Load child samples including the original samples
    7779        chain.add(new SampleToChildSampleTransformer(true));
     
    8890          // Collect parent extracts since those are also valid when joining child derived bioassays
    8991          chain.add(collectedExtracts.collectParentsOfSource(false));
     92          // Expand source selection to parents if the children push annotations upwards
     93          chain.add(new PushToParentsTransformer(sourceItemType));
    9094        }
    9195       
  • trunk/src/core/net/sf/basedb/util/listable/ToSampleSourceItemTransformerFactory.java

    r6791 r7772  
    7575      if (sourceItemType == Item.SAMPLE || stepBySource == Item.SAMPLE)
    7676      {
     77        // Expand source selection to parents if the children push annotations upwards
     78        if (sourceItemType == Item.SAMPLE) chain.add(new PushToParentsTransformer(sourceItemType));
    7779        // Load child samples and maybe include source samples
    7880        chain.add(new SampleToChildSampleTransformer(sourceItemType != Item.SAMPLE));
Note: See TracChangeset for help on using the changeset viewer.