Changeset 4895


Ignore:
Timestamp:
Apr 20, 2009, 8:38:02 AM (13 years ago)
Author:
Martin Svensson
Message:

Refereces #1128 Added new formatter classes and tested them on complex properties of extracts. Export of other items' complex properties should be implemented next.

Location:
trunk
Files:
2 added
4 edited

Legend:

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

    r4711 r4895  
    4141  public final Unit unit;
    4242  public final Formatter formatter;
     43  public final boolean isComplex;
    4344 
    4445  public static ExportedProperty parse(DbControl dc, String column, boolean annotatable, Formatter formatter)
     
    8182    if (columnPrefix != null) title = columnPrefix + title;
    8283    if (columnSuffix != null) title += columnSuffix;
    83     return new ExportedProperty(name, title, at, unit, formatter);
     84    return new ExportedProperty(name, title, at, unit, formatter, name.startsWith("&"));
    8485  }
    8586
     
    9596    AnnotationType annotationType, Unit unit, Formatter formatter)
    9697  {
     98    this(name, title, annotationType, unit, formatter, false);
     99  }
     100 
     101  /**
     102    @since 2.12
     103   */
     104  public ExportedProperty(String name, String title,
     105      AnnotationType annotationType, Unit unit, Formatter formatter, boolean isComplex)
     106  {
    97107    this.name = name;
    98108    this.title = title;
     
    100110    this.formatter = formatter;
    101111    this.unit = unit;
     112    this.isComplex = isComplex;
    102113  }
    103  
    104114}
  • trunk/src/clients/web/net/sf/basedb/clients/web/plugins/SimpleExport.java

    r4889 r4895  
    569569            else
    570570            {
    571               Object data = queryWrapper.getData(ep, item);
     571              Object data = ep.isComplex ? item : queryWrapper.getData(ep, item);
    572572              template.writeProperty(ep, data);
    573573            }
  • trunk/www/biomaterials/extracts/index.jsp

    r4889 r4895  
    3333  import="net.sf.basedb.core.BioMaterialEvent"
    3434  import="net.sf.basedb.core.BioWell"
     35  import="net.sf.basedb.core.LabeledExtract"
    3536  import="net.sf.basedb.core.Protocol"
    3637  import="net.sf.basedb.core.ItemQuery"
     
    4950  import="net.sf.basedb.util.Values"
    5051  import="net.sf.basedb.clients.web.util.HTML"
     52  import="net.sf.basedb.util.formatter.ParentPropertyFormatter"
     53  import="net.sf.basedb.util.formatter.PropertyFormatter"
    5154  import="net.sf.basedb.util.formatter.Formatter"
    5255  import="net.sf.basedb.util.formatter.WellCoordinateFormatter"
     
    6972    cc.setObject("export.formatter.bioWell.row", new WellCoordinateFormatter(true));
    7073    cc.setObject("export.formatter.bioWell.column", new WellCoordinateFormatter(false));
     74    cc.setObject("export.formatter.&children(name)", new PropertyFormatter("getLabeledExtracts"));
     75    cc.setObject("export.formatter.&creationEvent.sourceBioMaterials(name)", new ParentPropertyFormatter("getCreationEvent.getSources", "getSample"));
    7176  }
    7277%>
     
    325330  {
    326331    // Run an export plugin in a list context
     332    dc = sc.newDbControl();
    327333    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
    328334    final ItemQuery<Extract> query = Extract.getQuery();
    329335    cc.configureQuery(query, true);
    330336    registerExportFormatters(cc);
     337    dc.close();
    331338    cc.setQuery(query);
    332     redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+extracts";
     339    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+extracts";   
    333340  }
    334341  else if ("ExportItem".equals(cmd))
    335342  {
    336343    // Run an export plugin in single-item context
     344    dc = sc.newDbControl();
    337345    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
    338346    registerExportFormatters(cc);
     347    dc.close();
    339348    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+extract";
    340349  }
  • trunk/www/biomaterials/extracts/list_extracts.jsp

    r4889 r4895  
    357357        datatype="string"
    358358        filterable="true"
     359        exportable="true"
    359360      />
    360361      <tbl:columndef
     
    364365        datatype="string"
    365366        filterable="true"
     367        exportable="true"
    366368      />
    367369      <tbl:columndef
Note: See TracChangeset for help on using the changeset viewer.