Changeset 6567


Ignore:
Timestamp:
Oct 21, 2014, 10:00:30 AM (9 years ago)
Author:
Nicklas Nordborg
Message:

References #1843: Use snapshot manager to load annotations on list pages

Updated the table exporter to also use the snapshot manager. Initial export time with no cached snapshot for 23753 samples was little over 5 minutes. With snapshots in place the export time dropped to less than a minute.

File:
1 edited

Legend:

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

    r6319 r6567  
    2323
    2424import net.sf.basedb.core.Annotatable;
    25 import net.sf.basedb.core.Annotation;
    26 import net.sf.basedb.core.AnnotationSet;
    2725import net.sf.basedb.core.BasicItem;
    2826import net.sf.basedb.core.BooleanParameterType;
     
    4442import net.sf.basedb.core.Type;
    4543import net.sf.basedb.core.Unit;
    46 
    4744import net.sf.basedb.core.Job.ExecutionTime;
    4845import net.sf.basedb.core.data.BasicData;
     
    6663import net.sf.basedb.core.signal.SignalTarget;
    6764import net.sf.basedb.core.signal.ThreadSignalHandler;
     65import net.sf.basedb.core.snapshot.AnnotationSetSnapshot;
     66import net.sf.basedb.core.snapshot.AnnotationSnapshot;
     67import net.sf.basedb.core.snapshot.AnnotationTypeFilter;
     68import net.sf.basedb.core.snapshot.SnapshotManager;
    6869import net.sf.basedb.util.Enumeration;
    6970import net.sf.basedb.util.Values;
    7071import net.sf.basedb.util.formatter.Formatter;
     72import net.sf.basedb.util.units.UnitConverter;
    7173
    7274import java.io.IOException;
     
    514516    boolean hasAnnotations = false;
    515517    long totalItems = query.getMaxResults() == 0 ? query.count(dc) : query.getMaxResults();
     518    SnapshotManager manager = new SnapshotManager();
     519    AnnotationTypeFilter filter = new AnnotationTypeFilter();
    516520   
    517521    for (ExportedProperty ep : exportedProperties)
     
    566570       
    567571        int id = queryWrapper.getId(item);
    568         AnnotationSet as = null;
     572        AnnotationSetSnapshot snapshot = null;
    569573        if (hasAnnotations)
    570574        {
    571575          Annotatable a = (Annotatable)item;
    572           if (a.isAnnotated()) as = a.getAnnotationSet();
     576          if (a.isAnnotated()) snapshot = manager.getSnapshot(dc, a.getAnnotationSet().getId());
    573577        }
    574578       
     
    582586            if (ep.dataloader == null)
    583587            {
    584               Annotation a = as != null && as.hasAnnotation(ep.annotationType) ?
    585                   as.getAnnotation(ep.annotationType) : null;
    586               if (a != null)
     588              if (snapshot != null)
    587589              {
    588                 values = a.getValues(ep.unit);
    589                 if (ep.unit == null) unitSymbol = a.getUnitSymbol(null);
     590                filter.setAnnotationType(ep.annotationType);
     591                List<AnnotationSnapshot> s = manager.findAnnotations(dc, snapshot, filter, false);
     592                if (s.size() == 1)
     593                {
     594                  Unit defaultUnit = ep.annotationType.getDefaultUnit();
     595                  UnitConverter unitConverter = null;
     596                  if (defaultUnit != null)
     597                  {
     598                    if (ep.unit != null) unitConverter = ep.unit.getUnitConverter(defaultUnit);
     599                    if (ep.unit == null) unitSymbol = defaultUnit.getDisplaySymbol();
     600                  }
     601                  values = s.get(0).getValues(unitConverter, ep.annotationType.getValueType());
     602                }
    590603              }
    591604            }
Note: See TracChangeset for help on using the changeset viewer.