Changeset 5132
- Timestamp:
- Oct 14, 2009, 1:55:03 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/snapshot/AnnotationFilter.java
r5131 r5132 67 67 @param a A specific annotation, or null to match any annotation 68 68 */ 69 public void setAnnotation Type(Annotation a)69 public void setAnnotation(Annotation a) 70 70 { 71 71 this.annotationId = a == null ? 0 : a.getId(); -
trunk/src/core/net/sf/basedb/util/overview/GenericOverview.java
r5076 r5132 35 35 import net.sf.basedb.core.query.Order; 36 36 import net.sf.basedb.core.query.Orders; 37 import net.sf.basedb.core.snapshot.SnapshotManager; 37 38 import net.sf.basedb.util.overview.cache.NodeCache; 38 39 import net.sf.basedb.util.overview.loader.NodeLoader; … … 92 93 private final Project project; 93 94 private final BasicItem rootItem; 95 private final SnapshotManager snapshotManager; 94 96 private Node rootNode; 95 97 private Map<String, Node> allNodes; … … 114 116 this.rootItem = rootItem; 115 117 this.project = project; 118 this.snapshotManager = new SnapshotManager(); 116 119 reset(dc); 117 120 } … … 137 140 { 138 141 return nodeValidatorFactory; 142 } 143 144 /** 145 Get the current snapshot manager. 146 @since 2.14 147 */ 148 @Override 149 public SnapshotManager getSnapshotManager() 150 { 151 return snapshotManager; 139 152 } 140 153 -
trunk/src/core/net/sf/basedb/util/overview/Node.java
r4789 r5132 22 22 package net.sf.basedb.util.overview; 23 23 24 import java.util.Collections; 25 import java.util.Comparator; 24 26 import java.util.LinkedList; 25 27 import java.util.List; … … 51 53 */ 52 54 public class Node 55 implements Comparable<Node> 53 56 { 54 57 private final String name; … … 310 313 311 314 /** 315 Sorts the list of child nodes. 316 @param comparator A comparator that determines the sort order, 317 if not specifed, they children are sorted according to their 318 title 319 @since 2.14 320 */ 321 public void sortChildren(Comparator<? super Node> comparator) 322 { 323 if (children == null) return; 324 Collections.sort(children, comparator); 325 } 326 327 /** 312 328 Sets a flag to indicate that all children has been loaded. 313 329 @since 2.10 … … 495 511 } 496 512 513 @Override 514 public int compareTo(Node o) 515 { 516 return title.compareTo(o.title); 517 } 518 519 497 520 public String toString() 498 521 { -
trunk/src/core/net/sf/basedb/util/overview/OverviewContext.java
r5076 r5132 27 27 import net.sf.basedb.core.Project; 28 28 import net.sf.basedb.core.query.Order; 29 import net.sf.basedb.core.snapshot.SnapshotManager; 29 30 import net.sf.basedb.util.overview.cache.NodeCache; 30 31 import net.sf.basedb.util.overview.loader.NodeLoader; … … 60 61 public NodeValidatorFactory getNodeValidatorFactory(); 61 62 63 /** 64 Get the snapshot manager that is used to load annotation 65 values. 66 @since 2.14 67 */ 68 public SnapshotManager getSnapshotManager(); 69 62 70 /** 63 71 Get the project the overview is using as the "current" project. -
trunk/src/core/net/sf/basedb/util/overview/loader/AnnotationLoader.java
r5014 r5132 22 22 package net.sf.basedb.util.overview.loader; 23 23 24 import java.util.List; 25 24 26 import net.sf.basedb.core.Annotatable; 25 27 import net.sf.basedb.core.Annotation; … … 27 29 import net.sf.basedb.core.DbControl; 28 30 import net.sf.basedb.core.Item; 29 import net.sf.basedb.core.ItemQuery;30 import net.sf.basedb.core.ItemResultIterator;31 31 import net.sf.basedb.core.PermissionDeniedException; 32 32 import net.sf.basedb.core.Protocol; 33 import net.sf.basedb.core. query.Hql;34 import net.sf.basedb.core. query.Orders;33 import net.sf.basedb.core.snapshot.AnnotationSnapshot; 34 import net.sf.basedb.core.snapshot.SnapshotManager; 35 35 import net.sf.basedb.util.overview.OverviewContext; 36 36 import net.sf.basedb.util.overview.node.AnnotationNameGenerator; … … 82 82 folderNode = new Node("annotations", "Annotations", parentNode, ChildNodeDirection.NONE); 83 83 AnnotationSet as = parent.getAnnotationSet(); 84 85 // Primary annotations 86 ItemQuery<Annotation> query = context.initQuery(as.getAnnotations(), "annotationType.name"); 87 ItemResultIterator<Annotation> it = query.iterate(dc); 88 while (it.hasNext()) 84 SnapshotManager snapshotManager = context.getSnapshotManager(); 85 86 List<AnnotationSnapshot> all = snapshotManager.findAnnotations(dc, parent, null, true); 87 for (AnnotationSnapshot a : all) 89 88 { 90 Annotation a = it.next(); 91 89 Annotation ann = a.getAnnotation(dc); 92 90 // Annotations that are protocol parameters are handled by ProtocolParameterLoader 93 if ( protocol != null && protocol.isParameter(a))91 if (!a.isInherited() && protocol != null && protocol.isParameter(ann)) 94 92 { 95 93 /* #### CONTINUE-STATEMENT #### */ 96 94 continue; 97 95 } 98 createItemNode(nf, a , null, false, folderNode, ChildNodeDirection.NONE);96 createItemNode(nf, ann, null, false, folderNode, ChildNodeDirection.NONE); 99 97 } 100 101 // Inherited annotations 102 query = context.initQuery(as.getAllInheritedAnnotations(), 103 Orders.asc(Hql.property("at", "name"))); 104 query.join(Hql.innerJoin(null, "annotationType", "at", true)); 105 it = query.iterate(dc); 106 while (it.hasNext()) 107 { 108 Annotation a = it.next(); 109 createItemNode(nf, a, null, false, folderNode, ChildNodeDirection.NONE); 110 } 98 folderNode.sortChildren(null); 111 99 } 112 100 postValidateFolder(nf, folderNode, parentNode, false); -
trunk/src/core/net/sf/basedb/util/overview/validator/AnnotationValidator.java
r4823 r5132 28 28 import net.sf.basedb.core.Annotatable; 29 29 import net.sf.basedb.core.Annotation; 30 import net.sf.basedb.core.AnnotationSet;31 30 import net.sf.basedb.core.AnnotationType; 32 31 import net.sf.basedb.core.BasicItem; … … 38 37 import net.sf.basedb.core.ItemResultIterator; 39 38 import net.sf.basedb.core.PermissionDeniedException; 39 import net.sf.basedb.core.snapshot.AnnotationFilter; 40 import net.sf.basedb.core.snapshot.AnnotationSnapshot; 41 import net.sf.basedb.core.snapshot.SnapshotManager; 40 42 import net.sf.basedb.util.overview.Fix; 41 43 import net.sf.basedb.util.overview.OverviewContext; … … 85 87 Annotatable parent = (Annotatable)parentNode.getItem(dc); 86 88 Item parentItemType = parentNode.getItemType(); 87 AnnotationSet annotationSet = parent.getAnnotationSet();88 89 89 90 Annotation a = (Annotation)node.getItem(); 90 boolean isPrimary = a.belongsTo(annotationSet); 91 SnapshotManager manager = context.getSnapshotManager(); 92 // The primary use of the snapshot is to load the values if the annotation is a primary annotation 93 // Thus, we do not search inherited annotations 94 List<AnnotationSnapshot> snapshots = manager.findAnnotations(dc, parent, new AnnotationFilter(a), false); 95 AnnotationSnapshot snapshot = snapshots.size() > 0 ? snapshots.get(0) : null; 96 boolean isPrimary = snapshot != null && !snapshot.isInherited(); 91 97 92 98 AnnotationType at = null; … … 120 126 try 121 127 { 122 List<?> values = a.getValues();128 List<?> values = snapshot.getValues(); 123 129 if (values != null) 124 130 { -
trunk/www/common/overview/info.jsp
r5104 r5132 31 31 import="net.sf.basedb.core.AnnotationType" 32 32 import="net.sf.basedb.core.Annotation" 33 import="net.sf.basedb.core.Protocol" 33 34 import="net.sf.basedb.core.FileStoreEnabled" 34 35 import="net.sf.basedb.core.FileSetMember" … … 39 40 import="net.sf.basedb.core.PermissionDeniedException" 40 41 import="net.sf.basedb.core.ItemNotFoundException" 42 import="net.sf.basedb.core.snapshot.SnapshotManager" 43 import="net.sf.basedb.core.snapshot.AnnotationSetSnapshot" 44 import="net.sf.basedb.core.snapshot.AnnotationSnapshot" 45 import="net.sf.basedb.core.snapshot.AnnotationTypeFilter" 46 import="net.sf.basedb.core.snapshot.AnnotationFilter" 41 47 import="net.sf.basedb.clients.web.Base" 42 48 import="net.sf.basedb.clients.web.util.HTML" … … 92 98 try 93 99 { 94 GenericOverview overview = OverviewUtil.getCurrentOverview(sc); 100 final GenericOverview overview = OverviewUtil.getCurrentOverview(sc); 101 final SnapshotManager snapshotManager = overview.getSnapshotManager(); 102 final AnnotationTypeFilter annotationTypeFilter = new AnnotationTypeFilter(); 103 final AnnotationFilter annotationFilter = new AnnotationFilter(); 95 104 ValidationOptions options = overview.getValidationOptions(); 96 105 String nodeId = request.getParameter("nodeId"); … … 278 287 279 288 <% 280 List<Annotation > annotations = null;289 List<AnnotationSnapshot> annotations = new LinkedList<AnnotationSnapshot>(); 281 290 String annotationsTitle = ""; 282 291 Annotatable annotatable = null; … … 285 294 Annotation a = (Annotation)item; 286 295 dc.reattachItem(a, false); 287 annotations = Collections.singletonList(a); 288 try 289 { 290 annotatable = a.getAnnotationSet().getItem(); 291 } 292 catch (Throwable t) 293 {} 296 AnnotationSetSnapshot snapshot = snapshotManager.getSnapshot(dc, a.getAnnotationSet().getId()); 297 annotationFilter.setAnnotationType(a); 298 annotations.addAll(snapshotManager.findAnnotations(dc, snapshot, annotationFilter, true)); 299 300 // Find the annotatable parent node 301 Node parentNode = node; 302 while (parentNode != null) 303 { 304 BasicItem parentItem = parentNode.getItem(); 305 if (parentItem instanceof Annotatable) 306 { 307 annotatable = (Annotatable)parentItem; 308 break; 309 } 310 parentNode = parentNode.getParent(); 311 } 294 312 annotationsTitle = "Annotation values"; 295 313 } … … 301 319 { 302 320 BasicItem parentItem = parentNode.getItem(); 303 if (parentItem instanceof Annotatable )321 if (parentItem instanceof Annotatable && !(parentItem instanceof Protocol)) 304 322 { 305 323 annotatable = (Annotatable)parentItem; … … 307 325 if (annotatable.isAnnotated()) 308 326 { 309 annotations = annotatable.getAnnotationSet().findAnnotations(dc, (AnnotationType)item, true); 327 annotationTypeFilter.setAnnotationType((AnnotationType)item); 328 annotations.addAll(snapshotManager.findAnnotations(dc, annotatable, annotationTypeFilter, true)); 310 329 } 311 330 annotationsTitle = "Annotation values"; … … 322 341 { 323 342 dc.reattachItem((BasicItem)annotatable, false); 324 325 // Load annotations & protocol parameters 326 List<Node> nodes = new LinkedList<Node>(); 327 Node folder = node.getChild("annotations"); 328 if (folder != null && folder.getChildren() != null) nodes.addAll(folder.getChildren()); 329 Node protocolNode = node.getChild("protocol"); 330 if (protocolNode != null && protocolNode.getChildren() != null) nodes.addAll(protocolNode.getChildren()); 331 if (nodes.size() > 0) 332 { 333 annotations = new LinkedList<Annotation>(); 334 for (Node n : nodes) 335 { 336 BasicItem aItem = n.getItem(); 337 if (aItem instanceof Annotation) 338 { 339 annotations.add((Annotation)aItem); 340 } 341 else if (aItem instanceof AnnotationType) 342 { 343 annotations.addAll(annotatable.getAnnotationSet().findAnnotations(dc, (AnnotationType)aItem, true)); 344 } 345 } 346 } 343 annotations.addAll(snapshotManager.findAnnotations(dc, annotatable, null, true)); 347 344 } 348 345 } … … 353 350 <table border=0 cellspacing=0 cellpadding=0> 354 351 <% 355 for (Annotation a: annotations)356 { 357 a = Annotation.getById(dc, a.getId());352 for (AnnotationSnapshot snapshot : annotations) 353 { 354 Annotation a = snapshot.getAnnotation(dc); 358 355 String unitSymbol = a.hasUnit() ? " " + a.getUnitSymbol(null) : ""; 359 356 AnnotationType at = null; … … 361 358 try 362 359 { 363 at = a.getAnnotationType();360 at = snapshot.getAnnotationType(dc); 364 361 } 365 362 catch (Throwable t) … … 367 364 try 368 365 { 369 annotationOwner = a.getAnnotationSet().getItem();366 annotationOwner = snapshot.getItem(dc); 370 367 } 371 368 catch (Throwable t)
Note: See TracChangeset
for help on using the changeset viewer.