Changeset 4167


Ignore:
Timestamp:
Mar 3, 2008, 9:20:28 AM (14 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #941: SQLException when exporting "merged on reporters" with BioAssaySet? exporter on Postgres
References #939: BioAssaySetExporter? doesn't export BASEfiles for multiple array designs correctly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.6-stable/src/plugins/core/net/sf/basedb/plugins/BioAssaySetExporter.java

    r4166 r4167  
    7272import net.sf.basedb.core.query.JoinType;
    7373import net.sf.basedb.core.query.Orders;
    74 import net.sf.basedb.core.query.Select;
    7574import net.sf.basedb.core.query.Selects;
    7675import net.sf.basedb.core.query.SqlResult;
     
    318317      query.select(Selects.expression(qi.getExpression(dc, bas, mergeReporters), qi.getQueryAlias()));
    319318    }
    320 
    321     if (mergeReporters)
    322     {
    323       QueryItem qi = qis.get("rep.id");
    324       Select rep = Selects.expression(qi.getExpression(dc, bas, mergeReporters), qi.getQueryAlias());
    325       if (!reporterFields.contains(qi.getExportName()))
    326       {
    327         query.select(rep);
    328       }
    329       query.group(Dynamic.column(VirtualColumn.COLUMN));
    330       query.group(Expressions.selected(rep));
    331     }
    332    
     319 
    333320    checkInterrupted();
    334321    long count = getBaseFileSpotSectionCount(dc, bas.getSpotData(), mergeReporters);
    335322    checkInterrupted();
    336     exportBaseFileSectionSpots(out, dc, bas, query, reporterFields, spotFields, bas.getBioAssays().list(dc), qis, count);
     323    exportBaseFileSectionSpots(out, dc, bas, query, reporterFields, spotFields, bas.getBioAssays().list(dc), qis, count, mergeReporters);
    337324    out.flush();
    338325  }
     
    458445      }
    459446
    460       if (mergeReporters)
    461       {
    462         QueryItem qi = qis.get("rep.id");
    463         Select rep = Selects.expression(qi.getExpression(dc, bas, mergeReporters), qi.getQueryAlias());
    464         if (!reporterFields.contains(qi.getExportName()))
    465         {
    466           query.select(rep);
    467         }
    468         query.group(rep.getExpression());
    469       }
    470 
    471447      checkInterrupted();
    472448      long count = getBaseFileSpotSectionCount(dc, ba.getSpotData(), mergeReporters);
    473       exportBaseFileSectionSpots(out, dc, bas, query, reporterFields, spotFields, Collections.singletonList(ba), qis, count);
     449      exportBaseFileSectionSpots(out, dc, bas, query, reporterFields, spotFields, Collections.singletonList(ba), qis, count, mergeReporters);
    474450     
    475451      out.println();
     
    480456
    481457  private void exportBaseFileSectionSpots(PrintWriter out, DbControl dc, BioAssaySet bas, DynamicSpotQuery query,
    482     List<String> reporterFields, List<String> spotFields, List<BioAssay> assays, Map<String, QueryItem> qi, long count)
     458    List<String> reporterFields, List<String> spotFields, List<BioAssay> assays, Map<String, QueryItem> qi,
     459    long count, boolean mergeOnReporters)
    483460    throws SQLException
    484461  {
     
    516493    }
    517494   
    518     query.select(Selects.expression(Dynamic.column(VirtualColumn.POSITION), "_position"));
    519     query.select(Selects.expression(Dynamic.column(VirtualColumn.COLUMN), "_column"));
    520     query.order(Orders.asc(Dynamic.column(VirtualColumn.POSITION)));
    521     query.order(Orders.asc(Dynamic.column(VirtualColumn.COLUMN)));
     495    Expression posExpression = null;
     496    Expression colExpression = null;
     497    if (mergeOnReporters)
     498    {
     499      posExpression = Dynamic.column(VirtualTable.POSITION, VirtualColumn.REPORTER_ID);
     500      colExpression = Dynamic.column(VirtualColumn.COLUMN);
     501      query.group(colExpression);
     502      query.group(posExpression);
     503    }
     504    else
     505    {
     506      posExpression = Dynamic.column(VirtualColumn.POSITION);
     507      colExpression = Dynamic.column(VirtualColumn.COLUMN);
     508    }
     509    query.select(Selects.expression(posExpression, "_position"));
     510    query.select(Selects.expression(colExpression, "_column"));
     511    query.order(Orders.asc(posExpression));
     512    query.order(Orders.asc(colExpression));
    522513   
    523514    checkInterrupted();
Note: See TracChangeset for help on using the changeset viewer.