Changeset 5985
- Timestamp:
- Feb 24, 2012, 11:01:01 AM (11 years ago)
- Location:
- trunk/src/core/net/sf/basedb/util/overview
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/util/overview/OverviewUtil.java
r5815 r5985 37 37 import net.sf.basedb.core.DerivedBioAssay; 38 38 import net.sf.basedb.core.Extract; 39 import net.sf.basedb.core.ItemSubtype; 39 40 import net.sf.basedb.core.PermissionDeniedException; 40 41 import net.sf.basedb.core.Presets; … … 46 47 import net.sf.basedb.core.SessionControl; 47 48 import net.sf.basedb.core.RawBioAssay; 49 import net.sf.basedb.core.Subtypable; 48 50 import net.sf.basedb.core.Type; 49 51 import net.sf.basedb.core.query.Expressions; … … 283 285 if (item.equals(node.getItem())) return node; 284 286 return node.getFirstParent(new BasicItemFilter(item)); 287 } 288 289 /** 290 Add a restriction to the query that limit the returned result to those items 291 that has a subtype with the {@link ItemSubtype#getPushAnnotations()} flag set. 292 @since 3.1 293 */ 294 public static void restrictToPushAnnotationSubtypes(ItemQuery<? extends Subtypable> query) 295 { 296 query.join(Hql.innerJoin("itemSubtype", "sbt")); 297 query.restrict(Restrictions.eq(Hql.property("sbt", "pushAnnotations"), Expressions.bool(true))); 285 298 } 286 299 -
trunk/src/core/net/sf/basedb/util/overview/loader/BioSourceLoader.java
r5663 r5985 25 25 import net.sf.basedb.core.DbControl; 26 26 import net.sf.basedb.core.Item; 27 import net.sf.basedb.core.ItemSubtype; 27 28 import net.sf.basedb.core.PermissionDeniedException; 28 29 import net.sf.basedb.core.Sample; … … 105 106 getNodeLoader(context, Item.SAMPLE).createForwardNode(dc, context, bioSourceNode); 106 107 } 108 109 /** 110 A biosource usually don't have any reverse child nodes. The exception is 111 child samples that have a subtype with the {@link ItemSubtype#getPushAnnotations()} flag set. 112 @since 3.1 113 */ 114 @Override 115 protected void loadReverseChildNodes(DbControl dc, OverviewContext context, Node bioSourceNode) 116 { 117 if (bioSourceNode.getChildNodeDirection() == ChildNodeDirection.REVERSE) 118 { 119 // Only if we are moving in the reverse direction (eg. not when the biosource is a root node) 120 getNodeLoader(context, Item.SAMPLE).createPropertyNode(dc, context, bioSourceNode); 121 } 122 } 107 123 // --------------------------------------- 108 124 -
trunk/src/core/net/sf/basedb/util/overview/loader/ExtractLoader.java
r5807 r5985 25 25 import net.sf.basedb.core.DerivedBioAssay; 26 26 import net.sf.basedb.core.Extract; 27 import net.sf.basedb.core.ItemSubtype; 27 28 import net.sf.basedb.core.PermissionDeniedException; 28 29 import net.sf.basedb.core.PhysicalBioAssay; … … 83 84 if (parentType == Item.SAMPLE) 84 85 { 85 returnNode = createForwardNode((Sample)parentNode.getItem(dc), dc, context, parentNode );86 returnNode = createForwardNode((Sample)parentNode.getItem(dc), dc, context, parentNode, false); 86 87 } 87 88 else if (parentType == Item.EXTRACT) 88 89 { 89 returnNode = createForwardNode((Extract)parentNode.getItem(dc), dc, context, parentNode );90 returnNode = createForwardNode((Extract)parentNode.getItem(dc), dc, context, parentNode, false); 90 91 } 91 92 return returnNode; … … 135 136 return returnNode; 136 137 } 138 139 /** 140 A property node is created when moving in the reverse direction so that we 141 can load child extracts+physical bioassays with the {@link ItemSubtype#getPushAnnotations()} 142 flag set. The parent node should be a sample or extract node. 143 @since 3.1 144 */ 145 @Override 146 public Node createPropertyNode(DbControl dc, OverviewContext context, Node parentNode) 147 { 148 Node returnNode = null; 149 Item parentType = parentNode.getItemType(); 150 if (parentType == Item.SAMPLE) 151 { 152 returnNode = createForwardNode((Sample)parentNode.getItem(dc), dc, context, parentNode, true); 153 } 154 else if (parentType == Item.EXTRACT) 155 { 156 returnNode = createForwardNode((Extract)parentNode.getItem(dc), dc, context, parentNode, true); 157 } 158 return returnNode; 159 } 137 160 // -------------------------------- 138 161 /* … … 175 198 176 199 /** 177 Load either the parent sample or extract(s). 200 Load either the parent sample or extract(s) and child extracts+physical bioassays 201 with a subtype that has {@link ItemSubtype#getPushAnnotations()} flag set. 178 202 @see ExtractLoader#createReverseNode(DbControl, OverviewContext, Node) 179 203 @see SampleLoader#createReverseNode(DbControl, OverviewContext, Node) … … 190 214 { 191 215 getNodeLoader(context, Item.SAMPLE).createReverseNode(dc, context, extractNode); 216 } 217 if (extractNode.getChildNodeDirection() == ChildNodeDirection.REVERSE) 218 { 219 // Only if we are moving in the reverse direction (eg. not when the extract is a root node) 220 getNodeLoader(context, Item.EXTRACT).createPropertyNode(dc, context, extractNode); 221 getNodeLoader(context, Item.PHYSICALBIOASSAY).createPropertyNode(dc, context, extractNode); 192 222 } 193 223 } … … 333 363 sample as their parent. 334 364 */ 335 private Node createForwardNode(Sample sample, DbControl dc, OverviewContext context, Node parentNode) 365 private Node createForwardNode(Sample sample, DbControl dc, OverviewContext context, Node parentNode, 366 boolean onlyPushAnnotationTypes) 336 367 { 337 368 NodeFactory<Extract> nf = getNodeFactory(dc, context); 338 369 Node folderNode = null; 339 370 ItemQuery<Extract> query = context.initQuery(sample.getExtracts(), "name"); 371 if (onlyPushAnnotationTypes) OverviewUtil.restrictToPushAnnotationSubtypes(query); 340 372 ItemResultIterator<Extract> it = query.iterate(dc); 341 373 while (it.hasNext()) … … 354 386 /** 355 387 Create forward-loading extract nodes for the (pooled) extract that has a given 356 extract among their parents. 357 */ 358 private Node createForwardNode(Extract parentExtract, DbControl dc, OverviewContext context, Node parentNode) 388 extract among their parents. If the parent node is a forward-loading node all child 389 nodes are loaded, otherwise only child nodes that have an item with a subtype that 390 has {@link ItemSubtype#getPushAnnotations()} set. 391 */ 392 private Node createForwardNode(Extract parentExtract, DbControl dc, OverviewContext context, Node parentNode, 393 boolean onlyPushAnnotationTypes) 359 394 { 360 395 NodeFactory<Extract> nf = getNodeFactory(dc, context); 361 396 Node folderNode = null; 362 397 ItemQuery<Extract> query = context.initQuery(parentExtract.getChildExtracts(), "name"); 398 if (onlyPushAnnotationTypes) OverviewUtil.restrictToPushAnnotationSubtypes(query); 363 399 ItemResultIterator<Extract> it = query.iterate(dc); 364 400 while (it.hasNext()) -
trunk/src/core/net/sf/basedb/util/overview/loader/PhysicalBioAssayLoader.java
r5748 r5985 26 26 import net.sf.basedb.core.DerivedBioAssay; 27 27 import net.sf.basedb.core.Extract; 28 import net.sf.basedb.core.ItemSubtype; 28 29 import net.sf.basedb.core.PhysicalBioAssay; 29 30 import net.sf.basedb.core.Item; … … 34 35 import net.sf.basedb.util.overview.NodeAttribute; 35 36 import net.sf.basedb.util.overview.OverviewContext; 37 import net.sf.basedb.util.overview.OverviewUtil; 36 38 import net.sf.basedb.util.overview.cache.IndexedCacheKey; 37 39 import net.sf.basedb.util.overview.filter.HasAttributeFilter; … … 84 86 if (parentType == Item.EXTRACT) 85 87 { 86 returnNode = createForwardNode((Extract)parentNode.getItem(dc), dc, context, parentNode );88 returnNode = createForwardNode((Extract)parentNode.getItem(dc), dc, context, parentNode, false); 87 89 } 88 90 else if (parentType == Item.ARRAYSLIDE) … … 128 130 return bioAssayNode; 129 131 } 132 133 /** 134 A property node is created when moving in the reverse direction so that we 135 can load child physical bioassays with the {@link ItemSubtype#getPushAnnotations()} 136 flag set. The parent node should be an extract node. 137 @since 3.1 138 */ 139 @Override 140 public Node createPropertyNode(DbControl dc, OverviewContext context, Node parentNode) 141 { 142 Node returnNode = null; 143 Item parentType = parentNode.getItemType(); 144 if (parentType == Item.EXTRACT) 145 { 146 returnNode = createForwardNode((Extract)parentNode.getItem(dc), dc, context, parentNode, true); 147 } 148 return returnNode; 149 } 130 150 // -------------------------------------- 131 151 /* … … 199 219 that has a given extract as a source. 200 220 */ 201 private Node createForwardNode(Extract extract, DbControl dc, OverviewContext context, Node parentNode) 221 private Node createForwardNode(Extract extract, DbControl dc, OverviewContext context, Node parentNode, 222 boolean onlyPushAnnotationTypes) 202 223 { 203 224 NodeFactory<PhysicalBioAssay> nf = getNodeFactory(dc, context); 204 225 Node folderNode = null; 205 226 ItemQuery<PhysicalBioAssay> query = context.initQuery(extract.getPhysicalBioAssays(), "name"); 227 if (onlyPushAnnotationTypes) OverviewUtil.restrictToPushAnnotationSubtypes(query); 206 228 ItemResultIterator<PhysicalBioAssay> it = query.iterate(dc); 207 229 while (it.hasNext()) -
trunk/src/core/net/sf/basedb/util/overview/loader/SampleLoader.java
r5807 r5985 30 30 import net.sf.basedb.core.ItemQuery; 31 31 import net.sf.basedb.core.ItemResultIterator; 32 import net.sf.basedb.core.ItemSubtype; 32 33 import net.sf.basedb.core.MeasuredBioMaterial; 33 34 import net.sf.basedb.core.PermissionDeniedException; … … 79 80 if (parentType == Item.BIOSOURCE) 80 81 { 81 returnNode = createForwardNode((BioSource)parentNode.getItem(dc), dc, context, parentNode );82 returnNode = createForwardNode((BioSource)parentNode.getItem(dc), dc, context, parentNode, false); 82 83 } 83 84 else if (parentType == Item.SAMPLE) 84 85 { 85 returnNode = createForwardNode((Sample)parentNode.getItem(dc), dc, context, parentNode );86 returnNode = createForwardNode((Sample)parentNode.getItem(dc), dc, context, parentNode, false); 86 87 } 87 88 return returnNode; … … 118 119 return returnNode; 119 120 } 121 122 /** 123 A property node is created when moving in the reverse direction so that we 124 can load child samples+extracts with the {@link ItemSubtype#getPushAnnotations()} 125 flag set. The parent node should be a biosource or sample node. 126 @since 3.1 127 */ 128 @Override 129 public Node createPropertyNode(DbControl dc, OverviewContext context, Node parentNode) 130 { 131 Node returnNode = null; 132 Item parentType = parentNode.getItemType(); 133 if (parentType == Item.BIOSOURCE) 134 { 135 returnNode = createForwardNode((BioSource)parentNode.getItem(dc), dc, context, parentNode, true); 136 } 137 else if (parentType == Item.SAMPLE) 138 { 139 returnNode = createForwardNode((Sample)parentNode.getItem(dc), dc, context, parentNode, true); 140 } 141 return returnNode; 142 } 120 143 // -------------------------------- 121 144 /* … … 153 176 /** 154 177 If the sample is a pooled sample, loads the parent samples that 155 it was pooled from. Otherwise load the parent biosource. 178 it was pooled from. Otherwise load the parent biosource. Also load 179 any child samples or extracts that have a subtype with the 180 {@link ItemSubtype#getPushAnnotations()} flag set. 156 181 @see SampleLoader#createReverseNode(DbControl, OverviewContext, Node) 157 182 @see BioSourceLoader#createReverseNode(DbControl, OverviewContext, Node) … … 168 193 { 169 194 getNodeLoader(context, Item.BIOSOURCE).createReverseNode(dc, context, sampleNode); 195 } 196 if (sampleNode.getChildNodeDirection() == ChildNodeDirection.REVERSE) 197 { 198 // Only if we are moving in the reverse direction (eg. not when the sample is a root node) 199 getNodeLoader(context, Item.SAMPLE).createPropertyNode(dc, context, sampleNode); 200 getNodeLoader(context, Item.EXTRACT).createPropertyNode(dc, context, sampleNode); 170 201 } 171 202 } … … 238 269 biosource as their parent. 239 270 */ 240 private Node createForwardNode(BioSource bioSource, DbControl dc, OverviewContext context, Node parentNode) 271 private Node createForwardNode(BioSource bioSource, DbControl dc, OverviewContext context, Node parentNode, 272 boolean onlyPushAnnotationTypes) 241 273 { 242 274 NodeFactory<Sample> nf = getNodeFactory(dc, context); 243 275 Node folderNode = null; 244 276 ItemQuery<Sample> query = context.initQuery(bioSource.getSamples(), "name"); 277 if (onlyPushAnnotationTypes) OverviewUtil.restrictToPushAnnotationSubtypes(query); 245 278 ItemResultIterator<Sample> it = query.iterate(dc); 246 279 while (it.hasNext()) … … 261 294 sample as their parent. 262 295 */ 263 private Node createForwardNode(Sample parentSample, DbControl dc, OverviewContext context, Node parentNode) 296 private Node createForwardNode(Sample parentSample, DbControl dc, OverviewContext context, Node parentNode, 297 boolean onlyPushAnnotationTypes) 264 298 { 265 299 NodeFactory<Sample> nf = getNodeFactory(dc, context); 266 300 Node folderNode = null; 267 301 ItemQuery<Sample> query = context.initQuery(parentSample.getChildSamples(), "name"); 302 if (onlyPushAnnotationTypes) OverviewUtil.restrictToPushAnnotationSubtypes(query); 268 303 ItemResultIterator<Sample> it = query.iterate(dc); 269 304 while (it.hasNext())
Note: See TracChangeset
for help on using the changeset viewer.