Changeset 8086 for branches/3.19-stable


Ignore:
Timestamp:
Oct 27, 2022, 2:13:24 PM (7 months ago)
Author:
Nicklas Nordborg
Message:

References #2285: Values from items with a "push-to-parent" subtype are not displayed in table list

This should fix the problem when the target item is a sample or extract.

Location:
branches/3.19-stable/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/3.19-stable/src/clients/web/net/sf/basedb/clients/web/extensions/list/RelatedItemColumn.java

    r8077 r8086  
    146146    if (dc != null)
    147147    {
    148       SourceItemTransformerFactory transformerFactory = ListableUtil.getTransformerFactory(spec.targetType);
     148      boolean includeChildrenThatPushToParents =  !spec.multiHop &&
     149          (spec.getTargetType() == Item.EXTRACT || spec.getTargetType() == Item.SAMPLE) &&
     150          spec.getItemSubtype(dc).getPushAnnotations();
     151      SourceItemTransformerFactory transformerFactory = ListableUtil.getTransformerFactory(spec.targetType, includeChildrenThatPushToParents);
    149152      SourceItemTransformer tmp = transformerFactory.create(spec.sourceType, spec.direction);
    150153      Restriction targetRestriction = spec.createTargetTypeRestriction(dc);
  • branches/3.19-stable/src/core/net/sf/basedb/util/listable/ExtractToChildExtractTransformer.java

    r6848 r8086  
    4747
    4848  private final boolean includeSourcesInTarget;
     49  private final boolean pushOnly;
    4950 
    5051  /**
     
    5455  public ExtractToChildExtractTransformer(boolean includeSourcesInTarget)
    5556  {
     57    this(includeSourcesInTarget, false);
     58  }
     59  /**
     60    Create a new extract to child extract transformer that only load children
     61    has a subtype with "push annotations" set.
     62    @since 3.19.5
     63  */
     64  public ExtractToChildExtractTransformer(boolean includeSourcesInTarget, boolean childrensThatPushOnly)
     65  {
    5666    super(Item.EXTRACT, Item.EXTRACT);
    5767    this.includeSourcesInTarget = includeSourcesInTarget;
     68    this.pushOnly = childrensThatPushOnly;
    5869  }
    59  
     70
    6071  @Override
    6172  public Set<Integer> transform(TransformContext context, Set<Integer> source)
     
    7586        Expressions.parameter("parents")
    7687      ));
     88    if (pushOnly)
     89    {
     90      query.join(Hql.innerJoin("itemSubtype", "st"));
     91      query.restrict(Restrictions.eq(Hql.property("st", "pushAnnotations"), Expressions.bool(true)));
     92    }
    7793
    7894    // Keep track of all seen children and parents
  • branches/3.19-stable/src/core/net/sf/basedb/util/listable/ListableUtil.java

    r6787 r8086  
    2727
    2828import net.sf.basedb.core.Item;
     29import net.sf.basedb.core.ItemSubtype;
    2930import net.sf.basedb.core.Listable;
    3031import net.sf.basedb.core.SyncFilter.SourceItemTransform;
     
    6667  public static SourceItemTransformerFactory getTransformerFactory(Item targetItemType)
    6768  {
     69    return getTransformerFactory(targetItemType, false);
     70  }
     71 
     72  /**
     73    Create a source item transformer factory that can transform items to the given
     74    target item type. If no transformer factory exists, null is returned.
     75    The 'includeChildrenThatPushToParent' parameter can be used for transforms
     76    that go from child to parent items, when the target is a SAMPLE or EXTRACT.
     77    When this flag is set, transformer will also include child items that have
     78    a subtype that have the {@link ItemSubtype#getPushAnnotations()} flag enabled
     79    in the final result.
     80   
     81    @since 3.19.5
     82  */
     83  public static SourceItemTransformerFactory getTransformerFactory(Item targetItemType, boolean includeChildrenThatPushToParent)
     84  {
    6885    SourceItemTransformerFactory factory = null;
    6986    if (targetItemType == Item.BIOSOURCE)
     
    7390    else if (targetItemType == Item.SAMPLE)
    7491    {
    75       factory = new ToSampleSourceItemTransformerFactory();
     92      factory = new ToSampleSourceItemTransformerFactory(includeChildrenThatPushToParent);
    7693    }
    7794    else if (targetItemType == Item.EXTRACT)
    7895    {
    79       factory = new ToExtractSourceItemTransformerFactory();
     96      factory = new ToExtractSourceItemTransformerFactory(includeChildrenThatPushToParent);
    8097    }
    8198    else if (targetItemType == Item.PHYSICALBIOASSAY)
  • branches/3.19-stable/src/core/net/sf/basedb/util/listable/SampleToChildSampleTransformer.java

    r6848 r8086  
    4848
    4949  private final boolean includeSourcesInTarget;
     50  private final boolean pushOnly;
    5051 
    5152  /**
     
    5556  public SampleToChildSampleTransformer(boolean includeSourcesInTarget)
    5657  {
     58    this(includeSourcesInTarget, false);
     59  }
     60  /**
     61    Create a new sample to child sample transformer that only load children that
     62    has a subtype with "push annotations" set.
     63    @since 3.19.5
     64  */
     65  public SampleToChildSampleTransformer(boolean includeSourcesInTarget, boolean childrensThatPushOnly)
     66  {
    5767    super(Item.SAMPLE, Item.SAMPLE);
    5868    this.includeSourcesInTarget = includeSourcesInTarget;
     69    this.pushOnly = childrensThatPushOnly;
    5970  }
    60  
     71
    6172  @Override
    6273  public Set<Integer> transform(TransformContext context, Set<Integer> source)
     
    7687        Expressions.parameter("parents")
    7788      ));
     89    if (pushOnly)
     90    {
     91      query.join(Hql.innerJoin("itemSubtype", "st"));
     92      query.restrict(Restrictions.eq(Hql.property("st", "pushAnnotations"), Expressions.bool(true)));
     93    }
    7894
    7995    // Keep track of all seen children and parents
  • branches/3.19-stable/src/core/net/sf/basedb/util/listable/ToBioSourceSourceItemTransformerFactory.java

    r6791 r8086  
    6868
    6969      // Use utility function to add transformation up to the extract level
    70       ToExtractSourceItemTransformerFactory.childToParentChain(chain, sourceItemType, Item.BIOSOURCE);
     70      ToExtractSourceItemTransformerFactory.childToParentChain(chain, sourceItemType, Item.BIOSOURCE, false);
    7171      if (chain.size() > 0)
    7272      {
  • branches/3.19-stable/src/core/net/sf/basedb/util/listable/ToExtractSourceItemTransformerFactory.java

    r7772 r8086  
    5050    { Item.EXTRACT, Item.PHYSICALBIOASSAY, Item.DERIVEDBIOASSAY, Item.RAWBIOASSAY };
    5151 
     52  private final boolean includeChildrenThatPushToParent;
    5253 
    5354  public ToExtractSourceItemTransformerFactory()
    5455  {
     56    this(false);
     57  }
     58 
     59  public ToExtractSourceItemTransformerFactory(boolean includeChildrenThatPushToParent)
     60  {
    5561    super(Item.EXTRACT, PARENT_TO_CHILD, CHILD_TO_PARENT);
     62    this.includeChildrenThatPushToParent = includeChildrenThatPushToParent;
    5663  }
    5764 
     
    93100    else if (transform == SourceItemTransform.CHILD_TO_PARENT)
    94101    {
    95       childToParentChain(chain, sourceItemType, Item.EXTRACT);
     102      childToParentChain(chain, sourceItemType, Item.EXTRACT, includeChildrenThatPushToParent);
    96103    }
    97104
     
    105112    DERIVEDBIOASSAY, PHYSICALBIOASSAY and EXTRACT
    106113  */
    107   static void childToParentChain(List<SourceItemTransformer> chain, Item sourceItemType, Item targetItemType)
     114  static void childToParentChain(List<SourceItemTransformer> chain, Item sourceItemType, Item targetItemType, boolean includeChildrenThatPushToParent)
    108115  {
    109116    Item stepBySource = null;
     
    146153      // Load parent extracts, maybe including the source extracts
    147154      chain.add(new ExtractToParentExtractTransformer(sourceItemType != targetItemType, collectedExtracts));
     155      // Also include child extracts that have push-to-parent flag set
     156      if (includeChildrenThatPushToParent && targetItemType == Item.EXTRACT)
     157      {
     158        chain.add(new ExtractToChildExtractTransformer(true, true));
     159      }
    148160    }
    149161   
  • branches/3.19-stable/src/core/net/sf/basedb/util/listable/ToSampleSourceItemTransformerFactory.java

    r7772 r8086  
    5151 
    5252 
     53  private final boolean includeChildrenThatPushToParent;
     54 
    5355  public ToSampleSourceItemTransformerFactory()
    5456  {
    55     super(Item.SAMPLE, PARENT_TO_CHILD, CHILD_TO_PARENT);
     57    this(false);
    5658  }
    5759 
    58  
     60  public ToSampleSourceItemTransformerFactory(boolean includeChildrenThatPushToParent)
     61  {
     62    super(Item.SAMPLE, PARENT_TO_CHILD, CHILD_TO_PARENT);
     63    this.includeChildrenThatPushToParent = includeChildrenThatPushToParent;
     64  }
     65
    5966  @Override
    6067  public SourceItemTransformer create(final Item sourceItemType, final SourceItemTransform transform)
     
    8794     
    8895      // Use utility function to add transformation up to the extract level
    89       ToExtractSourceItemTransformerFactory.childToParentChain(chain, sourceItemType, Item.SAMPLE);
     96      ToExtractSourceItemTransformerFactory.childToParentChain(chain, sourceItemType, Item.SAMPLE, false);
    9097      if (chain.size() > 0)
    9198      {
     
    99106        // Load parent samples and maybe include source samples
    100107        chain.add(new SampleToParentSampleTransformer(sourceItemType != Item.SAMPLE));
     108        // Also include child samples that have push-to-parent flag set
     109        if (includeChildrenThatPushToParent)
     110        {
     111          chain.add(new SampleToChildSampleTransformer(true, true));
     112        }
    101113      }
    102114    }
Note: See TracChangeset for help on using the changeset viewer.