Changeset 5147


Ignore:
Timestamp:
Oct 20, 2009, 12:33:46 PM (12 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1389: Cache annotation summary groups in experiment explorer

The in-memory cache is now cleared every time the selected annotation types are modified.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/ExperimentExplorer.java

    r5130 r5147  
    2727import java.util.ArrayList;
    2828import java.util.Arrays;
     29import java.util.Collection;
    2930import java.util.HashMap;
    3031import java.util.HashSet;
     
    194195    The snapshot manager that loads annotation values.
    195196  */
    196   private final SnapshotManager snapshotManager;
     197  private SnapshotManager snapshotManager;
    197198 
    198199  /**
     
    234235    Caches annotation summaries.
    235236  */
    236   private Map<AnnotationType, AnnotationSummary> summaryCache;
     237  private Map<Integer, AnnotationSummary> summaryCache;
    237238 
    238239  /**
     
    244245    this.bioAssays = new HashMap<Short, Integer>();
    245246    this.snapshotManager = new SnapshotManager();
    246     this.summaryCache = new HashMap<AnnotationType, AnnotationSummary>();
     247    this.summaryCache = new HashMap<Integer, AnnotationSummary>();
    247248    for (BioAssay ba : bioAssaySet.getBioAssays().list(bioAssaySet.getDbControl()))
    248249    {
     
    412413    @return The id of the selected annotation type or 0 if no annotation type
    413414      is selected
    414     @deprecated Use {@link #getAnnotationTypeIds()} instead
     415    @deprecated In 2.14, use {@link #getAnnotationTypeIds()} instead
    415416  */
    416417  public int getAnnotationTypeId()
     
    425426    @param annotationTypeId The annotation type id or 0 if none is
    426427      selected
    427     @deprecated Use {@link #getAnnotationTypeIds()} instead
     428    @deprecated In 2.14, use {@link #setAnnotationTypeIds(Collection)} instead
    428429  */
    429430  public void setAnnotationTypeId(int annotationTypeId)
     
    435436 
    436437  /**
    437     Get a set for keeping track of the selected annotation types.
    438     @return A set for storing integers (=the id of the selected annotation types)
     438    Get the selected annotation types.
     439    @return A set with the the id's of the selected annotation types
     440    @since 2.14
    439441  */
    440442  public Set<Integer> getAnnotationTypeIds()
     
    442444    if (annotationTypeIds == null) annotationTypeIds = new HashSet<Integer>();
    443445    return annotationTypeIds;
     446  }
     447 
     448  /**
     449    Update the selected annotation types.
     450    @param ids A collection containing the id's of all annotation types
     451      that should currently be selected, all other annotation types are
     452      automatically deselected
     453    @since 2.14
     454  */
     455  public void setAnnotationTypeIds(Collection<Integer> ids)
     456  {
     457    Set<Integer> current = getAnnotationTypeIds();
     458    current.clear();
     459    for (Integer id : ids)
     460    {
     461      current.add(id);
     462      summaryCache.remove(id);
     463    }
     464    // The snapshot manager also has an in-memory cache
     465    snapshotManager = new SnapshotManager();
    444466  }
    445467 
     
    500522  public AnnotationSummary getAnnotationSummary(DbControl dc, AnnotationType annotationType)
    501523  {
    502     AnnotationSummary summary = summaryCache.get(annotationType);
     524    AnnotationSummary summary = summaryCache.get(annotationType.getId());
    503525    if (summary == null)
    504526    {
    505527      summary = new AnnotationSummary(this, dc, annotationType);
    506       summaryCache.put(annotationType, summary);
     528      summaryCache.put(annotationType.getId(), summary);
    507529    }
    508530    else
  • trunk/www/views/experiments/explorer/view/index.jsp

    r5137 r5147  
    8686  {
    8787    Integer[] annotationTypes = Values.getInt(request.getParameter("annotationtype_id").split("\\|"));
    88     Set<Integer> tmp = explorer.getAnnotationTypeIds();
    89     tmp.clear();
    90     tmp.addAll(Arrays.asList(annotationTypes));
     88    explorer.setAnnotationTypeIds(Arrays.asList(annotationTypes));
    9189   
    9290    // If an annotation type is selected the annotation column must be visible as the first column
Note: See TracChangeset for help on using the changeset viewer.