Changeset 8086 for branches/3.19-stable
- Timestamp:
- Oct 27, 2022, 2:13:24 PM (7 months ago)
- 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 146 146 if (dc != null) 147 147 { 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); 149 152 SourceItemTransformer tmp = transformerFactory.create(spec.sourceType, spec.direction); 150 153 Restriction targetRestriction = spec.createTargetTypeRestriction(dc); -
branches/3.19-stable/src/core/net/sf/basedb/util/listable/ExtractToChildExtractTransformer.java
r6848 r8086 47 47 48 48 private final boolean includeSourcesInTarget; 49 private final boolean pushOnly; 49 50 50 51 /** … … 54 55 public ExtractToChildExtractTransformer(boolean includeSourcesInTarget) 55 56 { 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 { 56 66 super(Item.EXTRACT, Item.EXTRACT); 57 67 this.includeSourcesInTarget = includeSourcesInTarget; 68 this.pushOnly = childrensThatPushOnly; 58 69 } 59 70 60 71 @Override 61 72 public Set<Integer> transform(TransformContext context, Set<Integer> source) … … 75 86 Expressions.parameter("parents") 76 87 )); 88 if (pushOnly) 89 { 90 query.join(Hql.innerJoin("itemSubtype", "st")); 91 query.restrict(Restrictions.eq(Hql.property("st", "pushAnnotations"), Expressions.bool(true))); 92 } 77 93 78 94 // Keep track of all seen children and parents -
branches/3.19-stable/src/core/net/sf/basedb/util/listable/ListableUtil.java
r6787 r8086 27 27 28 28 import net.sf.basedb.core.Item; 29 import net.sf.basedb.core.ItemSubtype; 29 30 import net.sf.basedb.core.Listable; 30 31 import net.sf.basedb.core.SyncFilter.SourceItemTransform; … … 66 67 public static SourceItemTransformerFactory getTransformerFactory(Item targetItemType) 67 68 { 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 { 68 85 SourceItemTransformerFactory factory = null; 69 86 if (targetItemType == Item.BIOSOURCE) … … 73 90 else if (targetItemType == Item.SAMPLE) 74 91 { 75 factory = new ToSampleSourceItemTransformerFactory( );92 factory = new ToSampleSourceItemTransformerFactory(includeChildrenThatPushToParent); 76 93 } 77 94 else if (targetItemType == Item.EXTRACT) 78 95 { 79 factory = new ToExtractSourceItemTransformerFactory( );96 factory = new ToExtractSourceItemTransformerFactory(includeChildrenThatPushToParent); 80 97 } 81 98 else if (targetItemType == Item.PHYSICALBIOASSAY) -
branches/3.19-stable/src/core/net/sf/basedb/util/listable/SampleToChildSampleTransformer.java
r6848 r8086 48 48 49 49 private final boolean includeSourcesInTarget; 50 private final boolean pushOnly; 50 51 51 52 /** … … 55 56 public SampleToChildSampleTransformer(boolean includeSourcesInTarget) 56 57 { 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 { 57 67 super(Item.SAMPLE, Item.SAMPLE); 58 68 this.includeSourcesInTarget = includeSourcesInTarget; 69 this.pushOnly = childrensThatPushOnly; 59 70 } 60 71 61 72 @Override 62 73 public Set<Integer> transform(TransformContext context, Set<Integer> source) … … 76 87 Expressions.parameter("parents") 77 88 )); 89 if (pushOnly) 90 { 91 query.join(Hql.innerJoin("itemSubtype", "st")); 92 query.restrict(Restrictions.eq(Hql.property("st", "pushAnnotations"), Expressions.bool(true))); 93 } 78 94 79 95 // Keep track of all seen children and parents -
branches/3.19-stable/src/core/net/sf/basedb/util/listable/ToBioSourceSourceItemTransformerFactory.java
r6791 r8086 68 68 69 69 // 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); 71 71 if (chain.size() > 0) 72 72 { -
branches/3.19-stable/src/core/net/sf/basedb/util/listable/ToExtractSourceItemTransformerFactory.java
r7772 r8086 50 50 { Item.EXTRACT, Item.PHYSICALBIOASSAY, Item.DERIVEDBIOASSAY, Item.RAWBIOASSAY }; 51 51 52 private final boolean includeChildrenThatPushToParent; 52 53 53 54 public ToExtractSourceItemTransformerFactory() 54 55 { 56 this(false); 57 } 58 59 public ToExtractSourceItemTransformerFactory(boolean includeChildrenThatPushToParent) 60 { 55 61 super(Item.EXTRACT, PARENT_TO_CHILD, CHILD_TO_PARENT); 62 this.includeChildrenThatPushToParent = includeChildrenThatPushToParent; 56 63 } 57 64 … … 93 100 else if (transform == SourceItemTransform.CHILD_TO_PARENT) 94 101 { 95 childToParentChain(chain, sourceItemType, Item.EXTRACT );102 childToParentChain(chain, sourceItemType, Item.EXTRACT, includeChildrenThatPushToParent); 96 103 } 97 104 … … 105 112 DERIVEDBIOASSAY, PHYSICALBIOASSAY and EXTRACT 106 113 */ 107 static void childToParentChain(List<SourceItemTransformer> chain, Item sourceItemType, Item targetItemType )114 static void childToParentChain(List<SourceItemTransformer> chain, Item sourceItemType, Item targetItemType, boolean includeChildrenThatPushToParent) 108 115 { 109 116 Item stepBySource = null; … … 146 153 // Load parent extracts, maybe including the source extracts 147 154 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 } 148 160 } 149 161 -
branches/3.19-stable/src/core/net/sf/basedb/util/listable/ToSampleSourceItemTransformerFactory.java
r7772 r8086 51 51 52 52 53 private final boolean includeChildrenThatPushToParent; 54 53 55 public ToSampleSourceItemTransformerFactory() 54 56 { 55 super(Item.SAMPLE, PARENT_TO_CHILD, CHILD_TO_PARENT);57 this(false); 56 58 } 57 59 58 60 public ToSampleSourceItemTransformerFactory(boolean includeChildrenThatPushToParent) 61 { 62 super(Item.SAMPLE, PARENT_TO_CHILD, CHILD_TO_PARENT); 63 this.includeChildrenThatPushToParent = includeChildrenThatPushToParent; 64 } 65 59 66 @Override 60 67 public SourceItemTransformer create(final Item sourceItemType, final SourceItemTransform transform) … … 87 94 88 95 // 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); 90 97 if (chain.size() > 0) 91 98 { … … 99 106 // Load parent samples and maybe include source samples 100 107 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 } 101 113 } 102 114 }
Note: See TracChangeset
for help on using the changeset viewer.