Changeset 5130
- Timestamp:
- Oct 13, 2009, 12:44:33 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/clients/web/net/sf/basedb/clients/web/ExperimentExplorer.java
r5114 r5130 76 76 import net.sf.basedb.core.query.Selects; 77 77 import net.sf.basedb.core.query.SqlResult; 78 import net.sf.basedb.core.snapshot.SnapshotManager; 78 79 import net.sf.basedb.util.BioAssaySetUtil; 79 80 import net.sf.basedb.util.formatter.Formatter; … … 191 192 192 193 /** 194 The snapshot manager that loads annotation values. 195 */ 196 private final SnapshotManager snapshotManager; 197 198 /** 193 199 Maps a bioassays cube column number to it's id for fast 194 200 loading by the {@link #getBioAssay(DbControl, short)} method. … … 237 243 this.bioAssaySet = bioAssaySet; 238 244 this.bioAssays = new HashMap<Short, Integer>(); 245 this.snapshotManager = new SnapshotManager(); 239 246 this.summaryCache = new HashMap<AnnotationType, AnnotationSummary>(); 240 247 for (BioAssay ba : bioAssaySet.getBioAssays().list(bioAssaySet.getDbControl())) … … 254 261 return BioAssaySet.getById(dc, bioAssaySet.getId()); 255 262 } 263 264 /** 265 Get the snapshot manager that is used to load annotation 266 values. 267 @since 2.14 268 */ 269 public SnapshotManager getSnapshotManager() 270 { 271 return snapshotManager; 272 } 256 273 257 274 /** … … 1031 1048 for (BioAssay ba : bioAssaySet.getBioAssays().list(dc)) 1032 1049 { 1033 Set<?> annotationValues = BioAssaySetUtil.getAnnotationValues(dc, ba, annotationType);1050 Set<?> annotationValues = BioAssaySetUtil.getAnnotationValues(dc, explorer.getSnapshotManager(), ba, annotationType); 1034 1051 AnnotationGroup group = temp.get(annotationValues); 1035 1052 if (group == null) -
trunk/src/clients/web/net/sf/basedb/clients/web/plugins/BioAssayExperimentalFactorLoader.java
r4978 r5130 24 24 import net.sf.basedb.core.BioAssay; 25 25 import net.sf.basedb.core.DbControl; 26 import net.sf.basedb.core.snapshot.SnapshotManager; 26 27 import net.sf.basedb.util.BioAssaySetUtil; 27 28 … … 30 31 those that are present on the parent raw bioassay(s) without being 31 32 directly inherited by the bioassay. See 32 {@link BioAssaySetUtil#getAnnotationValues(DbControl, BioAssay, net.sf.basedb.core.AnnotationType)}33 {@link BioAssaySetUtil#getAnnotationValues(DbControl, SnapshotManager, BioAssay, net.sf.basedb.core.AnnotationType)} 33 34 34 35 @author Nicklas … … 40 41 { 41 42 43 private final SnapshotManager snapshotManager; 42 44 public BioAssayExperimentalFactorLoader() 43 {} 45 { 46 this.snapshotManager = new SnapshotManager(); 47 } 48 49 /** 50 Creates an experimental factor loader that uses a specific snapshot manager 51 for loading the annotation values. 52 @since 2.14 53 */ 54 public BioAssayExperimentalFactorLoader(SnapshotManager snapshotManager) 55 { 56 this.snapshotManager = snapshotManager; 57 } 44 58 45 59 @Override … … 47 61 { 48 62 DbControl dc = item.getDbControl(); 49 return BioAssaySetUtil.getAnnotationValues(dc, item, exportedProperty.annotationType);63 return BioAssaySetUtil.getAnnotationValues(dc, snapshotManager, item, exportedProperty.annotationType); 50 64 } 51 65 -
trunk/src/clients/web/net/sf/basedb/clients/web/servlet/PlotServlet.java
r5114 r5130 45 45 import net.sf.basedb.core.query.SqlResultIterator; 46 46 import net.sf.basedb.core.query.WhenStatement; 47 import net.sf.basedb.core.snapshot.SnapshotManager; 47 48 import net.sf.basedb.clients.web.formatter.FormatterFactory; 48 49 import net.sf.basedb.clients.web.util.HTML; … … 448 449 Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType()); 449 450 if (at.supportUnits()) formatter = at.getDefaultUnit().getFormatter(formatter); 451 SnapshotManager snapshotManager = new SnapshotManager(); 450 452 for (BioAssay bioAssay : bioAssays) 451 453 { 452 Set<?> values = BioAssaySetUtil.getAnnotationValues(dc, bioAssay, at);454 Set<?> values = BioAssaySetUtil.getAnnotationValues(dc, snapshotManager, bioAssay, at); 453 455 if (!groups.containsKey(values)) 454 456 { -
trunk/src/core/net/sf/basedb/core/snapshot/SnapshotManager.java
r5123 r5130 23 23 24 24 import java.util.ArrayList; 25 import java.util.Collections; 25 26 import java.util.HashMap; 26 27 import java.util.List; 27 28 import java.util.Map; 28 29 30 import net.sf.basedb.core.Annotatable; 29 31 import net.sf.basedb.core.AnnotationSet; 30 32 import net.sf.basedb.core.AnnotationType; … … 162 164 } 163 165 166 /** 167 Utility method for calling <code>getSnapshot</code> and <code>findAnnotations</code> 168 in one go. 169 @return A list with the annotation snapshots (an empty list is returned if the 170 item doesn't have any annotations) 171 @see #getSnapshot(DbControl, int) 172 @see #findAnnotations(DbControl, AnnotationSetSnapshot, AnnotationType, boolean) 173 */ 174 public List<AnnotationSnapshot> findAnnotations(DbControl dc, Annotatable item, 175 AnnotationType at, boolean searchInherited) 176 { 177 if (!item.isAnnotated()) return Collections.emptyList(); 178 AnnotationSetSnapshot snapshot = getSnapshot(dc, item.getAnnotationSet().getId()); 179 return findAnnotations(dc, snapshot, at, searchInherited); 180 } 164 181 } -
trunk/src/core/net/sf/basedb/util/BioAssaySetUtil.java
r4912 r5130 22 22 package net.sf.basedb.util; 23 23 24 import net.sf.basedb.core.Annotation;25 24 import net.sf.basedb.core.AnnotationType; 26 25 import net.sf.basedb.core.BaseException; … … 36 35 import net.sf.basedb.core.query.Expression; 37 36 import net.sf.basedb.core.query.Restriction; 37 import net.sf.basedb.core.snapshot.AnnotationSnapshot; 38 import net.sf.basedb.core.snapshot.SnapshotManager; 38 39 import net.sf.basedb.util.jep.ChannelFunction; 39 40 import net.sf.basedb.util.jep.ExtraValueFunction; … … 47 48 import net.sf.basedb.util.jep.ScoreFunction; 48 49 49 import java.util.List;50 50 import java.util.Set; 51 51 import java.util.TreeSet; … … 75 75 @param annotationType The annotation type of the annotations 76 76 @return A set containing all values 77 @deprecated In BASE 2.14 due to performance problems, use 78 {@link #getAnnotationValues(DbControl, SnapshotManager, BioAssay, AnnotationType)} 79 instead 77 80 */ 78 81 public static Set<?> getAnnotationValues(DbControl dc, BioAssay bioAssay, AnnotationType annotationType) 79 82 { 83 return getAnnotationValues(dc, new SnapshotManager(), bioAssay, annotationType); 84 } 85 86 /** 87 Find the annotation values for a given annotation type on a bioassay. 88 This method will only check annotations, primary and inherited, on the 89 raw bioassays that the bioassay is a child of. 90 <p> 91 Since a bioassay may 92 have more than one parent raw bioassay and each annotation may have 93 multiple values it is possible that the set contains multiple values. 94 Each value is only present once regardless of how many times it appears 95 in the annotations. 96 97 @param dc The DbControl for database access 98 @param snapshotManager A snapshot manager that is used for loading the annotations 99 from either the database or the file cache (if null, an internal, non-reusable 100 snapshot manager is used) 101 @param bioAssay The bioassay to get the annotations for 102 @param annotationType The annotation type of the annotations 103 @return A set containing all values 104 @since 2.14 105 */ 106 public static Set<?> getAnnotationValues(DbControl dc, SnapshotManager snapshotManager, 107 BioAssay bioAssay, AnnotationType annotationType) 108 { 109 Set<Object> allValues = new TreeSet<Object>(); 110 if (snapshotManager == null) snapshotManager = new SnapshotManager(); 111 for (AnnotationSnapshot a : snapshotManager.findAnnotations(dc, bioAssay, annotationType, true)) 112 { 113 if (a != null) allValues.addAll(a.getValues()); 114 } 80 115 ItemQuery<RawBioAssay> rbaQuery = bioAssay.getRawBioAssays(); 81 116 rbaQuery.include(Include.MINE, Include.SHARED, Include.IN_PROJECT, Include.OTHERS); 82 Set<Object> allValues = new TreeSet<Object>(); 83 if (bioAssay.isAnnotated()) 117 for (RawBioAssay rb : rbaQuery.list(dc)) 84 118 { 85 List<Annotation> all = bioAssay.getAnnotationSet().findAnnotations(dc, annotationType, true); 86 for (Annotation a : all) 119 for (AnnotationSnapshot a : snapshotManager.findAnnotations(dc, rb, annotationType, true)) 87 120 { 88 121 if (a != null) allValues.addAll(a.getValues()); 89 122 } 90 123 } 91 for (RawBioAssay rb : rbaQuery.list(dc))92 {93 if (rb.isAnnotated())94 {95 List<Annotation> all = rb.getAnnotationSet().findAnnotations(dc, annotationType, true);96 for (Annotation a : all)97 {98 if (a != null) allValues.addAll(a.getValues());99 }100 }101 }102 124 return allValues; 103 125 } 104 126 127 105 128 /** 106 129 Find the values of parent properties for a given bioassay. This method -
trunk/src/core/net/sf/basedb/util/export/spotdata/AbstractBioAssaySetExporter.java
r4926 r5130 52 52 import net.sf.basedb.core.query.SqlResult; 53 53 import net.sf.basedb.core.signal.SignalException; 54 import net.sf.basedb.core.snapshot.SnapshotManager; 54 55 import net.sf.basedb.util.formatter.Formatter; 55 56 import net.sf.basedb.util.formatter.ToStringFormatter; … … 100 101 private BioAssaySet source; 101 102 private DbControl dc; 103 private SnapshotManager snapshotManager; 102 104 private ProgressReporter progress; 103 105 … … 136 138 { 137 139 return dc; 140 } 141 142 /** 143 Set's the snapshot manager that should be used to load annotation values. 144 If no snapshot manager is provided an internal, temporary one is used. 145 @since 2.14 146 */ 147 public void setSnapshotManager(SnapshotManager snapshotManager) 148 { 149 this.snapshotManager = snapshotManager; 150 } 151 152 /** 153 Get the current snapshot manager. 154 @since 2.14 155 */ 156 public SnapshotManager getSnapshotManager() 157 { 158 return snapshotManager; 138 159 } 139 160 … … 393 414 Experiment exp = BioAssaySet.getById(dc, source.getId()).getExperiment(); 394 415 416 SnapshotManager sm = getSnapshotManager(); 417 if (sm == null) sm = new SnapshotManager(); 418 395 419 // Load the experimental factors and register them 396 420 ItemQuery<AnnotationType> query = exp.getExperimentalFactors(); … … 401 425 AnnotationAssayField af = new AnnotationAssayField(); 402 426 af.setAnnotationType(at); 427 af.setSnapshotManager(sm); 403 428 addAssayField(af); 404 429 } -
trunk/src/core/net/sf/basedb/util/export/spotdata/AnnotationAssayField.java
r4925 r5130 27 27 import net.sf.basedb.core.BioAssay; 28 28 import net.sf.basedb.core.DbControl; 29 import net.sf.basedb.core.snapshot.SnapshotManager; 29 30 import net.sf.basedb.util.BioAssaySetUtil; 30 31 import net.sf.basedb.util.formatter.Formatter; … … 44 45 private AnnotationType at; 45 46 private Formatter<?> formatter; 47 private SnapshotManager snapshotManager; 46 48 47 49 /** … … 72 74 public Collection<?> getAssayValue(DbControl dc, BioAssay ba) 73 75 { 74 return at == null ? null : BioAssaySetUtil.getAnnotationValues(dc, ba, at);76 return at == null ? null : BioAssaySetUtil.getAnnotationValues(dc, snapshotManager, ba, at); 75 77 } 76 78 … … 105 107 this.formatter = formatter; 106 108 } 109 110 /** 111 Set the snapshot manager that should be used to load annotation values. 112 @since 2.14 113 */ 114 public void setSnapshotManager(SnapshotManager snapshotManager) 115 { 116 this.snapshotManager = snapshotManager; 117 } 107 118 108 119 } -
trunk/www/views/experiments/bioassays/index.jsp
r5060 r5130 45 45 import="net.sf.basedb.core.PermissionDeniedException" 46 46 import="net.sf.basedb.core.ItemAlreadyExistsException" 47 import="net.sf.basedb.core.snapshot.SnapshotManager" 47 48 import="net.sf.basedb.util.RemovableUtil" 48 49 import="net.sf.basedb.util.ShareableUtil" … … 65 66 66 67 private static void registerExportFormatters(ItemContext cc, List<AnnotationType> experimentalFactors) 67 { 68 { 69 SnapshotManager snapshotManager = new SnapshotManager(); 68 70 for (AnnotationType at : experimentalFactors) 69 71 { 70 cc.setObject("export.dataloader.#" + at.getId(), new BioAssayExperimentalFactorLoader( ));72 cc.setObject("export.dataloader.#" + at.getId(), new BioAssayExperimentalFactorLoader(snapshotManager)); 71 73 } 72 74 }%> -
trunk/www/views/experiments/bioassays/list_bioassays.jsp
r4978 r5130 51 51 import="net.sf.basedb.core.plugin.GuiContext" 52 52 import="net.sf.basedb.core.plugin.Plugin" 53 import="net.sf.basedb.core.snapshot.SnapshotManager" 53 54 import="net.sf.basedb.util.Tree" 54 55 import="net.sf.basedb.util.Enumeration" … … 119 120 annotationTypes = annotationTypeQuery.list(dc); 120 121 experimentalFactors = experimentalFactorQuery.list(dc); 122 final SnapshotManager snapshotManager = new SnapshotManager(); 121 123 try 122 124 { … … 572 574 <tbl:cell column="<%="ef"+at.getId()%>" 573 575 ><tbl:cellvalue 574 list="<%=BioAssaySetUtil.getAnnotationValues(dc, item, at)%>"576 list="<%=BioAssaySetUtil.getAnnotationValues(dc, snapshotManager, item, at)%>" 575 577 /></tbl:cell> 576 578 <%
Note: See TracChangeset
for help on using the changeset viewer.