Changeset 5897


Ignore:
Timestamp:
Dec 2, 2011, 12:09:46 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #1616: Clone reporter information to per-experiment tables in the dynamic database

Added a tab on the experiment view page that lists cloned and master reporter information that can be used to find out if the master reporter information has been modified. It is then possible to update the cloned information.

This more or less completes the intended functionality. I'll keep the ticket open for some more testing.

Location:
trunk
Files:
5 added
18 edited

Legend:

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

    r5887 r5897  
    139139    List<ClonableProperty> properties = template == null ?
    140140      ClonableProperty.getAll() : template.getClonableProperties();
    141    
     141    String jepFunction = propertyPrefix != null && propertyPrefix.startsWith("@@") ? "mrep": "rep";
    142142    SessionControl sc = dc.getSessionControl();
    143143    for (ClonableProperty cp : properties)
    144144    {
    145145      String name = cp.getName();
    146       TableColumn tc = new TableColumn(idPrefix + name, propertyPrefix + name, "rep('"+name+"')",
     146      TableColumn tc = new TableColumn(idPrefix + name, propertyPrefix + name, jepFunction + "('"+name+"')",
    147147          cp.getType(), titlePrefix + cp.getTitle(), cp.getDescription(), "auto", true, true, true,
    148148          cp.getAverageMethod(), FormatterFactory.getExtendedPropertyFormatter(sc, cp));
  • trunk/src/clients/web/net/sf/basedb/clients/web/ExperimentExplorer.java

    r5892 r5897  
    7979import net.sf.basedb.core.query.Select;
    8080import net.sf.basedb.core.query.Selects;
     81import net.sf.basedb.core.query.SqlQuery;
    8182import net.sf.basedb.core.query.SqlResult;
    8283import net.sf.basedb.core.snapshot.SnapshotManager;
     
    663664    {@link net.sf.basedb.core.DataQuery}. This means that we don't get
    664665    {@link ReporterData} objects as a result and that we must specify the
    665     properties to select (see {@link ItemContext#configureQuery(DbControl, net.sf.basedb.core.AbstractSqlQuery, List)}).
     666    properties to select (see {@link ItemContext#configureQuery(DbControl, SqlQuery, List)}).
    666667    <p>
    667668    The reporter id is always included as the first selected property so it
     
    683684    @param selectionList The properties that the query should select
    684685    @return A query
    685     @see ItemContext#configureQuery(DbControl, net.sf.basedb.core.AbstractSqlQuery, List)
     686    @see ItemContext#configureQuery(DbControl, SqlQuery, List)
    686687  */
    687688  public DynamicReporterQuery getReporterQuery(DbControl dc, List<String> selectionList)
     
    718719   
    719720    reporterQuery.select(Selects.expression(Dynamic.reporter("id"), "id", true));
    720     cc.configureQuery(dc, reporterQuery, selectionList);
     721    cc.configureQuery(dc, (SqlQuery)reporterQuery, selectionList);
    721722   
    722723    // Do not return the total count. Do not set paging options.
     
    949950      cc.setPropertyInspector(null);
    950951    }
    951     cc.configureQuery(dc, reporterQuery, null);
     952    cc.configureQuery(dc, (SqlQuery)reporterQuery, null);
    952953    reporterQuery.order(Orders.asc(Expressions.selected(position)));
    953954    reporterQuery.setDistinct(true);
  • trunk/src/clients/web/net/sf/basedb/clients/web/plugins/DynamicQueryWrapper.java

    r4512 r5897  
    2727import net.sf.basedb.core.DynamicQuery;
    2828import net.sf.basedb.core.query.ResultIterator;
     29import net.sf.basedb.core.query.SqlQuery;
    2930import net.sf.basedb.core.query.SqlResult;
    3031
     
    3940  implements QueryWrapper<SqlResult>
    4041{
    41   private final DynamicQuery query;
     42  private final SqlQuery query;
    4243  private final DbControl dc;
    4344  private int counter = 0;
     
    4950    @param query The query
    5051  */
    51   public DynamicQueryWrapper(DbControl dc, DynamicQuery query)
     52  public DynamicQueryWrapper(DbControl dc, SqlQuery query)
    5253  {
    5354    this.dc = dc;
  • trunk/src/clients/web/net/sf/basedb/clients/web/plugins/SimpleExport.java

    r5843 r5897  
    2929import net.sf.basedb.core.DataQuery;
    3030import net.sf.basedb.core.DbControl;
    31 import net.sf.basedb.core.DynamicQuery;
    3231import net.sf.basedb.core.InvalidUseOfNullException;
    3332import net.sf.basedb.core.Item;
     
    6362import net.sf.basedb.core.query.Restrictions;
    6463import net.sf.basedb.core.query.ResultIterator;
     64import net.sf.basedb.core.query.SqlQuery;
    6565import net.sf.basedb.core.signal.SignalHandler;
    6666import net.sf.basedb.core.signal.SignalTarget;
     
    225225    ItemContext cc = sc.getCurrentContext(itemType, subContext);
    226226   
    227     //
     227    Query query = cc.getQuery();
     228    boolean isSqlQuery = query instanceof SqlQuery;
     229   
    228230    String entityName = null;
    229231    Class entityClass = null;
    230232    Metadata metadata = null;
    231     if (itemType == Item.RAWDATA)
    232     {
    233       RawBioAssay rba = RawBioAssay.getById(dc, sc.getCurrentContext(Item.RAWBIOASSAY).getId());
    234       entityName = rba.getRawDataType().getEntityName();
    235       entityClass = RawData.class;
    236     }
    237     else if (itemType == Item.REPORTERSCORE)
    238     {
    239       entityClass = ReporterScore.class;
    240       entityName = ReporterListScoreData.class.getName();
    241     }
    242     else if (itemType.getItemClass() != null)
    243     {
    244       entityClass = itemType.getItemClass();
    245     }
    246     else
    247     {
    248       entityClass = itemType.getDataClass();
    249     }
    250     if (entityName != null)
    251     {
    252       metadata = Metadata.getInstance(entityClass, entityName);
    253     }
    254     else if (entityClass != null)
    255     {
    256       metadata = Metadata.getInstance(entityClass);
     233    if (!isSqlQuery)
     234    {
     235      if (itemType == Item.RAWDATA)
     236      {
     237        RawBioAssay rba = RawBioAssay.getById(dc, sc.getCurrentContext(Item.RAWBIOASSAY).getId());
     238        entityName = rba.getRawDataType().getEntityName();
     239        entityClass = RawData.class;
     240      }
     241      else if (itemType == Item.REPORTERSCORE)
     242      {
     243        entityClass = ReporterScore.class;
     244        entityName = ReporterListScoreData.class.getName();
     245      }
     246      else if (itemType.getItemClass() != null)
     247      {
     248        entityClass = itemType.getItemClass();
     249      }
     250      else
     251      {
     252        entityClass = itemType.getDataClass();
     253      }
     254      if (entityName != null)
     255      {
     256        metadata = Metadata.getInstance(entityClass, entityName);
     257      }
     258      else if (entityClass != null)
     259      {
     260        metadata = Metadata.getInstance(entityClass);
     261      }
    257262    }
    258263
     
    291296   
    292297    // Get the query from the current context
    293     Query query = cc.getQuery();
    294298    Set<Integer>selectedItems = cc.getSelected();
    295     if (query instanceof DynamicQuery)
    296     {     
    297       cc.configureQuery(dc, (DynamicQuery)query, properties);
     299    if (isSqlQuery)
     300    {
     301      cc.configureQuery(dc, (SqlQuery)query, properties);
    298302    }
    299303   
     
    517521      queryWrapper = new ReporterScoreQueryWrapper(dc, (ReporterScoreQuery)query);
    518522    }
    519     else if (query instanceof DynamicQuery)
    520     {
    521       DynamicQuery dynamicQuery = (DynamicQuery)query;     
     523    else if (query instanceof SqlQuery)
     524    {
     525      SqlQuery dynamicQuery = (SqlQuery)query;     
    522526      queryWrapper = new DynamicQueryWrapper(dc, dynamicQuery);
    523527    }
  • trunk/src/core/net/sf/basedb/core/AbstractSqlQuery.java

    r5885 r5897  
    5252  @base.modified $Date$
    5353*/
    54 abstract class AbstractSqlQuery
     54public abstract class AbstractSqlQuery
    5555  extends AbstractQuery
    5656  implements SqlQuery
     
    143143    @throws BaseException If there is an error
    144144  */
     145  @Override
    145146  public DynamicResultIterator iterate(DbControl dc)
    146147    throws BaseException
  • trunk/src/core/net/sf/basedb/core/DynamicQuery.java

    r5879 r5897  
    5050public abstract class DynamicQuery
    5151  extends AbstractSqlQuery
     52  implements ClonableReporterQuery
    5253{
    5354
     
    109110  // -------------------------------------------
    110111 
     112  /*
     113    From the ClonableReporterQuery interface
     114    ----------------------------------------
     115  */
    111116  /**
    112117    Check if the virtual database that this query is using has
     
    114119    @since 3.1
    115120  */
     121  @Override
    116122  public boolean hasClonedReporters()
    117123  {
     
    127133    @since 3.1
    128134  */
     135  @Override
    129136  public boolean useClonedReporters()
    130137  {
     
    138145    @since 3.1
    139146  */
     147  @Override
    140148  public void setUseClonedReporters(boolean useClonedReporters)
    141149  {
    142150    this.useClonedReporters = hasClonedReporters && useClonedReporters;
    143151  }
     152 
     153  /**
     154    Get the virtual database that this query is using.
     155    @return A virtual database item
     156    @since 3.1
     157  */
     158  @Override
     159  public VirtualDb getVirtualDb()
     160  {
     161    return virtualDb;
     162  }
     163  // -------------------------------------------
    144164 
    145165  /**
     
    159179    return cube;
    160180  }
    161   /**
    162     Get the virtual database that this query is using.
    163     @return A virtual database item
    164     @since 3.1
    165   */
    166   public VirtualDb getVirtualDb()
    167   {
    168     return virtualDb;
    169   }
     181
    170182  VirtualTable getRootTable()
    171183  {
  • trunk/src/core/net/sf/basedb/core/DynamicReporterQuery.java

    r5885 r5897  
    4343public class DynamicReporterQuery
    4444  extends AbstractSqlQuery
     45  implements ClonableReporterQuery
    4546{
    4647
    47   private final RealTable rootTable;
     48  private final String rootAlias;
     49  private final VirtualDb virtualDb;
     50  private final boolean hasClonedReporters;
     51  private boolean useClonedReporters;
    4852  private Set<Object> joinedItems;
    4953
     
    5458  {
    5559    super(RealTable.REPORTERS.getQualifiedTableName());
    56     this.rootTable = RealTable.REPORTERS;
     60    this.rootAlias = RealTable.REPORTERS.getAlias();
    5761    joinedItems = new HashSet<Object>();
     62    this.virtualDb = null;
     63    this.hasClonedReporters = false;
    5864    setAutoJoinType(JoinType.LEFT);
    5965  }
    6066 
     67  /**
     68    Create a new dynamic query for reporter data using cloned
     69    reporter information.
     70    @since 3.1 
     71  */
    6172  DynamicReporterQuery(VirtualDb vdb)
    6273  {
    6374    super(VirtualTable.CLONED_REPORTERS.getQualifiedTableName(vdb));
    64     this.rootTable = RealTable.REPORTERS;
     75    this.rootAlias = VirtualTable.CLONED_REPORTERS.getAlias();
     76    this.virtualDb = vdb;
     77    this.hasClonedReporters = virtualDb.hasClonedReporters();
     78    this.useClonedReporters = hasClonedReporters;
    6579    joinedItems = new HashSet<Object>();
    6680    setAutoJoinType(JoinType.LEFT);
     
    7791  public String getRootAlias()
    7892  {
    79     return HibernateUtil.quote(rootTable.getAlias());
     93    return HibernateUtil.quote(rootAlias);
    8094  }
    8195  public boolean isReadonly()
     
    98112  // -------------------------------------------
    99113
    100   /*
    101   RealTable getRootTable()
    102   {
    103     return rootTable;
    104   }
    105   */
    106  
     114  /**
     115    Check if the virtual database that this query is using has
     116    cloned reporter annotations or not.
     117    @since 3.1
     118  */
     119  @Override
     120  public boolean hasClonedReporters()
     121  {
     122    return hasClonedReporters;
     123  }
     124 
     125  /**
     126    Checks if this query is using cloned reporter or not by default.
     127    The default setting is to use cloned reporters if they are available
     128    in the experiment.
     129   
     130    @return TRUE if this query is using cloned reporters, FALSE if not
     131    @since 3.1
     132  */
     133  @Override
     134  public boolean useClonedReporters()
     135  {
     136    return useClonedReporters;
     137  }
     138 
     139  /**
     140    Set if cloned reporters should be used by default or not.
     141    @param useClonedReporters TRUE to use cloned reporters by default, FALSE
     142      to use the master reporters
     143    @since 3.1
     144  */
     145  @Override
     146  public void setUseClonedReporters(boolean useClonedReporters)
     147  {
     148    this.useClonedReporters = hasClonedReporters && useClonedReporters;
     149  }
     150 
     151  /**
     152    Get the virtual database that this query is using.
     153    @return A virtual database item (can be null if hasClonedReporter is false)
     154    @since 3.1
     155  */
     156  @Override
     157  public VirtualDb getVirtualDb()
     158  {
     159    return virtualDb;
     160  }
     161  // -------------------------------------------
     162
    107163  /**
    108164      Makes a join with a <code>ReporterList</code>
    109165      @param reporterList To do the join on.
    110166      @param joinType The join type to use.
    111       @see net.sf.basedb.core.query.JoinType
    112       @since 3.0
     167    @see net.sf.basedb.core.query.JoinType
     168    @since 3.0
    113169  */
    114170  public void joinReporterList(ReporterList reporterList, JoinType joinType)
     
    118174    if (!joinedItems.contains(reporterList))
    119175    {
    120       join(new ReporterListJoin(reporterList, joinType, RealTable.REPORTERS, "id"));
     176      if (useClonedReporters())
     177      {
     178        join(new ReporterListJoin(reporterList, joinType, VirtualTable.CLONED_REPORTERS, VirtualColumn.REPORTER_ID_PK));
     179      }
     180      else
     181      {
     182        join(new ReporterListJoin(reporterList, joinType, RealTable.REPORTERS, "id"));
     183      }
    121184      joinedItems.add(reporterList);
     185    }
     186  }
     187 
     188  /**
     189    Join the master reporter table into this query. This is ignored unless the
     190    query rooted at the cloned reporters table.
     191    @param joinType The join type to use
     192    @since 3.1
     193  */
     194  public void joinMasterReporters(JoinType joinType)
     195  {
     196    if (joinType == null) throw new InvalidUseOfNullException("joinType");
     197    if (hasClonedReporters() && !joinedItems.contains(RealTable.REPORTERS))
     198    {
     199      join(new RealJoin(joinType, VirtualTable.CLONED_REPORTERS, RealTable.REPORTERS, VirtualColumn.REPORTER_ID_PK));
     200      joinedItems.add(RealTable.REPORTERS);
    122201    }
    123202  }
     
    133212  {
    134213    addAutoJoiner(getReporterListJoiner(joinType));
     214    addAutoJoiner(getMasterReporterJoiner(joinType));
    135215  }
    136216
     
    146226 
    147227  /**
     228    Get a joiner instance for joining the master reporter table
     229    when the root query is against the cloned reporters table.
     230    @param joinType The type of join
     231    @since 3.1
     232  */
     233  public static MasterReporterJoiner getMasterReporterJoiner(JoinType joinType)
     234  {
     235    return new MasterReporterJoiner(joinType);
     236  }
     237 
     238  /**
    148239    Auto joiner for reporter lists.
    149240    @since 3.0
    150241  */
    151   private static class ReporterListJoiner
     242  static class ReporterListJoiner
    152243    implements AutoJoiner<DynamicReporterQuery, ReporterListExpression>
    153244  {
     
    182273  }
    183274
     275  /**
     276    Auto joiner for master reporter table.
     277    @since 3.1
     278  */
     279  static class MasterReporterJoiner
     280    implements AutoJoiner<DynamicReporterQuery, ReporterPropertyExpression>
     281  {
     282    private final JoinType joinType;
     283 
     284    private MasterReporterJoiner(JoinType joinType)
     285    {
     286      this.joinType = joinType;
     287    }
     288   
     289    /*
     290      From the AutoJoiner interface
     291      -------------------------------------------
     292    */
     293    @Override
     294    public Class<DynamicReporterQuery> getQueryClass()
     295    {
     296      return DynamicReporterQuery.class;
     297    }
     298    @Override
     299    public Class<ReporterPropertyExpression> getElementClass()
     300    {
     301      return ReporterPropertyExpression.class;
     302    }
     303    @Override
     304    public void joinIfNeeded(DynamicReporterQuery query, ReporterPropertyExpression element)
     305    {
     306      query.joinMasterReporters(joinType);
     307    }
     308    // -------------------------------------------
     309  }
     310
    184311}
  • trunk/src/core/net/sf/basedb/core/ItemContext.java

    r5892 r5897  
    3636import net.sf.basedb.core.query.Select;
    3737import net.sf.basedb.core.query.Selects;
     38import net.sf.basedb.core.query.SqlQuery;
    3839import net.sf.basedb.core.data.ContextData;
    3940import net.sf.basedb.core.data.PropertyFilterData;
     
    165166  private static final JepFunction rawCh = new RawChannelFunction();
    166167  private static final JepFunction raw = new RawFunction(true);
    167   private static final JepFunction rep = new ReporterFunction();
     168  private static final JepFunction rep = new ReporterFunction(false);
     169  private static final JepFunction mrep = new ReporterFunction(true);
    168170 
    169171  private final String name;
     
    11511153    that are allowed to be used in queries. If a filter has been set the
    11521154    {@link #configureQuery(DbControl, EntityQuery, boolean)} and
    1153     {@link #configureQuery(DbControl, AbstractSqlQuery, List)} methods will
     1155    {@link #configureQuery(DbControl, SqlQuery, List)} methods will
    11541156    check each property before it is used for sorting, filtering, etc.
    11551157   
     
    13981400 
    13991401  /**
     1402    @deprecated In 3.1, use {@link #configureQuery(DbControl, SqlQuery, List)} instead
     1403  */
     1404  @Deprecated
     1405  public void configureQuery(DbControl dc, AbstractSqlQuery query, List<String> selectionList)
     1406  {
     1407    configureQuery(dc, (SqlQuery)query, selectionList);
     1408  }
     1409
     1410  /**
    14001411    Use the settings in this context to configure a dynamic query.
    14011412    <ul>
     
    14091420    @param selectionList A list of expression that we want to select
    14101421      from the query
    1411     @throws BaseException If the configuring the query fails.
    1412   */
    1413   public void configureQuery(DbControl dc, AbstractSqlQuery query, List<String> selectionList)
     1422    @throws BaseException If the configuring the query fails.
     1423    @since 3.1
     1424  */
     1425  public void configureQuery(DbControl dc, SqlQuery query, List<String> selectionList)
    14141426    throws BaseException
    14151427  {
     
    14861498          {
    14871499            setMessage(ex.getClass().getSimpleName() + ": " + ex.getMessage());
     1500            ex.printStackTrace();
    14881501          }
    14891502        }
     
    15081521    <li>$: The rest of the string is a raw data property name. We use
    15091522      the {@link Dynamic#rawData(String)} to create the expression.
    1510      
     1523
     1524    <li>@@: The rest of the string is a reporter property name. We use
     1525      the {@link Dynamic#reporter(String, Boolean)} with to create the
     1526      expression. The second parameter is FALSE to force using the master
     1527      reporter table.
     1528
    15111529    <li>@: The rest of the string is a reporter property name. We use
    1512       the {@link Dynamic#reporter(String)} to create the expression.
     1530      the {@link Dynamic#reporter(String)} to create the expression
     1531      and let the query decide if it should use the cloned or master
     1532      reporter table.
    15131533     
    15141534    <li>#: The rest of the string is the id of an extra value.
     
    15471567      e = Dynamic.rawData(propertyDef.substring(1));
    15481568    }
     1569    else if (propertyDef.startsWith("@@"))
     1570    {
     1571      // propertyDef is @@reporterPropertyName (from master table)
     1572      e = Dynamic.reporter(propertyDef.substring(2), false);
     1573    }
    15491574    else if (propertyDef.startsWith("@"))
    15501575    {
     
    15671592    {
    15681593      // propertyDef is JEP expression
    1569       e = Jep.formulaToExpression(propertyDef.substring(1), ch, rawCh, raw, rep);
     1594      e = Jep.formulaToExpression(propertyDef.substring(1), ch, rawCh, raw, rep, mrep);
    15701595    }
    15711596    else
     
    16071632      s = Dynamic.selectRawData(propertyDef.substring(1));
    16081633    }
     1634    else if (propertyDef.startsWith("@@"))
     1635    {
     1636      // propertyDef is @@reporterPropertyName (from master table)
     1637      s = Dynamic.selectReporter(propertyDef.substring(2), false);
     1638    }
    16091639    else if (propertyDef.startsWith("@"))
    16101640    {
     
    16271657    {
    16281658      // propertyDef is JEP expression
    1629       Expression e = Jep.formulaToExpression(propertyDef.substring(1), ch, rawCh, raw, rep);
     1659      Expression e = Jep.formulaToExpression(propertyDef.substring(1), ch, rawCh, raw, rep, mrep);
    16301660      s = Selects.expression(e, "jep" + System.identityHashCode(e));
    16311661    }
  • trunk/src/core/net/sf/basedb/core/ReporterCloneBatcher.java

    r5886 r5897  
    283283     
    284284      PreparedStatement insertSql = buildInsertSql();
    285    
    286       System.out.println("sql: " + (query != null ? query.toQl(dc) : rawQuery.toQl(dc)));
    287285     
    288286      DynamicResultIterator it = query != null ? query.iterate(dc) : rawQuery.iterate(dc);
  • trunk/src/core/net/sf/basedb/core/ReporterPropertyExpression.java

    r5881 r5897  
    9696      String joinAlias = RealTable.REPORTERS.getAlias();
    9797     
    98       if (query instanceof DynamicQuery)
     98      if (query instanceof ClonableReporterQuery)
    9999      {
    100         DynamicQuery dynamicQuery = (DynamicQuery)query;
    101         if (useCloned(dynamicQuery))
     100        ClonableReporterQuery clonableQuery = (ClonableReporterQuery)query;
     101        if (useCloned(clonableQuery))
    102102        {
    103           if (!dc.loadItem(dynamicQuery.getVirtualDb()).hasClonedReporterProperty(property))
     103          if (!dc.loadItem(clonableQuery.getVirtualDb()).hasClonedReporterProperty(property))
    104104          {
    105105            throw new InvalidDataException("Reporter property is not cloned: " + property);
     
    164164    @since 3.1
    165165  */
    166   public boolean useCloned(DynamicQuery query)
     166  public boolean useCloned(ClonableReporterQuery query)
    167167  {
    168168    // Check if the virtual database has cloned reporters
  • trunk/src/core/net/sf/basedb/core/query/Expressions.java

    r5429 r5897  
    152152    if (value == null) throw new InvalidUseOfNullException("value");
    153153    return parameter("P" + MD5.getHashString(value), value);
     154  }
     155 
     156  /**
     157    Create a constant expression from a boolean.
     158    @param value The value to create an expression for
     159    @return The expression
     160    @since 3.1
     161  */
     162  public static Expression bool(boolean value)
     163  {
     164    return new BooleanExpression(value);
     165  }
     166 
     167  /**
     168    Create a boolean expression view of a restriction.
     169    @param restriction The restriction
     170    @return The expression
     171    @since 3.1
     172  */
     173  public static Expression bool(Restriction restriction)
     174  {
     175    if (restriction == null) throw new InvalidUseOfNullException("restriction");
     176    return new BooleanExpression(restriction);
    154177  }
    155178 
  • trunk/src/core/net/sf/basedb/core/query/SqlQuery.java

    r4889 r5897  
    2323package net.sf.basedb.core.query;
    2424
     25import net.sf.basedb.core.DbControl;
     26import net.sf.basedb.core.DynamicResultIterator;
     27
    2528/**
    2629  This is a query that is using SQL as the query language. All
     
    3437public interface SqlQuery
    3538  extends Query
    36 {}
     39{
     40  public DynamicResultIterator iterate(DbControl dc);
     41}
  • trunk/src/core/net/sf/basedb/util/jep/ReporterFunction.java

    r5319 r5897  
    3939
    4040/**
    41   A JEP function class that adds a <code>rep(string)</code> function to a
    42   JEP expression parser. The function will look up the value of the reporter
     41  A JEP function class that adds a <code>rep(string)</code> or <code>mrep(string)</code>
     42  function to a  JEP expression parser. The function will look up the value of the reporter
    4343  property with the given name. For example:
    4444  <code>rep('sequence')</code>
     45  <p>
     46  If the <code>mrep</code> variant is used, the master reporter table is used,
     47  otherwise the actual query can decide if it should use cloned reporter information
     48  or not.
    4549  <p>
    4650  To be able to use this function it must be registered with the JEP
     
    7781  private final Metadata<ReporterData> metaData;
    7882  private final DbControl dc;
     83  private final boolean master;
    7984  private int numParameters;
    8085  private ReporterData reporter;
     
    8893  public ReporterFunction()
    8994  {
     95    this(false);
     96  }
     97 
     98  /**
     99    Create a new instance of this function. The new instance cannot be used
     100    to dynamically evaluate expressions. It should only be used for converting
     101    JEP formulas to {@link Expression}:s. If
     102   
     103    @since 3.1
     104    @param master TRUE to force using the master reporter table, FALSE to let
     105      the query decide
     106  */
     107  public ReporterFunction(boolean master)
     108  {
    90109    this.dc = null;
    91110    this.metaData = null;
     111    this.master = master;
    92112  }
    93113 
     
    99119    this.dc = dc;
    100120    this.metaData = Metadata.getInstance(ReporterData.class);
     121    this.master = false;
    101122  }
    102123 
     
    106127  */
    107128  /**
    108     @return The string "rep"
     129    @return The string "rep" or "mrep"
    109130  */
    110131  public String getFunctionName()
    111132  {
    112     return "rep";
     133    return master ? "mrep" : "rep";
    113134  }
    114135  // -------------------------------------------
     
    128149      throw new BaseException("Invalid number of expressions for 'rep' function: " + numChildren);
    129150    }
    130     return Dynamic.reporter(Jep.nodeToString(node.jjtGetChild(0)));
     151    return Dynamic.reporter(Jep.nodeToString(node.jjtGetChild(0)), master ? false : null);
    131152  }
    132153  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/util/jep/convert/AbstractJepConversionFunction.java

    r4515 r5897  
    2323
    2424import net.sf.basedb.core.query.Expression;
     25import net.sf.basedb.core.query.Expressions;
    2526import net.sf.basedb.core.query.Restriction;
    2627
     
    7677  }
    7778  /**
    78     @throws UnsupportedOperationException Always
     79    Convert to a restriction and then use {@link Expressions#bool(Restriction)}
     80    to create a boolean expression.
    7981  */
    8082  public Expression toExpression(T node)
    8183  {
    82     throw new UnsupportedOperationException("toExpression");
     84    return Expressions.bool(toRestriction(node));
    8385  }
    8486
     
    8890  public Restriction toRestriction(T node)
    8991  {
    90     throw new UnsupportedOperationException("toRestriction");
     92    throw new UnsupportedOperationException(getClass() + ".toRestriction()");
    9193  }
    9294  // -------------------------------------------
  • trunk/www/views/experiments/bioassaysets/list_bioassaysets.jsp

    r5590 r5897  
    210210        location.href = '../index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=experimentId%>&tab='+tabId;
    211211      }
     212      else if (tabId == 'clonedreporters')
     213      {
     214        viewClonedReporters();
     215      }
    212216      else
    213217      {
    214218        TabControl.setActiveTab(tabControlId, tabId);
    215219      }
     220    }
     221    function viewClonedReporters()
     222    {
     223      location.href = '../reporters/index.jsp?ID=<%=ID%>&experiment_id=<%=experimentId%>';
    216224    }
    217225    </script>
     
    241249    </base:buttongroup>
    242250    </t:tab>
     251   
     252    <t:tab id="clonedreporters" title="Cloned reporters"
     253      visible="<%=experiment.getVirtualDb().hasClonedReporters() %>"/>
     254   
    243255    <t:tab id="overview" title="Overview"
    244256      tooltip="Display a tree overview of related items" />
  • trunk/www/views/experiments/index.jsp

    r5886 r5897  
    2424  @version 2.0
    2525--%>
    26 <%@page import="net.sf.basedb.core.StringParameterType"%>
    2726<%@ page pageEncoding="UTF-8" session="false"
    2827  import="net.sf.basedb.core.SessionControl"
     
    4241  import="net.sf.basedb.core.Job"
    4342  import="net.sf.basedb.core.ItemParameterType"
     43  import="net.sf.basedb.core.StringParameterType"
    4444  import="net.sf.basedb.core.ItemQuery"
    4545  import="net.sf.basedb.core.ItemResultIterator"
  • trunk/www/views/experiments/view_experiment.jsp

    r5886 r5897  
    171171      location.href = 'bioassaysets/index.jsp?ID=<%=ID%>&experiment_id=<%=itemId%>';
    172172    }
     173    function viewClonedReporters()
     174    {
     175      location.href = 'reporters/index.jsp?ID=<%=ID%>&experiment_id=<%=itemId%>';
     176    }
    173177    function switchTab(tabControlId, tabId)
    174178    {
     
    177181      {
    178182        location.href = 'index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=itemId%>&tab='+tabId;
     183      }
     184      else if (tabId == 'clonedreporters')
     185      {
     186        viewClonedReporters();
    179187      }
    180188      else if (tabId == 'bioassaysets')
     
    885893     
    886894      <t:tab id="bioassaysets" title="Bioassay sets" />
     895      <t:tab id="clonedreporters"
     896        title="Cloned reporters"
     897        visible="<%=virtualDb.hasClonedReporters() %>"
     898        tooltip="Show information about cloned reporters"
     899      />
    887900      <t:tab id="overview" title="Overview"
    888901        tooltip="Display a tree overview of related items">
  • trunk/www/views/reporterlists/index.jsp

    r5757 r5897  
    3535  import="net.sf.basedb.core.DataQuery"
    3636  import="net.sf.basedb.core.ItemQuery"
    37   import="net.sf.basedb.core.DynamicQuery"
     37  import="net.sf.basedb.core.query.SqlQuery"
    3838  import="net.sf.basedb.core.DataResultIterator"
    3939  import="net.sf.basedb.core.DynamicResultIterator"
     
    191191            }
    192192          }
    193           else if (query instanceof DynamicQuery)
    194           {
    195             DynamicResultIterator result = ((DynamicQuery)query).iterate(dc);
     193          else if (query instanceof SqlQuery)
     194          {
     195            DynamicResultIterator result = ((SqlQuery)query).iterate(dc);
    196196            while (result.hasNext())
    197197            {
Note: See TracChangeset for help on using the changeset viewer.