Changeset 6687


Ignore:
Timestamp:
Jan 20, 2015, 3:45:46 PM (8 years ago)
Author:
Nicklas Nordborg
Message:

References #1906: Display inherited annotations in list views

Added support for exporting inherited annotations to the table exporter.

Location:
trunk/src/clients/web/net/sf/basedb/clients/web/plugins
Files:
2 edited

Legend:

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

    r6030 r6687  
    4444  public final String title;
    4545  public final AnnotationType annotationType;
     46  public final boolean loadInherited;
    4647  public final Unit unit;
    4748  public final Formatter formatter;
     
    5253  {
    5354    PropertyPath propertyPath = metadata.getPropertyPath(path, false);
    54     return new ExportedProperty(path, title, propertyPath, null, null, formatter, null);
     55    return new ExportedProperty(path, title, propertyPath, null, false, null, formatter, null);
    5556  }
    5657
     
    6768    String title = p.length > 2 ? p[2] : p[0];
    6869    AnnotationType at = null;
     70    boolean loadInherited = false;
    6971    Unit unit = null;
    7072    String columnSuffix = null;
     
    7274    if (name.startsWith("#") && annotatable) // && itemType != Item.SPOTDATA)
    7375    {
     76      loadInherited = name.startsWith("##");
    7477      // Annotation: properties[i] = #annotationTypeId
    75       int annotationTypeId = Values.getInt(name.substring(1));
     78      int annotationTypeId = Values.getInt(loadInherited ? name.substring(2) : name.substring(1));
    7679      at = AnnotationType.getById(dc, annotationTypeId);
    7780      name = "annotationtype_"+annotationTypeId;
     
    8992    if (columnPrefix != null) title = columnPrefix + title;
    9093    if (columnSuffix != null) title += columnSuffix;
    91     return new ExportedProperty(name, title, propertyPath, at, unit, formatter, dataloader);
     94    return new ExportedProperty(name, title, propertyPath, at, loadInherited, unit, formatter, dataloader);
    9295  }
    9396
     
    9598    @since 2.15
    9699  */
    97   public ExportedProperty(String name, String title, PropertyPath propertyPath,
    98       AnnotationType annotationType, Unit unit, Formatter formatter, DataLoader dataloader)
     100  private ExportedProperty(String name, String title, PropertyPath propertyPath,
     101      AnnotationType annotationType, boolean loadInherited, Unit unit, Formatter formatter, DataLoader dataloader)
    99102  {
    100103    this.name = name;
     
    102105    this.propertyPath = propertyPath;
    103106    this.annotationType = annotationType;
     107    this.loadInherited = loadInherited;
    104108    this.formatter = formatter == null ? new ToStringFormatter() : formatter;
    105109    this.unit = unit;
  • trunk/src/clients/web/net/sf/basedb/clients/web/plugins/SimpleExport.java

    r6567 r6687  
    582582          if (ep.annotationType != null)
    583583          {
    584             List<?> values = null;
     584            List values = null;
    585585            String unitSymbol = null;
    586586            if (ep.dataloader == null)
     
    589589              {
    590590                filter.setAnnotationType(ep.annotationType);
    591                 List<AnnotationSnapshot> s = manager.findAnnotations(dc, snapshot, filter, false);
    592                 if (s.size() == 1)
     591                List<AnnotationSnapshot> list = manager.findAnnotations(dc, snapshot, filter, !ep.loadInherited, ep.loadInherited);
     592                if (list.size() > 0)
    593593                {
    594594                  Unit defaultUnit = ep.annotationType.getDefaultUnit();
     595                  Type valueType = ep.annotationType.getValueType();
    595596                  UnitConverter unitConverter = null;
    596597                  if (defaultUnit != null)
     
    599600                    if (ep.unit == null) unitSymbol = defaultUnit.getDisplaySymbol();
    600601                  }
    601                   values = s.get(0).getValues(unitConverter, ep.annotationType.getValueType());
     602                  values = new ArrayList();
     603                  for (AnnotationSnapshot s : list)
     604                  {
     605                    values.addAll(s.getValues(unitConverter, valueType));
     606                  }
    602607                }
    603608              }
Note: See TracChangeset for help on using the changeset viewer.