Changeset 5163


Ignore:
Timestamp:
Oct 26, 2009, 10:59:01 AM (12 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1418: List of inherited annotations may include annotations that are not inherited and in some cases duplicates

Location:
branches/2.14-stable/src/core/net/sf/basedb/core/snapshot
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2.14-stable/src/core/net/sf/basedb/core/snapshot/AnnotationFilter.java

    r5132 r5163  
    7272  }
    7373
     74  /**
     75    Set the annotation this filter should match.
     76    @param annotationId A specific annotation, or 0 to match any annotation
     77    @since 2.14.1
     78  */
     79  public void setAnnotationId(int annotationId)
     80  {
     81    this.annotationId = annotationId;
     82  }
    7483}
  • branches/2.14-stable/src/core/net/sf/basedb/core/snapshot/SnapshotManager.java

    r5131 r5163  
    131131    List<AnnotationSnapshot> result = new ArrayList<AnnotationSnapshot>();
    132132    if (filter == null) filter = new StaticFilter<AnnotationSnapshot>(true);
     133    // Needed for recursive searching of inherited annotations
     134    AnnotationFilter annotationFilter = new AnnotationFilter();
     135   
    133136    for (AnnotationSnapshot shot : snapshot.getAnnotations())
    134137    {
     
    137140        if (!searchInherited) continue; // with the next snapshot in the list
    138141       
    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))
     142        int annotationId = shot.getAnnotationId();
     143        // If this is an inherited annotation set (annotationId==0), or if
     144        // it the filter matches we must recursively load the inherited annotations
     145        if (annotationId == 0 || filter.evaluate(shot))
    142146        {
    143147          AnnotationSetSnapshot recursive = getSnapshot(dc, shot.getAnnotationSetId());
    144148          if (recursive != null)
    145149          {
    146             for (AnnotationSnapshot primary : findAnnotations(dc, recursive, filter, false))
     150            Filter<? super AnnotationSnapshot> recursiveFilter = filter;
     151            if (annotationId != 0)
     152            {
     153              // The main filter has already matched this annotation
     154              // Use the recursive filter to load the specific annotation only
     155              recursiveFilter = annotationFilter;
     156              annotationFilter.setAnnotationId(annotationId);
     157            }
     158            for (AnnotationSnapshot primary : findAnnotations(dc, recursive, recursiveFilter, false))
    147159            {
    148160              AnnotationSnapshot copy = new AnnotationSnapshot();
Note: See TracChangeset for help on using the changeset viewer.