Changeset 4928


Ignore:
Timestamp:
May 13, 2009, 1:01:46 PM (12 years ago)
Author:
Nicklas Nordborg
Message:

References #742: Refactor BioAssaySetExporter?

The new BASEfile exporter plug-in is in place. The BioAssaySetExporter? has been deprecated but no changes have yet been made to code that uses it. The installation will unshare the BioAssaySetExporter? if upgrading and doesn't install it as a plug-in in a new installation.
Also fixed DynamicPositionQuery? so that it handles extra values properly (=support for automatic joins to the needed tables).

Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/core/DynamicPositionQuery.java

    r4912 r4928  
    2222*/
    2323package net.sf.basedb.core;
     24
     25import java.util.HashSet;
     26import java.util.Set;
    2427
    2528import net.sf.basedb.core.query.Dynamic;
     
    4952
    5053  private Select[] defaultSelects;
     54  private Set<Object> joinedItems;
    5155
    5256  /**
     
    5761  {
    5862    super(cube, VirtualTable.POSITION, null);
     63    joinedItems = new HashSet<Object>();
     64    setAutoJoinType(JoinType.LEFT);
    5965  }
    6066 
     
    7682    return defaultSelects;
    7783  }
     84  /**
     85    Reset join information.
     86  */
     87  @Override
     88  public void reset()
     89  {
     90    super.reset();
     91    joinedItems.clear();
     92  }
    7893  // -------------------------------------------
    7994
     
    92107  {
    93108    if (joinType == null) throw new InvalidUseOfNullException("joinType");
    94     join(new RealJoin(joinType, VirtualTable.POSITION, RealTable.REPORTERS, VirtualColumn.REPORTER_ID));
     109    if (!joinedItems.contains(RealTable.REPORTERS))
     110    {
     111      join(new RealJoin(joinType, VirtualTable.POSITION, RealTable.REPORTERS,
     112        VirtualColumn.REPORTER_ID));
     113      joinedItems.add(RealTable.REPORTERS);
     114    }
    95115  }
    96116 
     
    120140        " is not part of the same data cube as this query: " + getDataCube());
    121141    }
    122     join(new ExtraValueJoin(extraValue, joinType));
     142    if (!joinedItems.contains(extraValue))
     143    {
     144      join(new ExtraValueJoin(extraValue, joinType));
     145      joinedItems.add(extraValue);
     146    }
     147  }
     148 
     149  /**
     150    Specify the join type of automatic joins. The default join type is
     151    {@link JoinType#LEFT}. This setting doesn't affect joins that has been made
     152    directly to the the query.
     153    @param joinType The type of the automatic joins
     154    @since 2.12
     155  */
     156  public void setAutoJoinType(JoinType joinType)
     157  {
     158    addAutoJoiner(DynamicPositionQueryJoiners.getExtraValueJoiner(joinType));
     159    addAutoJoiner(DynamicPositionQueryJoiners.getReporterJoiner(joinType));
    123160  }
    124161
     162
    125163}
  • trunk/src/core/net/sf/basedb/core/DynamicSpotQuery.java

    r4915 r4928  
    201201    if (extraValue == null) throw new InvalidUseOfNullException("extraValue");
    202202    if (joinType == null) throw new InvalidUseOfNullException("joinType");
    203     if (extraValue.getCoordinateType() != ExtraValue.CoordinateType.SPOT)
     203    /*if (extraValue.getCoordinateType() != ExtraValue.CoordinateType.SPOT)
    204204    {
    205205      throw new InvalidDataException("Extra value "+ extraValue+
    206206        " is not attached to spots: "+extraValue.getCoordinateType());
    207     }
     207    }*/
    208208    if (!getDataCube().equals(extraValue.getDataCubeExtraValue().getDataCube()))
    209209    {
  • trunk/src/core/net/sf/basedb/core/Install.java

    r4918 r4928  
    3636import net.sf.basedb.core.data.PlatformFileTypeData;
    3737import net.sf.basedb.core.data.PluginConfigurationData;
     38import net.sf.basedb.core.data.ProjectKeyData;
    3839import net.sf.basedb.core.data.ProtocolTypeData;
    3940import net.sf.basedb.core.data.QuantityData;
     
    4344import net.sf.basedb.core.data.RoleData;
    4445import net.sf.basedb.core.data.SchemaVersionData;
     46import net.sf.basedb.core.data.ShareableData;
    4547import net.sf.basedb.core.data.SoftwareTypeData;
    4648import net.sf.basedb.core.data.SoftwareData;
     
    112114    method.
    113115  */
    114   public static final int NEW_SCHEMA_VERSION = Integer.valueOf(70).intValue();
     116  public static final int NEW_SCHEMA_VERSION = Integer.valueOf(71).intValue();
    115117 
    116118  public static synchronized void createTables(boolean update, final ProgressReporter progress)
     
    623625     
    624626      createPluginDefinition("net.sf.basedb.plugins.Base1PluginExecuter", null, null, true, null, false);
    625       createPluginDefinition("net.sf.basedb.plugins.BioAssaySetExporter", null, keyEveryoneUse, true, null, true);
     627      if (update && schemaVersion.getSchemaVersion() < 71)
     628      {
     629        // Update and unshare the bioassay set exporter plug-in
     630        PluginDefinition p = createPluginDefinition("net.sf.basedb.plugins.BioAssaySetExporter", null, keyEveryoneUse, true, null, true);
     631        setPermissions(Item.PLUGINDEFINITION, p.getId(), null, null);
     632      }
     633     
     634      createPluginDefinition("net.sf.basedb.plugins.BaseFileExporterPlugin", null, keyEveryoneUse, true, null, true);
    626635      createPluginDefinition("net.sf.basedb.plugins.FormulaFilter", null, keyEveryoneUse, true, null, false);
    627636      createPluginDefinition("net.sf.basedb.plugins.HelpExporter", null, null, true, null, true);
     
    26382647  }
    26392648 
     2649  private static void setPermissions(Item itemType, int itemId, ItemKeyData itemKey, ProjectKeyData projectKey)
     2650  {
     2651    org.hibernate.Transaction tx = null;
     2652    try
     2653    {
     2654      tx = HibernateUtil.newTransaction(session);
     2655      ShareableData data = (ShareableData)session.get(itemType.getDataClass(), itemId);
     2656      data.setItemKey(itemKey);
     2657      data.setProjectKey(projectKey);
     2658     
     2659      HibernateUtil.commit(tx);
     2660      log.info("setPermissions: OK " + itemType.name() + "(" +  itemId + ")");
     2661    }
     2662    catch (RuntimeException ex)
     2663    {
     2664      if(tx != null) HibernateUtil.rollback(tx);
     2665      log.error("setPermissions: FAILED " + itemType.name() + "(" +  itemId + ")");
     2666      throw ex;
     2667    }
     2668  }
     2669 
    26402670  private static class PlatformFT
    26412671  {
  • trunk/src/core/net/sf/basedb/core/Update.java

    r4917 r4928  
    797797    </td>
    798798  </tr>
     799  <tr>
     800    <td>71</td>
     801    <td>
     802      Deprecated:
     803      <ul>
     804      <li>{@link net.sf.basedb.plugins.BioAssaySetExporter}.
     805      </ul>
     806      No special database update is needed. Only increase the schema version.
     807    </td>
     808  </tr>
    799809  </table>
    800810
     
    10841094        schemaVersion = setSchemaVersionInTransaction(session, 63);
    10851095      }
    1086       // Schemaversion 64-70 only updates the version number
    1087       if (schemaVersion < 70)
    1088       {
    1089         if (progress != null) progress.display((int)(69*progress_factor), "--Updating schema version: " + schemaVersion + " -> 70...");
    1090         schemaVersion = setSchemaVersionInTransaction(session, 70);
     1096      // Schemaversion 64-71 only updates the version number
     1097      if (schemaVersion < 71)
     1098      {
     1099        if (progress != null) progress.display((int)(70*progress_factor), "--Updating schema version: " + schemaVersion + " -> 71...");
     1100        schemaVersion = setSchemaVersionInTransaction(session, 71);
    10911101      }
    10921102     
  • trunk/src/core/net/sf/basedb/util/export/spotdata/ExportableFieldFactory.java

    r4925 r4928  
    2424import net.sf.basedb.core.AnnotationType;
    2525import net.sf.basedb.core.ExtendedProperty;
     26import net.sf.basedb.core.ExtraValueType;
    2627import net.sf.basedb.core.Formula;
    2728import net.sf.basedb.core.RawDataProperty;
     
    207208  }
    208209 
     210  /**
     211    Create a JEP dynamic field that exports an extra value.
     212    @param extra The extra value type
     213    @param title The column title, or null to use the
     214      name of the formula as the title
     215    @param formatter A formatter or null
     216  */
     217  public static JepDynamicField extraValue(ExtraValueType extra, String title, Formatter<?> formatter)
     218  {
     219    String expression = "xtra('" + extra.getExternalId() + "')";
     220    if (title == null) title = extra.getName();
     221    return jep(expression, title, extra.getAverageMethod(), formatter);
     222  }
     223 
    209224}
  • trunk/src/plugins/core/net/sf/basedb/plugins/BioAssaySetExporter.java

    r4917 r4928  
    8686import net.sf.basedb.util.BioAssaySetUtil;
    8787import net.sf.basedb.util.Enumeration;
     88import net.sf.basedb.util.export.spotdata.AbstractBioAssaySetExporter;
     89import net.sf.basedb.util.export.spotdata.MatrixBaseFileExporter;
     90import net.sf.basedb.util.export.spotdata.SerialBaseFileExporter;
    8891
    8992import java.io.IOException;
     
    119122   @version 2.1
    120123   @base.modified $Date$
     124   @deprecated In 2.12. Use: {@link SerialBaseFileExporter} or {@link MatrixBaseFileExporter}
     125    for BASEfile export and the extension package at http://baseplugins.thep.lu.se/wiki/net.sf.basedb.mev
     126    for MeV export
    121127*/
    122 
    123128public class BioAssaySetExporter
    124129  extends AbstractExporterPlugin
     
    231236
    232237  /**
    233     @deprecated In 2.11, use
    234       {@link #exportBaseFileMatrix(BioAssaySet, File, Map, List, List, Boolean, ProgressReporter)}
     238    @deprecated In 2.11 and 2.12, use {@link MatrixBaseFileExporter} instead
    235239  */
    236240  public void exportBaseFileMatrix(BioAssaySet bas, File file, Map<String, String> parameters,
     
    298302    @throws SQLException If there is an error reading from the database
    299303    @since 2.11
     304    @deprecated In 2.12, use {@link MatrixBaseFileExporter} instead
    300305  */
    301306  public void exportBaseFileMatrix(BioAssaySet bas, File file, Map<String, String> parameters,
     
    310315
    311316  /**
    312     @deprecated In 2.11, use {@link #exportBaseFileMatrix(BioAssaySet, OutputStream, Map, List, List, boolean, ProgressReporter)}
     317    @deprecated In 2.11 and 2.12, use {@link MatrixBaseFileExporter} instead.
    313318  */
    314319  public void exportBaseFileMatrix(BioAssaySet bas, OutputStream os, Map<String, String> parameters,
     
    321326  /**
    322327    @since 2.11
     328    @deprecated In 2.11 and 2.12, use {@link MatrixBaseFileExporter} instead.
    323329  */
    324330  public void exportBaseFileMatrix(BioAssaySet bas, OutputStream os, Map<String, String> parameters,
     
    422428 
    423429  /**
    424     @deprecated In 2.11, use {@link
    425       #exportBaseFileSerial(BioAssaySet, File, Map, List, List, Boolean, ProgressReporter)}
     430    @deprecated In 2.11 and 2.12, use {@link SerialBaseFileExporter} instead.
    426431  */
    427432  public void exportBaseFileSerial(BioAssaySet bas, File file, Map<String, String> parameters,
     
    449454    @throws SQLException If there is an error reading from the database
    450455    @since 2.11
     456    @deprecated In 2.12, use {@link SerialBaseFileExporter} instead.
    451457  */
    452458  public void exportBaseFileSerial(BioAssaySet bas, File file, Map<String, String> parameters,
     
    460466 
    461467  /**
    462     @deprecated In 2.11, use {@link
    463       #exportBaseFileSerial(BioAssaySet, OutputStream, Map, List, List, boolean, ProgressReporter)}
     468    @deprecated In 2.11 and 2.12, use {@link SerialBaseFileExporter} instead.
    464469  */
    465470  public void exportBaseFileSerial(BioAssaySet bas, OutputStream os, Map<String, String> parameters,
     
    472477  /**
    473478    @since 2.11
     479    @deprecated In 2.12, use {@link SerialBaseFileExporter} instead.
    474480  */
    475481  public void exportBaseFileSerial(BioAssaySet bas, OutputStream os, Map<String, String> parameters,
     
    691697    @throws IOException If there is an IO error
    692698    @throws SQLException If there is an error reading from the database
     699    @deprecated In 2.12, use extension package found at
     700      http://baseplugins.thep.lu.se/wiki/net.sf.basedb.mev instead
    693701  */
    694702  public void exportMeV(BioAssaySet bioassayset, OutputStream to,
     
    921929    @throws IOException If there is an IO error
    922930    @throws SQLException If there is an error reading from the database
     931    @deprecated In 2.12, no direct replacement, write a subclass of
     932      {@link AbstractBioAssaySetExporter} instead
    923933  */
    924934  public void exportPlainMatrix(BioAssaySet bioassayset, OutputStream os,
     
    15591569    new AboutImpl
    15601570    (
    1561       "Bioassay set file exporter",
    1562       "Exporter for bioassay sets. Supported formats:\n\n" +
    1563       "- Tab Delimited, Multiple Sample Files (TDMS Format) for " +
    1564       "use in MeV (available from http://www.tm4.org).\n"+
    1565       "- BASEfile\n",
     1571      "Bioassay set file exporter (deprecated)",
     1572      "This plug-in has been deprecated and has been replaced with the " +
     1573      "BASEfile exporter for serial and matrix BASEfile formats and with" +
     1574      "the MeV extension for MeV TDMS format " +
     1575      "(see http://baseplugins.thep.lu.se/wiki/net.sf.basedb.mev)\n",
    15661576      Version.getMajor() + "." + Version.getMinor() + "." + Version.getMaintenance(),
    15671577      "2006, Base 2 development team",
  • trunk/www/views/experiments/spotdata/list_spotdata.jsp

    r4917 r4928  
    124124  {
    125125    cc.setMessage(t.getMessage());
     126    t.printStackTrace();
    126127  }
    127128
Note: See TracChangeset for help on using the changeset viewer.