Ignore:
Timestamp:
Aug 24, 2009, 11:19:37 AM (14 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1360: Existing annotatation on an item may not be visible/editable in some cases

This should make sure that all existing annotations can be viewed and edited. The problem with the "Unhandled item: ANNOTATION..." will be fixed as part of #1361.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/common/annotations/annotate.jsp

    r4889 r5074  
    6363  import="java.util.HashSet"
    6464  import="java.util.TreeSet"
     65  import="java.util.Map"
     66  import="java.util.HashMap"
    6567%>
    6668<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    7880Set<AnnotationType> annotationTypes = null;
    7981Set<AnnotationType> protocolParameters = null;
     82Map<AnnotationType, Annotation> existing = null;
    8083try
    8184{
     
    142145  final StringBuilder sb = new StringBuilder();
    143146  final AnnotationSet as = item == null || !item.isAnnotated() ? null : item.getAnnotationSet();
     147  if (as != null)
     148  {
     149    // Load the existing annotations
     150    existing = new HashMap<AnnotationType, Annotation>();
     151    List<Annotation> annotations = as.getAnnotations().list(dc);
     152    for (Annotation a : annotations)
     153    {
     154      try
     155      {
     156        existing.put(a.getAnnotationType(), a);
     157      }
     158      catch (PermissionDeniedException ex)
     159      {}
     160    }
     161  }
    144162  %>
    145163
     
    153171    annotationTypes = new TreeSet<AnnotationType>(new NameableComparator(false));
    154172    annotationTypes.addAll(annotationTypeQuery.list(dc));
     173    if (existing != null) annotationTypes.addAll(existing.keySet());
    155174    if (annotationTypeId != 0)
    156175    {
     
    170189      List values = null;
    171190      Unit unit = at.getDefaultUnit();
    172       if (as != null && as.hasAnnotation(at))
    173       {
    174         Annotation a = as.getAnnotation(at);
     191      if (existing != null && existing.containsKey(at))
     192      {
     193        Annotation a = existing.get(at);
    175194        unit = a.getUnit();
    176195        values = a.getValues(null);
Note: See TracChangeset for help on using the changeset viewer.