Changeset 4857


Ignore:
Timestamp:
Mar 27, 2009, 12:47:31 PM (13 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1259: Exporting spot data (with table exporter): Bioassay column is numerated 1, 2, 3, ...

Also changed the list page to use the same formatter.

Location:
trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/views/experiments/spotdata/index.jsp

    r4511 r4857  
    3636  import="net.sf.basedb.clients.web.WebException"
    3737  import="net.sf.basedb.util.Values"
     38  import="net.sf.basedb.util.formatter.LookupFormatter"
    3839  import="net.sf.basedb.clients.web.util.HTML"
    3940  import="java.util.Map"
     
    6162  }
    6263  private static final Item itemType = Item.SPOTDATA;
     64 
     65  private static void registerExportFormatters(DbControl dc, ItemContext cc,
     66    BioAssaySet bas, BioAssay ba)
     67  {
     68    if (bas != null)
     69    {
     70      Map<Number, String> bioAssayMap = new HashMap<Number, String>();
     71      for (BioAssay b : bas.getBioAssays().list(dc))
     72      {
     73        short columnNo = b.getDataCubeColumnNo();
     74        String name = b.getName();
     75        // Safety measure, since JDBC driver seems to return 'short' as 'int'
     76        bioAssayMap.put(columnNo, name);
     77        bioAssayMap.put((int)columnNo, name);
     78      }
     79      cc.setObject("export.formatter.COLUMN", new LookupFormatter(bioAssayMap));
     80    }
     81  }
    6382%>
    6483<%
     
    122141    final DynamicSpotQuery query = ba != null ? ba.getSpotData() : bas.getSpotData();
    123142    //cc.configureQuery(query, true);
     143    registerExportFormatters(dc, cc, bas, ba);
    124144    dc.close();
    125145    cc.setQuery(query);
  • trunk/www/views/experiments/spotdata/list_spotdata.jsp

    r4511 r4857  
    4545  import="net.sf.basedb.util.Enumeration"
    4646  import="net.sf.basedb.util.ColorGenerator"
     47  import="net.sf.basedb.util.formatter.LookupFormatter"
    4748  import="net.sf.basedb.clients.web.Base"
    4849  import="net.sf.basedb.clients.web.ModeInfo"
     
    8889  final int experimentId = experiment.getId();
    8990  final RawDataType rawDataType = bioAssaySet.getRawDataType();
    90   Map<Short, String> bioAssayMap = null;
    9191 
    9292  final String subContext = rawDataType.getId();
     
    119119  int numListed = 0;
    120120  %>
     121 
    121122  <base:page title="<%=title%>">
    122123  <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
     
    269270      if (bioAssay == null)
    270271      {
    271         bioAssayMap = new HashMap<Short, String>();
     272        Map<Number, String> bioAssayMap = new HashMap<Number, String>();
    272273        Enumeration<String, String> bioAssayEnum = new Enumeration<String, String>();
    273274        for (BioAssay ba : bioAssaySet.getBioAssays().list(dc))
    274275        {
    275           short columnNo = ba.getDataCubeColumnNo();
    276           bioAssayMap.put(columnNo, Base.getLinkedName(ID, ba, false, true));
     276          short columnNo = ba.getDataCubeColumnNo();
     277          String linkedBioAssay = Base.getLinkedName(ID, ba, false, true);
     278          // Safety measure, since JDBC driver seems to return 'short' as 'int'
     279          bioAssayMap.put(columnNo, linkedBioAssay);
     280          bioAssayMap.put((int)columnNo, linkedBioAssay);
    277281          bioAssayEnum.add(String.valueOf(columnNo), HTML.encodeTags(ba.getName()));
    278282        }
     
    287291          exportable="true"
    288292          enumeration="<%=bioAssayEnum%>"
     293          formatter="<%=new LookupFormatter<Number>(bioAssayMap)%>"
    289294        />
    290295        <%
     
    373378                for (String columnId : selected.selectedIds)
    374379                {
    375                   Object value = item.getObject(i++);
    376                   if ("COLUMN".equals(columnId))
    377                   {
    378                     short columnNo = ((Number)value).shortValue();
    379                     value= bioAssayMap.get(columnNo);
    380                   }
    381380                  %>
    382                   <tbl:cell column="<%=columnId%>" value="<%=value%>" />
     381                  <tbl:cell column="<%=columnId%>" value="<%=item.getObject(i++)%>" />
    383382                  <%
    384383                }
Note: See TracChangeset for help on using the changeset viewer.