Changeset 5074 for trunk/www/common/annotations/list_annotations.jsp
- Timestamp:
- Aug 24, 2009, 11:19:37 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/common/annotations/list_annotations.jsp
r5055 r5074 43 43 import="net.sf.basedb.clients.web.Base" 44 44 import="net.sf.basedb.clients.web.util.HTML" 45 import="net.sf.basedb.util.NameableComparator" 45 46 import="net.sf.basedb.util.formatter.Formatter" 46 47 import="net.sf.basedb.util.formatter.PrefixSuffixFormatter" … … 48 49 import="net.sf.basedb.util.Values" 49 50 import="java.util.List" 51 import="java.util.Set" 52 import="java.util.HashSet" 53 import="java.util.TreeSet" 54 import="java.util.Map" 55 import="java.util.HashMap" 50 56 %> 51 57 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 60 66 final DbControl dc = sc.newDbControl(); 61 67 68 Set<AnnotationType> annotationTypes = null; 69 Set<AnnotationType> protocolParameters = null; 70 Map<AnnotationType, Annotation> existing = null; 71 62 72 try 63 73 { 64 74 final Annotatable item = (Annotatable)itemType.getById(dc, itemId); 75 final boolean writePermission = item.hasPermission(Permission.WRITE); 76 65 77 ItemQuery<AnnotationType> annotationTypeQuery = null; 66 78 String message = null; 67 79 boolean isProxy = item instanceof AnnotatableProxy; 68 80 81 // Load all annotation types that are possible for this item type 69 82 if (isProxy) 70 83 { … … 77 90 annotationTypeQuery = Base.getAnnotationTypesQuery(itemType, false); 78 91 } 79 final List<AnnotationType> annotationTypes = annotationTypeQuery.list(dc); 80 Protocol protocol = null; 81 boolean readProtocol = true; 82 try 83 { 84 protocol = item.getProtocol(); 85 } 86 catch (PermissionDeniedException ex) 87 { 88 readProtocol = false; 89 } 90 final List<AnnotationType> protocolParameters = protocol == null ? 91 null : Base.getProtocolParametersQuery(protocol).list(dc); 92 final boolean writePermission = item.hasPermission(Permission.WRITE); 92 annotationTypes = new TreeSet<AnnotationType>(new NameableComparator(false)); 93 annotationTypes.addAll(annotationTypeQuery.list(dc)); 93 94 94 95 final AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null; … … 96 97 if (as != null) 97 98 { 99 // Load the existing annotations on the item 100 existing = new HashMap<AnnotationType, Annotation>(); 101 List<Annotation> annotations = as.getAnnotations().list(dc); 102 for (Annotation a : annotations) 103 { 104 try 105 { 106 existing.put(a.getAnnotationType(), a); 107 } 108 catch (PermissionDeniedException ex) 109 {} 110 } 111 annotationTypes.addAll(existing.keySet()); 112 113 // Load inherited annotations 98 114 ItemQuery<Annotation> inheritedQuery = as.getAllInheritedAnnotations(); 99 115 // Need FETCH JOIN because Postgres don't like the DISTINCT keyword … … 104 120 inheritedAnnotations = inheritedQuery.list(dc); 105 121 } 106 %> 122 123 // Load the possible protocol parameters 124 Protocol protocol = null; 125 boolean readProtocol = true; 126 try 127 { 128 protocol = item.getProtocol(); 129 } 130 catch (PermissionDeniedException ex) 131 { 132 readProtocol = false; 133 } 134 ItemQuery<AnnotationType> parameterQuery = Base.getProtocolParametersQuery(protocol); 135 if (parameterQuery != null) 136 { 137 protocolParameters = new HashSet<AnnotationType>(parameterQuery.list(dc)); 138 annotationTypes.removeAll(protocolParameters); 139 } 140 %> 107 141 <base:page type="include"> 108 142 <base:body> … … 168 202 for (AnnotationType at : annotationTypes) 169 203 { 170 Annotation a = as != null && as.hasAnnotation(at) ? as.getAnnotation(at) : null;204 Annotation a = existing != null ? existing.get(at) : null; 171 205 List<?> values = null; 172 206 Formatter formatter = null; … … 252 286 for (AnnotationType at : protocolParameters) 253 287 { 254 Annotation a = as != null && as.hasAnnotation(at) ? as.getAnnotation(at) : null;288 Annotation a = existing != null ? existing.get(at) : null; 255 289 Formatter formatter = null; 256 290 List<?> values = null;
Note: See TracChangeset
for help on using the changeset viewer.