Changeset 5131
- Timestamp:
- Oct 14, 2009, 9:44:14 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/snapshot/AnnotationSnapshot.java
r5124 r5131 36 36 import net.sf.basedb.core.data.AnnotationData; 37 37 import net.sf.basedb.core.data.AnnotationSetData; 38 import net.sf.basedb.util.filter.Filter; 38 39 import net.sf.basedb.util.units.UnitConverter; 39 40 … … 197 198 Get the annotation values. NOTE! The values are only available 198 199 for primary annotations and for inherited annotations returned by 199 {@link SnapshotManager#findAnnotations(DbControl, AnnotationSetSnapshot, AnnotationType, boolean)}200 {@link SnapshotManager#findAnnotations(DbControl, AnnotationSetSnapshot, Filter, boolean)} 200 201 201 202 @return A list with the values … … 233 234 Get the id of the item this annotation belongs to. NOTE! this value 234 235 is only available on annotations returned from the call to: 235 {@link SnapshotManager#findAnnotations(DbControl, AnnotationSetSnapshot, AnnotationType, boolean)}236 {@link SnapshotManager#findAnnotations(DbControl, AnnotationSetSnapshot, Filter, boolean)} 236 237 */ 237 238 public int getItemId() … … 252 253 Get the item type of the item this annotation belongs to. 253 254 NOTE! this value is only available on annotations returned from the call to: 254 {@link SnapshotManager#findAnnotations(DbControl, AnnotationSetSnapshot, AnnotationType, boolean)}255 {@link SnapshotManager#findAnnotations(DbControl, AnnotationSetSnapshot, Filter, boolean)} 255 256 256 257 @return The item type, or null if not known -
trunk/src/core/net/sf/basedb/core/snapshot/SnapshotManager.java
r5130 r5131 30 30 import net.sf.basedb.core.Annotatable; 31 31 import net.sf.basedb.core.AnnotationSet; 32 import net.sf.basedb.core.AnnotationType;33 32 import net.sf.basedb.core.Application; 34 33 import net.sf.basedb.core.DbControl; 35 34 import net.sf.basedb.util.StaticCache; 35 import net.sf.basedb.util.filter.Filter; 36 import net.sf.basedb.util.filter.StaticFilter; 36 37 37 38 /** … … 110 111 } 111 112 113 112 114 /** 113 115 Search in a snapshot for all annotations of a specified annotation type. … … 118 120 exists for an inherited annotation set 119 121 @param snapshot The snapshot to search 120 @param at The annotation type to look for, or null to return121 annotations of any type122 @param filter A filter that should match the wanted annotation snapshots 123 or null to match all annotations 122 124 @param searchInherited TRUE if inherited annotations should be searched, 123 125 FALSE to only search primary annotations … … 125 127 */ 126 128 public List<AnnotationSnapshot> findAnnotations(DbControl dc, AnnotationSetSnapshot snapshot, 127 AnnotationType at, boolean searchInherited)129 Filter<? super AnnotationSnapshot> filter, boolean searchInherited) 128 130 { 129 131 List<AnnotationSnapshot> result = new ArrayList<AnnotationSnapshot>(); 130 i nt id = at == null ? 0 : at.getId();132 if (filter == null) filter = new StaticFilter<AnnotationSnapshot>(true); 131 133 for (AnnotationSnapshot shot : snapshot.getAnnotations()) 132 134 { … … 134 136 { 135 137 if (!searchInherited) continue; // with the next snapshot in the list 136 // Is this a specific inherited annotation or a complete annotation set? 137 if (shot.getAnnotationTypeId() == id || shot.getAnnotationId() == 0) 138 139 // If this is an inherited annotation set or if it matches the filter we 140 // must recursively load the inherited annotations 141 if (shot.getAnnotationId() == 0 || filter.evaluate(shot)) 138 142 { 139 // Load the snapshot for the inherited annotation set and search the140 // primary annotations only141 143 AnnotationSetSnapshot recursive = getSnapshot(dc, shot.getAnnotationSetId()); 142 144 if (recursive != null) 143 145 { 144 for (AnnotationSnapshot primary : findAnnotations(dc, recursive, at, false))146 for (AnnotationSnapshot primary : findAnnotations(dc, recursive, filter, false)) 145 147 { 146 148 AnnotationSnapshot copy = new AnnotationSnapshot(); … … 154 156 { 155 157 // Primary annotation 156 if ( shot.getAnnotationTypeId() == id || id == 0)158 if (filter.evaluate(shot)) 157 159 { 158 160 shot.setItem(snapshot.getItemId(), snapshot.getItemType()); … … 170 172 item doesn't have any annotations) 171 173 @see #getSnapshot(DbControl, int) 172 @see #findAnnotations(DbControl, AnnotationSetSnapshot, AnnotationType, boolean)174 @see #findAnnotations(DbControl, AnnotationSetSnapshot, Filter, boolean) 173 175 */ 174 176 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 } 177 Filter<? super AnnotationSnapshot> filter, boolean searchInherited) 178 { 179 if (!item.isAnnotated()) return Collections.emptyList(); 180 AnnotationSetSnapshot snapshot = getSnapshot(dc, item.getAnnotationSet().getId()); 181 return findAnnotations(dc, snapshot, filter, searchInherited); 182 } 183 181 184 } -
trunk/src/core/net/sf/basedb/util/BioAssaySetUtil.java
r5130 r5131 36 36 import net.sf.basedb.core.query.Restriction; 37 37 import net.sf.basedb.core.snapshot.AnnotationSnapshot; 38 import net.sf.basedb.core.snapshot.AnnotationTypeFilter; 38 39 import net.sf.basedb.core.snapshot.SnapshotManager; 40 import net.sf.basedb.util.filter.Filter; 39 41 import net.sf.basedb.util.jep.ChannelFunction; 40 42 import net.sf.basedb.util.jep.ExtraValueFunction; … … 109 111 Set<Object> allValues = new TreeSet<Object>(); 110 112 if (snapshotManager == null) snapshotManager = new SnapshotManager(); 111 for (AnnotationSnapshot a : snapshotManager.findAnnotations(dc, bioAssay, annotationType, true)) 113 Filter<AnnotationSnapshot> filter = new AnnotationTypeFilter(annotationType); 114 for (AnnotationSnapshot a : snapshotManager.findAnnotations(dc, bioAssay, filter, true)) 112 115 { 113 116 if (a != null) allValues.addAll(a.getValues()); … … 117 120 for (RawBioAssay rb : rbaQuery.list(dc)) 118 121 { 119 for (AnnotationSnapshot a : snapshotManager.findAnnotations(dc, rb, annotationType, true))122 for (AnnotationSnapshot a : snapshotManager.findAnnotations(dc, rb, filter, true)) 120 123 { 121 124 if (a != null) allValues.addAll(a.getValues()); -
trunk/www/views/experiments/view_experiment.jsp
r5128 r5131 60 60 import="net.sf.basedb.core.snapshot.AnnotationSetSnapshot" 61 61 import="net.sf.basedb.core.snapshot.AnnotationSnapshot" 62 import="net.sf.basedb.core.snapshot.AnnotationTypeFilter" 62 63 import="net.sf.basedb.util.formatter.Formatter" 63 64 import="net.sf.basedb.clients.web.formatter.FormatterFactory" … … 532 533 } 533 534 %> 534 535 535 <% 536 536 ItemQuery<RawBioAssay> rbaQuery = experiment.getRawBioAssays(); … … 579 579 } 580 580 %> 581 582 581 <tbl:data> 583 582 <tbl:columns> … … 586 585 <% 587 586 SnapshotManager manager = new SnapshotManager(); 587 AnnotationTypeFilter annotationTypeFilter = new AnnotationTypeFilter(); 588 588 for (RawBioAssay item : rawBioAssays) 589 589 { 590 //System.out.println("processing rba: " + item);591 590 AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null; 592 //System.out.println("got annotation set: " + as);593 591 AnnotationSetSnapshot snapshot = as == null ? null : manager.getSnapshot(dc, as.getId()); 594 //System.out.println("got snapshot: " + snapshot);595 592 %> 596 593 <tbl:row> … … 608 605 609 606 String value = "<i>- none -</i>"; 610 //System.out.println("load annotations: " +at);607 annotationTypeFilter.setAnnotationType(at); 611 608 List<AnnotationSnapshot> all = snapshot == null ? 612 null : manager.findAnnotations(dc, snapshot, at, true); 613 //System.out.println("loaded annotations: " + at); 609 null : manager.findAnnotations(dc, snapshot, annotationTypeFilter, true); 614 610 Map<Annotatable, List> factorValues = new HashMap<Annotatable, List>(); 615 611 if (all != null && all.size() > 0) … … 623 619 try 624 620 { 625 //System.out.println("load item: "+ a.getItemType() + a.getItemId());626 621 aItem = a.getItem(dc); 627 //System.out.println("loaded item: "+ a.getItemType() + a.getItemId());628 622 } 629 623 catch (Throwable t) … … 638 632 } 639 633 } 640 641 634 %> 642 635 <tbl:cell column="<%="at"+at.getId()%>"
Note: See TracChangeset
for help on using the changeset viewer.