Changeset 6456
- Timestamp:
- May 9, 2014, 11:21:36 AM (9 years ago)
- Location:
- trunk/src/core/net/sf/basedb
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/MeasuredBioMaterial.java
r6357 r6456 24 24 package net.sf.basedb.core; 25 25 26 import java.util.Collection; 26 27 import java.util.Collections; 27 28 import java.util.Date; 29 import java.util.HashSet; 28 30 import java.util.Map; 29 31 import java.util.Set; … … 36 38 import net.sf.basedb.core.log.ChangeType; 37 39 import net.sf.basedb.core.log.LoggingInterceptor; 40 import net.sf.basedb.core.query.Expressions; 41 import net.sf.basedb.core.query.Hql; 42 import net.sf.basedb.core.query.Restrictions; 38 43 import net.sf.basedb.util.EqualsHelper; 44 import net.sf.basedb.util.collections.BasicItemToIdTransformer; 39 45 40 46 /** … … 189 195 throws BaseException 190 196 { 197 return getAnnotatableParents(null); 198 } 199 // ------------------------------------------- 200 201 /** 202 Get the annotable parents, possible only a given set of specific parents items. 203 @param parents If not null or empty, only include the given parent items (for pooled items only) 204 @since 3.3 205 */ 206 public Set<Annotatable> getAnnotatableParents(Collection<? extends MeasuredBioMaterial> parents) 207 throws BaseException 208 { 191 209 Set<Annotatable> annotatable = super.getAnnotatableParents(); 192 210 try … … 200 218 ItemQuery<? extends BioMaterial> query = getCreationEvent().getSources(); 201 219 query.include(Include.ALL); 220 if (parents != null && parents.size() > 0) 221 { 222 query.restrict(Restrictions.in(Hql.property("id"), Expressions.parameter("parents"))); 223 Set<Integer> parentIds = new HashSet<Integer>(); 224 new BasicItemToIdTransformer().transform(parents, parentIds); 225 query.setParameter("parents", parentIds, Type.INT); 226 } 202 227 annotatable.addAll(query.list(getDbControl())); 203 228 } … … 211 236 return annotatable; 212 237 } 213 // ------------------------------------------- 214 215 238 216 239 /* 217 240 From the Subtypable interface -
trunk/src/core/net/sf/basedb/util/AnnotationUtil.java
r6124 r6456 39 39 import net.sf.basedb.core.PhysicalBioAssay; 40 40 import net.sf.basedb.core.RawBioAssay; 41 import net.sf.basedb.util.biomaterial.ChildrenTransformer; 42 import net.sf.basedb.util.extensions.events.AllEventsFilter; 41 43 import net.sf.basedb.util.filter.Filter; 42 44 … … 115 117 { 116 118 // ...and queue the parents items for processing... 117 unprocessed.addAll(toProcess.getAnnotatableParentWrappers( ));119 unprocessed.addAll(toProcess.getAnnotatableParentWrappers(dc)); 118 120 } 119 121 } … … 170 172 private final Annotatable item; 171 173 private final Set<Extract> extractsInChain; 174 private Set<Extract> allChildExtractsInChain; 172 175 private final AnnotatableWrapper chain; 173 176 private final Cache cache; … … 181 184 this.extract = getExtract(item); 182 185 this.extractsInChain = loadExtracts(); 186 this.allChildExtractsInChain = null; 183 187 } 184 188 … … 190 194 this.extract = getExtract(item); 191 195 this.extractsInChain = loadExtracts(); 196 this.allChildExtractsInChain = chain.allChildExtractsInChain; 192 197 } 193 198 … … 233 238 Get all annotatable parents wrapped inside AnnotatableWrapper:s 234 239 */ 235 Set<AnnotatableWrapper> getAnnotatableParentWrappers( )240 Set<AnnotatableWrapper> getAnnotatableParentWrappers(DbControl dc) 236 241 throws BaseException 237 242 { … … 247 252 if (item instanceof PhysicalBioAssay) 248 253 { 249 parents = ((PhysicalBioAssay)item).getAnnotatableParents(0, extractsInChain); 254 allChildExtractsInChain = new HashSet<Extract>(); 255 if (extractsInChain.size() > 0) 256 { 257 // Only load parents that eventually lead up to one of the extracts in the chain 258 ChildrenTransformer<Extract> transformer = new ChildrenTransformer<Extract>(dc, true, Extract.getQuery()); 259 transformer.transform(extractsInChain, allChildExtractsInChain); 260 } 261 parents = ((PhysicalBioAssay)item).getAnnotatableParents(0, allChildExtractsInChain); 262 } 263 else if (item instanceof Extract) 264 { 265 if (extractsInChain.contains(item)) 266 { 267 // When we have reached one of the items in the chain, we no longed need to restrict the loading of parent items 268 allChildExtractsInChain = null; 269 } 270 parents = ((Extract)item).getAnnotatableParents(allChildExtractsInChain); 250 271 } 251 272 else
Note: See TracChangeset
for help on using the changeset viewer.