Changeset 5885


Ignore:
Timestamp:
Nov 22, 2011, 4:17:37 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

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

Updated Experiment explorer to use cloned information when possible. Renamed ClonedProperty to ClonableProperty.

Location:
trunk
Files:
16 edited
1 moved

Legend:

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

    r5879 r5885  
    2424
    2525import net.sf.basedb.core.BioAssaySet;
    26 import net.sf.basedb.core.ClonedProperty;
     26import net.sf.basedb.core.ClonableProperty;
    2727import net.sf.basedb.core.ExtendedProperties;
    2828import net.sf.basedb.core.ExtendedProperty;
     
    182182    }
    183183    SessionControl sc = dc.getSessionControl();
    184     for (ClonedProperty cp : template.getClonedProperties())
     184    for (ClonableProperty cp : template.getClonableProperties())
    185185    {
    186186      String name = cp.getName();
  • trunk/src/clients/web/net/sf/basedb/clients/web/ExperimentExplorer.java

    r5711 r5885  
    5252import net.sf.basedb.core.DynamicResultIterator;
    5353import net.sf.basedb.core.DynamicSpotQuery;
     54import net.sf.basedb.core.Experiment;
    5455import net.sf.basedb.core.Formula;
    5556import net.sf.basedb.core.Include;
     
    6263import net.sf.basedb.core.SessionControl;
    6364import net.sf.basedb.core.VirtualColumn;
     65import net.sf.basedb.core.VirtualDb;
    6466import net.sf.basedb.core.VirtualTable;
    6567import net.sf.basedb.core.ItemContext.SortDirection;
     
    136138  */
    137139  private static final ItemContext defaultReporterContext =
    138     Base.createDefaultContext("@externalId", "name,externalId");
     140    Base.createDefaultContext("@externalId", "externalId");
    139141 
    140142  /**
     
    186188  private final BioAssaySet bioAssaySet;
    187189 
     190  private final Experiment experiment;
     191 
     192  private final VirtualDb virtualDb;
     193 
    188194  /**
    189195    The snapshot manager that loads annotation values.
     
    237243  {
    238244    this.bioAssaySet = bioAssaySet;
     245    this.experiment = bioAssaySet.getExperiment();
     246    this.virtualDb = experiment.getVirtualDb();
    239247    this.bioAssays = new HashMap<Short, Integer>();
    240248    this.snapshotManager = new SnapshotManager();
     
    256264    return BioAssaySet.getById(dc, bioAssaySet.getId());
    257265  }
    258  
     266
     267  /**
     268    Get the experiment that is currently beeing explored.
     269    @param dc The DbControl used for access the database
     270    @return The <code>Experiment</code> object
     271  */
     272  public Experiment getExperiment(DbControl dc)
     273  {
     274    return Experiment.getById(dc, experiment.getId());
     275  }
     276
    259277  /**
    260278    Get the snapshot manager that is used to load annotation
     
    531549  /**
    532550    Get the reporter for the specified index. The index should be between
    533     0 and the number of matching reporters minus 1.
     551    0 and the number of matching reporters minus 1. The returned reporter
     552    information is taken from the cloned table if that is present in the
     553    current experiment.
    534554   
    535555    @param dc The DbControl to use for database access
     
    542562    if (cache == null) initReporterCache(dc);
    543563    int reporterId = index >= 0 && index < cache.length ? cache[index].id : 0;
    544     return reporterId == 0 ? null : Reporter.getById(dc, reporterId);
     564   
     565    return reporterId == 0 ? null : Reporter.getById(dc, reporterId, getExperiment(dc));
    545566  }
    546567
     
    685706   
    686707    // Create reporter query
    687     DynamicReporterQuery reporterQuery = Reporter.getDynamicQuery();
     708    DynamicReporterQuery reporterQuery = Reporter.getDynamicQuery(getExperiment(dc));
    688709    // Guard against no hits
    689710    if (reporterIds.size() == 0) reporterIds.add(-1);
  • trunk/src/core/net/sf/basedb/core/AbstractSqlQuery.java

    r5881 r5885  
    233233      else
    234234      {
    235         releaseSavepoint(conn, savepoint, currentSql);
     235        if (savepoint != null) releaseSavepoint(conn, savepoint, currentSql);
    236236      }
    237237    }
  • trunk/src/core/net/sf/basedb/core/ClonableProperty.java

    r5879 r5885  
    4040  @base.modified $Date$
    4141*/
    42 public class ClonedProperty
     42public class ClonableProperty
    4343  extends ExtendedProperty
    44   implements Comparable<ClonedProperty>
     44  implements Comparable<ClonableProperty>
    4545{
    4646 
     
    7676  public static String SYMBOL = "symbol";
    7777
     78  /**
     79    The property name of the "static" property {@link ReporterData#getEntryDate()}
     80  */
     81  public static String ENTRY_DATE = "entryDate";
     82
     83  /**
     84    The property name of the "static" property {@link ReporterData#getLastSource()}
     85  */
     86  public static String LAST_SOURCE = "lastSource";
     87
     88  /**
     89    The property name of the "static" property {@link ReporterData#getLastUpdate()}
     90  */
     91  public static String LAST_UPDATE = "lastUpdate";
     92
     93  /**
     94    The property name of the "static" property {@link ReporterData#getDescription()}
     95  */
     96  public static String DESCRIPTION = "description";
    7897
    7998  /**
     
    85104      doesn't exist
    86105  */
    87   public static ClonedProperty createFromRegular(String name)
    88   {
    89     ClonedProperty property = null;
     106  public static ClonableProperty createFromRegular(String name)
     107  {
     108    ClonableProperty property = null;
    90109    if (ID.equals(name))
    91110    {
    92       property = new ClonedProperty(ID, "Id", "The internal id of the reporter", "id",
     111      property = new ClonableProperty(ID, "Id", "The internal id of the reporter", "id",
    93112        Type.INT, 0, !NULLABLE, AverageMethod.NONE, MANDATORY);
    94113    }
    95114    else if (VERSION.equals(name))
    96115    {
    97       property = new ClonedProperty(VERSION, "Version", "The internal version number of the reporter", "version",
     116      property = new ClonableProperty(VERSION, "Version", "The internal version number of the reporter", "version",
    98117        Type.INT, 0, !NULLABLE, AverageMethod.NONE, MANDATORY);
    99118    }
    100119    else if (EXTERNAL_ID.equals(name))
    101120    {
    102       property = new ClonedProperty(EXTERNAL_ID, "External ID", "The external id of the reporter", "external_id",
     121      property = new ClonableProperty(EXTERNAL_ID, "External ID", "The external id of the reporter", "external_id",
    103122        Type.STRING, ReporterData.MAX_EXTERNAL_ID_LENGTH, !NULLABLE, AverageMethod.NONE, MANDATORY);
    104123    }
    105124    else if (NAME.equals(name))
    106125    {
    107       property = new ClonedProperty(NAME, "Name", "The name of the reporter", "name",
     126      property = new ClonableProperty(NAME, "Name", "The name of the reporter", "name",
    108127        Type.STRING, ReporterData.MAX_NAME_LENGTH, !NULLABLE, AverageMethod.NONE, !MANDATORY);
    109128    }
    110129    else if (SYMBOL.equals(name))
    111130    {
    112       property = new ClonedProperty(SYMBOL, "Symbol", "", "symbol",
     131      property = new ClonableProperty(SYMBOL, "Symbol", "The gene symbol for the reporter", "symbol",
    113132        Type.STRING, ReporterData.MAX_SYMBOL_LENGTH, NULLABLE, AverageMethod.NONE, !MANDATORY);
     133    }
     134    else if (ENTRY_DATE.equals(name))
     135    {
     136      property = new ClonableProperty(ENTRY_DATE, "Entry date", "The date this reporter was registered in the database", "entry_date",
     137        Type.DATE, 0, NULLABLE, AverageMethod.NONE, !MANDATORY);
     138    }
     139    else if (LAST_SOURCE.equals(name))
     140    {
     141      property = new ClonableProperty(LAST_SOURCE, "Last source", "The source (file) of the last update to the reporter", "last_source",
     142        Type.STRING, ReporterData.MAX_LAST_SOURCE_LENGTH, NULLABLE, AverageMethod.NONE, !MANDATORY);
     143    }
     144    else if (LAST_UPDATE.equals(name))
     145    {
     146      property = new ClonableProperty(LAST_UPDATE, "Last update", "The date and time this reporter was last updated", "last_update",
     147        Type.TIMESTAMP, 0, NULLABLE, AverageMethod.NONE, !MANDATORY);
     148    }
     149    else if (DESCRIPTION.equals(name))
     150    {
     151      property = new ClonableProperty(DESCRIPTION, "Description", "A custom description", "description",
     152        Type.TEXT, ReporterData.MAX_DESCRIPTION_LENGTH, NULLABLE, AverageMethod.NONE, !MANDATORY);
    114153    }
    115154    else
     
    127166      doesn't exist
    128167  */
    129   public static ClonedProperty createFromExtended(String name)
     168  public static ClonableProperty createFromExtended(String name)
    130169  {
    131170    ExtendedProperty ep = ExtendedProperties.getProperty("ReporterData", name);
     
    134173      throw new ItemNotFoundException("ExtendedProperty[name="+name+"]");
    135174    }
    136     return new ClonedProperty(ep);
     175    return new ClonableProperty(ep);
    137176  }
    138177 
     
    146185      doesn't exist
    147186  */
    148   public static ClonedProperty create(String name)
    149   {
    150     ClonedProperty property = null;
     187  public static ClonableProperty create(String name)
     188  {
     189    ClonableProperty property = null;
    151190    ExtendedProperty ep = ExtendedProperties.getProperty("ReporterData", name);
    152191    if (ep == null)
     
    156195    else
    157196    {
    158       property = new ClonedProperty(ep);
     197      property = new ClonableProperty(ep);
    159198    }
    160199    return property;
     
    165204    extended properties.
    166205  */
    167   public static List<ClonedProperty> getAll()
    168   {
    169     List<ClonedProperty> all = getAllMandatory();
     206  public static List<ClonableProperty> getAll()
     207  {
     208    List<ClonableProperty> all = getAllMandatory();
    170209    // Other static properties
    171210    all.add(createFromRegular(NAME));
    172211    all.add(createFromRegular(SYMBOL));
     212    all.add(createFromRegular(DESCRIPTION));
     213    all.add(createFromRegular(ENTRY_DATE));
     214    all.add(createFromRegular(LAST_SOURCE));
     215    all.add(createFromRegular(LAST_UPDATE));
    173216    // All extended properties
    174217    List<ExtendedProperty> extended = ExtendedProperties.getProperties("ReporterData");
    175218    for (ExtendedProperty ep : extended)
    176219    {
    177       all.add(new ClonedProperty(ep));
     220      all.add(new ClonableProperty(ep));
    178221    }
    179222    Collections.sort(all);
     
    184227    Get a list with all mandatory properties that must be cloned.
    185228  */
    186   public static List<ClonedProperty> getAllMandatory()
    187   {
    188     List<ClonedProperty> mandatory = new ArrayList<ClonedProperty>();
     229  public static List<ClonableProperty> getAllMandatory()
     230  {
     231    List<ClonableProperty> mandatory = new ArrayList<ClonableProperty>();
    189232    mandatory.add(createFromRegular(ID));
    190233    mandatory.add(createFromRegular(VERSION));
     
    199242    Create a cloned property representation of a static property.
    200243  */
    201   private ClonedProperty(String propertyName, String title, String description,
     244  private ClonableProperty(String propertyName, String title, String description,
    202245      String column, Type valueType, int length, boolean nullable, AverageMethod averageMethod, boolean isMandatory)
    203246  {
     
    213256    @param p The extended property to clone
    214257  */
    215   private ClonedProperty(ExtendedProperty p)
     258  private ClonableProperty(ExtendedProperty p)
    216259  {
    217260    super(p.getName(), p.getTitle(), p.getDescription(), p.getColumn(),
     
    228271    @param d Other metadata for the property
    229272  */
    230   ClonedProperty(String propertyName, ReporterClonePropertyData d)
     273  ClonableProperty(String propertyName, ReporterClonePropertyData d)
    231274  {
    232275    super(propertyName, d.getTitle(), d.getDescription(), d.getColumn(),
     
    296339    if (this == o) return true;
    297340    if (o == null) return false;
    298     if (o.getClass() != ClonedProperty.class) return false;
    299     ClonedProperty other = (ClonedProperty)o;
     341    if (o.getClass() != ClonableProperty.class) return false;
     342    ClonableProperty other = (ClonableProperty)o;
    300343    return getName().equals(other.getName());
    301344  }
     
    315358  */
    316359  @Override
    317   public int compareTo(ClonedProperty o)
     360  public int compareTo(ClonableProperty o)
    318361  {
    319362    if (isMandatory() != o.isMandatory())
  • trunk/src/core/net/sf/basedb/core/DynamicReporterQuery.java

    r5711 r5885  
    5959  }
    6060 
     61  DynamicReporterQuery(VirtualDb vdb)
     62  {
     63    super(VirtualTable.CLONED_REPORTERS.getQualifiedTableName(vdb));
     64    this.rootTable = RealTable.REPORTERS;
     65    joinedItems = new HashSet<Object>();
     66    setAutoJoinType(JoinType.LEFT);
     67  }
     68 
    6169  /*
    6270    From the Query interface
     
    9098  // -------------------------------------------
    9199
     100  /*
    92101  RealTable getRootTable()
    93102  {
    94103    return rootTable;
    95104  }
     105  */
    96106 
    97107  /**
  • trunk/src/core/net/sf/basedb/core/Reporter.java

    r4889 r5885  
    2424package net.sf.basedb.core;
    2525
     26import java.util.List;
     27
    2628import net.sf.basedb.core.data.ReporterData;
    2729import net.sf.basedb.core.data.ReporterTypeData;
    2830
    2931import org.hibernate.EntityMode;
     32import org.hibernate.SQLQuery;
    3033import org.hibernate.metadata.ClassMetadata;
    3134
     
    8790 
    8891  /**
     92    Get a {@link ReporterData} object when you know the ID, possibly
     93    using the cloned reporter annotations of the given experiment.
     94    If the experiment doesn't have cloned reporter information this
     95    method is the same as {@link #getById(DbControl, int)}. If
     96    the experiment has cloned information, all non-cloned properties
     97    are set to null.
     98   
     99    @param dc The <code>DbControl</code> which will be used for
     100      permission checking and database access
     101    @param id The ID of the reporter
     102    @param experiment The experiment which may have cloned reporter information
     103    @return The <code>ReporterData</code> object
     104    @since 3.1
     105  */
     106  public static ReporterData getById(DbControl dc, int id, Experiment experiment)
     107  {
     108    VirtualDb vdb = experiment == null ? null : experiment.getVirtualDb();
     109    if (vdb != null && vdb.hasClonedReporters())
     110    {
     111      String sql = getClonedSelectSql(vdb);
     112      sql += " where " + HibernateUtil.quote("id") + "=:id";
     113      SQLQuery q = HibernateUtil.createSqlQuery(dc.getStatelessSession(), sql.toString());
     114      q.setInteger("id", id);
     115      q.addEntity(ReporterData.class);
     116      ReporterData rd = HibernateUtil.loadData(ReporterData.class, q);
     117      if (rd == null) throw new ItemNotFoundException("Reporter[id="+id+"]");
     118      return rd;
     119    }
     120    else
     121    {
     122      return getById(dc, id);
     123    }
     124  }
     125 
     126  /**
    89127    Get a {@link ReporterData} object when you know the external id. Use
    90128    this method only when you need to get a few reporters. If you need
     
    120158  }
    121159 
     160  /**
     161    Get a {@link ReporterData} object when you know the external id, possibly
     162    using the cloned reporter annotations of the given experiment.
     163    If the experiment doesn't have cloned reporter information this
     164    method is the same as {@link #getByExternalId(DbControl, String)}.
     165    If  the experiment has cloned information, all non-cloned properties
     166    are set to null.
     167    <p>
     168   
     169    Use this method only when you need to get a few reporters. If you need
     170    to get many reporter use the {@link ReporterCloneBatcher#getByExternalId(String)}
     171    method instead. It has better performance since it resuses a single
     172    query instead of creating a new one each time as this method does.
     173
     174    @param dc The <code>DbControl</code> which will be used for
     175      permission checking and database access
     176    @param externalId The external id of the reporter
     177    @param experiment The experiment which may have cloned reporter information
     178    @return The <code>ReporterData</code> object
     179    @since 3.1
     180  */
     181  public static ReporterData getByExternalId(DbControl dc, String externalId, Experiment experiment)
     182  {
     183    if (externalId != null) externalId = externalId.trim();
     184    VirtualDb vdb = experiment == null ? null : experiment.getVirtualDb();
     185    if (vdb != null && vdb.hasClonedReporters())
     186    {
     187      String sql = getClonedSelectSql(vdb);
     188      sql += " where " + HibernateUtil.quote("external_id") + "=:id";
     189      SQLQuery q = HibernateUtil.createSqlQuery(dc.getStatelessSession(), sql.toString());
     190      q.setString("id", externalId);
     191      q.addEntity(ReporterData.class);
     192      ReporterData rd = HibernateUtil.loadData(ReporterData.class, q);
     193      if (rd == null) throw new ItemNotFoundException("Reporter[externalId="+externalId+"]");
     194      return rd;
     195    }
     196    else
     197    {
     198      return getByExternalId(dc, externalId);
     199    }
     200  }
     201
    122202  /**
    123203    Get a proxy reporter object. This method is usefult when linking
     
    163243 
    164244  /**
     245    Get a dynamic query object configured to retrieve reporter
     246    information from either the master reporter table or a
     247    cloned reporter table in the given experiment.
     248    You must add columns/expressions to select with
     249    {@link net.sf.basedb.core.query.Query#select(net.sf.basedb.core.query.Select)}
     250    @return A {@link DynamicReporterQuery} object
     251    @since 3.1
     252  */
     253  public static DynamicReporterQuery getDynamicQuery(Experiment experiment)
     254  {
     255    if (experiment != null && experiment.getVirtualDb().hasClonedReporters())
     256    {
     257      return new DynamicReporterQuery(experiment.getVirtualDb());
     258    }
     259    else
     260    {
     261      return new DynamicReporterQuery();
     262    }
     263  }
     264 
     265  /**
    165266    Get the reporter type item from a reporter data object.
    166267   
     
    196297  }
    197298 
     299  /**
     300    Generate an SQL statement for selecting ALL reporter properties from a cloned
     301    table. Properties that have not been cloned should be included as 'null'
     302    selects.
     303  */
     304  private static String getClonedSelectSql(VirtualDb vdb)
     305  {
     306    ReporterCloneTemplate template = vdb.getReporterCloneTemplate();
     307    List<ClonableProperty> all = ClonableProperty.getAll();
     308    StringBuilder sql = new StringBuilder();
     309    sql.append("select ");
     310    for (ClonableProperty cp : all)
     311    {
     312      if (template.hasClonableProperty(cp.getName()))
     313      {
     314        sql.append(HibernateUtil.quote(cp.getColumn()));
     315      }
     316      else
     317      {
     318        sql.append("null as " + HibernateUtil.quote(cp.getColumn()));
     319      }
     320      sql.append(",");
     321    }
     322    sql.append("null as ").append(HibernateUtil.quote("reportertype_id"));
     323    sql.append(" from ").append(VirtualTable.CLONED_REPORTERS.getQualifiedTableName(vdb));
     324    return sql.toString();
     325  }
    198326}
  • trunk/src/core/net/sf/basedb/core/ReporterCloneBatcher.java

    r5879 r5885  
    318318  private DynamicPositionQuery buildSelectQuery()
    319319  {
    320     List<ClonedProperty> cloned = virtualDb.getReporterCloneTemplate().getClonedProperties();
     320    List<ClonableProperty> cloned = virtualDb.getReporterCloneTemplate().getClonableProperties();
    321321    parameterTypes = new int[cloned.size()+1];
    322322   
     
    329329
    330330    int index = 1;
    331     for (ClonedProperty cp : cloned)
    332     {
    333       query.select(Selects.expression(Dynamic.reporter(cp.getName()), "cp" + index, cp.getName().equals(ClonedProperty.ID)));
     331    for (ClonableProperty cp : cloned)
     332    {
     333      query.select(Selects.expression(Dynamic.reporter(cp.getName()), "cp" + index, cp.getName().equals(ClonableProperty.ID)));
    334334      parameterTypes[index] = cp.getType().getTypeWrapper().getSQLType();
    335335      index++;
  • trunk/src/core/net/sf/basedb/core/ReporterCloneTemplate.java

    r5879 r5885  
    7474    t.setName("New reporter clone template");
    7575    t.getData().setEntryDate(new Date());
    76     for (ClonedProperty cp : ClonedProperty.getAll())
    77     {
    78       if (cp.isMandatory()) t.addClonedProperty(cp);
     76    for (ClonableProperty cp : ClonableProperty.getAll())
     77    {
     78      if (cp.isMandatory()) t.addClonableProperty(cp);
    7979    }
    8080    return t;
     
    261261
    262262  /**
    263     Add a cloned property to this template.
     263    Add a clonable property to this template.
    264264    @param property Information about the property to include in the
    265265      template (null is not allowed)
    266266  */
    267   public void addClonedProperty(ClonedProperty property)
     267  public void addClonableProperty(ClonableProperty property)
    268268  {
    269269    checkPermission(Permission.WRITE);
     
    276276    @param propertyName The name of a property (null is not allowed)
    277277  */
    278   public void removeClonedProperty(String propertyName)
     278  public void removeClonableProperty(String propertyName)
    279279  {
    280280    checkPermission(Permission.WRITE);
    281281    if (propertyName == null) throw new InvalidUseOfNullException("propertyName");
    282     ClonedProperty cp = getClonedProperty(propertyName);
     282    ClonableProperty cp = getClonableProperty(propertyName);
    283283    if (cp != null)
    284284    {
     
    292292 
    293293  /**
    294     Get information about a cloned property that is included in this template.
     294    Get information about a clonable property that is included in this template.
    295295    @param propertyName The name of a property
    296296    @return Cloned property information, or null if the named property is not
    297297      part of this template
    298298  */
    299   public ClonedProperty getClonedProperty(String propertyName)
     299  public ClonableProperty getClonableProperty(String propertyName)
    300300  {
    301301    ReporterClonePropertyData data = getData().getProperties().get(propertyName);
    302     return data == null ? null : new ClonedProperty(propertyName, data);
    303   }
    304  
    305   /**
    306     Check if this template contains a cloned property with
     302    return data == null ? null : new ClonableProperty(propertyName, data);
     303  }
     304 
     305  /**
     306    Check if this template contains a clonable property with
    307307    the given name.
    308308    @param propertyName The property name to check
    309309    @return TRUE if the template contains the given property, FALSE if not
    310310  */
    311   public boolean hasClonedProperty(String propertyName)
     311  public boolean hasClonableProperty(String propertyName)
    312312  {
    313313    return getData().getProperties().containsKey(propertyName);
     
    315315 
    316316  /**
    317     Get a list with all cloned properties in this template. The returned list
     317    Get a list with all clonable properties in this template. The returned list
    318318    is a copy of the information in this template and modifications to the list
    319319    do not affect this template.
    320320    @return A list with cloned properties
    321321  */
    322   public List<ClonedProperty> getClonedProperties()
     322  public List<ClonableProperty> getClonableProperties()
    323323  {
    324324    Set<Map.Entry<String, ReporterClonePropertyData>> properties = getData().getProperties().entrySet();
    325     List<ClonedProperty> list = new ArrayList<ClonedProperty>(properties.size());
     325    List<ClonableProperty> list = new ArrayList<ClonableProperty>(properties.size());
    326326    for (Map.Entry<String, ReporterClonePropertyData> data : properties)
    327327    {
    328       ClonedProperty cp = new ClonedProperty(data.getKey(), data.getValue());
     328      ClonableProperty cp = new ClonableProperty(data.getKey(), data.getValue());
    329329      int insertIndex = Collections.binarySearch(list, cp);
    330330      if (insertIndex < 0) list.add(-1-insertIndex, cp);
     
    350350    for (Map.Entry<String, ReporterClonePropertyData> entry : getData().getProperties().entrySet())
    351351    {
    352       ClonedProperty cp = new ClonedProperty(entry.getKey(), entry.getValue());
     352      ClonableProperty cp = new ClonableProperty(entry.getKey(), entry.getValue());
    353353      propertiesCopy.put(cp.getName(), cp.toData());
    354354    }
  • trunk/src/core/net/sf/basedb/core/VirtualColumn.java

    r5879 r5885  
    255255    @since 3.1
    256256  */
    257   public static VirtualColumn clonedProperty(ClonedProperty property)
     257  public static VirtualColumn clonableProperty(ClonableProperty property)
    258258  {
    259259    VirtualColumn vc = null;
     
    264264      // than a ClonedProperty item can
    265265      String name = property.getName();
    266       if (ClonedProperty.ID.equals(name))
     266      if (ClonableProperty.ID.equals(name))
    267267      {
    268268        vc = VirtualColumn.REPORTER_ID_PK;
    269269      }
    270       else if (ClonedProperty.VERSION.equals(name))
     270      else if (ClonableProperty.VERSION.equals(name))
    271271      {
    272272        vc = VirtualColumn.REPORTER_VERSION;
    273273      }
    274       else if (ClonedProperty.EXTERNAL_ID.equals(name))
     274      else if (ClonableProperty.EXTERNAL_ID.equals(name))
    275275      {
    276276        vc = VirtualColumn.REPORTER_EXTERNAL_ID;
  • trunk/src/core/net/sf/basedb/core/VirtualTable.java

    r5879 r5885  
    267267      // The default columns should be included
    268268      ReporterCloneTemplate cloneTemplate = vdb.getReporterCloneTemplate();
    269       List<ClonedProperty> properties = cloneTemplate.getClonedProperties();
     269      List<ClonableProperty> properties = cloneTemplate.getClonableProperties();
    270270      VirtualColumn[] allColumns = new VirtualColumn[properties.size()];
    271271     
    272272      int index = 0;
    273       for (ClonedProperty cp : properties)
     273      for (ClonableProperty cp : properties)
    274274      {
    275         allColumns[index] = VirtualColumn.clonedProperty(cp);
     275        allColumns[index] = VirtualColumn.clonableProperty(cp);
    276276        index++;
    277277      }
  • trunk/src/test/TestReporterCloneTemplate.java

    r5877 r5885  
    2222
    2323import net.sf.basedb.core.BaseException;
    24 import net.sf.basedb.core.ClonedProperty;
     24import net.sf.basedb.core.ClonableProperty;
    2525import net.sf.basedb.core.DbControl;
    2626import net.sf.basedb.core.Experiment;
     
    5959    List<ExtendedProperty> properties = ExtendedProperties.getProperties("ReporterData");
    6060   
    61     ClonedProperty symbol = ClonedProperty.createFromRegular(ClonedProperty.SYMBOL);
    62     ClonedProperty ex1 = ClonedProperty.createFromExtended(properties.get(0).getName());
     61    ClonableProperty symbol = ClonableProperty.createFromRegular(ClonableProperty.SYMBOL);
     62    ClonableProperty ex1 = ClonableProperty.createFromExtended(properties.get(0).getName());
    6363   
    6464    int id = test_create("Test reporter clone template", symbol, ex1);
     
    9393  }
    9494
    95   static int test_create(String name, ClonedProperty... properties)
     95  static int test_create(String name, ClonableProperty... properties)
    9696  {
    9797    if (!TestUtil.hasPermission(Permission.CREATE, Item.REPORTERCLONETEMPLATE)) return 0;
     
    106106      if (properties != null)
    107107      {
    108         for (ClonedProperty cp : properties)
     108        for (ClonableProperty cp : properties)
    109109        {
    110           rct.addClonedProperty(cp);
     110          rct.addClonableProperty(cp);
    111111        }
    112112      }
     
    227227    {
    228228      System.out.println(i+":\t"+rct.getId()+"\t"+rct.getName()+"\t"+rct.getDescription()+
    229           "\t"+rct.isLocked() + "\t" + rct.getClonedProperties());
     229          "\t"+rct.isLocked() + "\t" + rct.getClonableProperties());
    230230    }
    231231  }
  • trunk/www/admin/reporterclonetemplates/edit_template.jsp

    r5879 r5885  
    2727  import="net.sf.basedb.core.Permission"
    2828  import="net.sf.basedb.core.ReporterCloneTemplate"
    29   import="net.sf.basedb.core.ClonedProperty"
     29  import="net.sf.basedb.core.ClonableProperty"
    3030  import="net.sf.basedb.core.ItemQuery"
    3131  import="net.sf.basedb.core.ItemResultList"
     
    5959  String title = null;
    6060  ReporterCloneTemplate template = null;
    61   List<ClonedProperty> clonedProperties = null;
     61  List<ClonableProperty> clonableProperties = null;
    6262 
    6363  if (itemId == 0)
    6464  {
    6565    title = "Create reporter clone template";
    66     clonedProperties = ClonedProperty.getAllMandatory();
     66    clonableProperties = ClonableProperty.getAllMandatory();
    6767    cc.removeObject("item");
    6868  }
     
    7171    template = ReporterCloneTemplate.getById(dc, itemId);
    7272    template.checkPermission(Permission.WRITE);
    73     clonedProperties = template.getClonedProperties();
     73    clonableProperties = template.getClonableProperties();
    7474    cc.setObject("item", template);
    7575    title = "Edit reporter clone template -- " + HTML.encodeTags(template.getName());
     
    182182                ondblclick="moveBetween(document.forms['template'].cloned_properties, document.forms['template'].uncloned_properties, true)">
    183183              <%
    184               for (ClonedProperty cp : clonedProperties)
     184              for (ClonableProperty cp : clonableProperties)
    185185              {
    186186                %>
     
    214214                ondblclick="moveBetween(document.forms['template'].uncloned_properties, document.forms['template'].cloned_properties)">
    215215              <%
    216               for (ClonedProperty cp : ClonedProperty.getAll())
     216              for (ClonableProperty cp : ClonableProperty.getAll())
    217217              {
    218                 if ((template == null && !cp.isMandatory()) || (template != null && !template.hasClonedProperty(cp.getName())))
     218                if ((template == null && !cp.isMandatory()) || (template != null && !template.hasClonableProperty(cp.getName())))
    219219                {
    220220                  %>
  • trunk/www/admin/reporterclonetemplates/index.jsp

    r5878 r5885  
    2727  import="net.sf.basedb.core.Include"
    2828  import="net.sf.basedb.core.ReporterCloneTemplate"
    29   import="net.sf.basedb.core.ClonedProperty"
     29  import="net.sf.basedb.core.ClonableProperty"
    3030  import="net.sf.basedb.core.ItemQuery"
    3131  import="net.sf.basedb.core.Permission"
     
    157157        for (String propertyName : cloned)
    158158        {
    159           if (!template.hasClonedProperty(propertyName))
     159          if (!template.hasClonableProperty(propertyName))
    160160          {
    161             template.addClonedProperty(ClonedProperty.create(propertyName));
     161            template.addClonableProperty(ClonableProperty.create(propertyName));
    162162          }
    163163        }
     
    169169        for (String propertyName : uncloned)
    170170        {
    171           if (template.hasClonedProperty(propertyName))
     171          if (template.hasClonableProperty(propertyName))
    172172          {
    173             template.removeClonedProperty(propertyName);
     173            template.removeClonableProperty(propertyName);
    174174          }
    175175        }
  • trunk/www/admin/reporterclonetemplates/list_templates.jsp

    r5878 r5885  
    2121
    2222--%>
    23 <%@page import="net.sf.basedb.core.ClonedProperty"%>
    2423<%@ page pageEncoding="UTF-8" session="false"
    2524  import="net.sf.basedb.core.SessionControl"
     
    2726  import="net.sf.basedb.core.Item"
    2827  import="net.sf.basedb.core.ReporterCloneTemplate"
     28  import="net.sf.basedb.core.ClonableProperty"
    2929  import="net.sf.basedb.core.ItemQuery"
    3030  import="net.sf.basedb.core.Include"
     
    231231      <%
    232232      Enumeration<String, String> allProperties = new Enumeration<String, String>();
    233       for (ClonedProperty cp : ClonedProperty.getAll())
     233      for (ClonableProperty cp : ClonableProperty.getAll())
    234234      {
    235235        allProperties.add(cp.getTitle(), cp.getTitle());
     
    459459                  <%
    460460                  String separator = "";
    461                   for (ClonedProperty cp : item.getClonedProperties())
     461                  for (ClonableProperty cp : item.getClonableProperties())
    462462                  {
    463463                    out.write(separator);
  • trunk/www/admin/reporterclonetemplates/view_template.jsp

    r5877 r5885  
    3030  import="net.sf.basedb.core.Permission"
    3131  import="net.sf.basedb.core.ReporterCloneTemplate"
    32   import="net.sf.basedb.core.ClonedProperty"
     32  import="net.sf.basedb.core.ClonableProperty"
    3333  import="net.sf.basedb.core.User"
    3434  import="net.sf.basedb.core.PermissionDeniedException"
     
    277277
    278278      <%
    279       List<ClonedProperty> properties = template.getClonedProperties();
     279      List<ClonableProperty> properties = template.getClonableProperties();
    280280      if (properties.size() == 0)
    281281      {
     
    316316              <tbl:rows>
    317317              <%
    318               for (ClonedProperty property : properties)
     318              for (ClonableProperty property : properties)
    319319              {
    320320                boolean exists = property.exists();
  • trunk/www/views/experiments/explorer/search/list.jsp

    r5711 r5885  
    8989  final String subContext = cc.getSubContext();
    9090
    91   List<TableColumn> columns = new LinkedList<TableColumn>();
    92   DynamicUtil.addReporterColumns(columns, dc, "", "@", "");
     91  List<TableColumn> allColumns = new LinkedList<TableColumn>();
     92  DynamicUtil.addReporterColumns(allColumns, dc, experiment.getVirtualDb().getReporterCloneTemplate(), "", "@", "");
    9393 
    94   DynamicUtil.SelectedInfo selected = DynamicUtil.getSelectedColumns(cc, columns, false);
    95   Map<String, Integer> selectedIndex = new HashMap<String, Integer>();
    96   for (int i = 0; i < selected.selectedIds.size(); ++i)
    97   {
    98     selectedIndex.put(selected.selectedIds.get(i), i+2);
    99   }
     94  DynamicUtil.SelectedInfo selected = DynamicUtil.getSelectedColumns(cc, allColumns, false);
     95  List<TableColumn> selectedColumns = selected.selectedColumns;
    10096 
    10197  try
    10298  {
    10399    DynamicReporterQuery reporterQuery = explorer.getReporterQuery(dc, selected.selectedProperties);
     100    reporterQuery.setFailSafe(true);
    104101    totalReporters = explorer.getMatchingReporters(dc);
    105102    reporters = reporterQuery.iterate(dc);
     
    175172      <p:pathelement title="Explorer" />
    176173    </p:path>
    177    
    178174    <t:tabcontrol id="explorer" switch="switchTab" remember="false" active="search">
    179175    <t:tab id="search" title="Reporter search">
     
    203199        value="<%=String.valueOf(bioAssaySetId)%>"
    204200      />
    205       <tbl:columndef
    206         id="reporterList"
    207         property="£reporterList"
    208         datatype="int"
    209         title="Reporter list"
    210         filterable="true"
    211         enumeration="<%=Base.getReporterListsEnum(dc)%>"
    212         multiple="false"
    213       />     
    214201      <%
    215       for (TableColumn tc : columns)
     202      for (TableColumn tc : allColumns)
    216203      {
    217204        %>
     
    231218      }
    232219      %>
     220      <tbl:columndef
     221        id="reporterList"
     222        property="£reporterList"
     223        datatype="int"
     224        title="Reporter list"
     225        filterable="true"
     226        enumeration="<%=Base.getReporterListsEnum(dc)%>"
     227        multiple="false"
     228      />     
    233229       
    234230      <tbl:toolbar>
     
    269265       
    270266      <%
    271       int index = cc.getPage()*cc.getRowsPerPage();
     267      int rowIndex = cc.getPage()*cc.getRowsPerPage();
    272268      if (reporters != null)
    273269      {
     
    276272          SqlResult item = reporters.next();
    277273          int itemId = item.getInt(1);
    278           index++;
     274          rowIndex++;
    279275          numListed++;
    280276          %>
     
    282278            <tbl:header
    283279              clazz="icons"
    284               ><a href="javascript:viewReporter(<%=index-1%>)"><%=index%></a></tbl:header>
    285             <tbl:cell column="name"><div class="link" onclick="itemOnClick(event, <%=itemId%>)"
    286               title="View this item (use CTRL, ALT or SHIFT to edit)"><%=HTML.encodeTags(item.getString(selectedIndex.get("name")))%></div></tbl:cell>
    287             <tbl:cell column="externalId"><tbl:cellvalue value="<%=item.getString(selectedIndex.get("externalId"))%>"/></tbl:cell>
    288             <tbl:cell column="symbol"><tbl:cellvalue value="<%=item.getString(selectedIndex.get("symbol"))%>"/></tbl:cell>
    289             <tbl:cell column="description"><tbl:cellvalue value="<%=item.getString(selectedIndex.get("description"))%>"/></tbl:cell>
    290             <tbl:cell column="lastUpdate"><tbl:cellvalue value="<%=item.getObject(selectedIndex.get("lastUpdate"))%>"/></tbl:cell>
     280              ><a href="javascript:viewReporter(<%=rowIndex-1%>)"><%=rowIndex%></a></tbl:header>
    291281            <%
    292             List<ExtendedProperty> reporterProperties = ExtendedProperties.getProperties("ReporterData");
    293             if (reporterProperties != null)
     282            int colIndex = 2;
     283            for (TableColumn tc : selectedColumns)
    294284            {
    295               for (ExtendedProperty ep : reporterProperties)
     285              String name = tc.getId();
     286              if ("externalId".equals(name))
    296287              {
    297                 String name = ep.getName();
    298288                %>
    299                 <tbl:cell column="<%=name%>"><tbl:cellvalue value="<%=item.getObject(selectedIndex.get(name))%>" /></tbl:cell>
    300               <%
     289                <tbl:cell column="externalId"><div class="link" onclick="itemOnClick(event, <%=itemId%>)"
     290                  title="View this item (use CTRL, ALT or SHIFT to edit)"><%=HTML.encodeTags(item.getString(colIndex))%></div></tbl:cell>
     291                <%
    301292              }
     293              else
     294              {
     295                %>
     296                <tbl:cell column="<%=name%>"><tbl:cellvalue value="<%=item.getObject(colIndex)%>" /></tbl:cell>
     297                <%
     298              }
     299              colIndex++;
    302300            }
    303301            %>
  • trunk/www/views/experiments/explorer/view/view.jsp

    r5711 r5885  
    8888<%!
    8989  private static final Item itemType = Item.SPOTDATA;
    90   private static final String defaultReporterColumns = "name,externalId,symbol,description";
     90  private static final String defaultReporterColumns = "externalId";
    9191%>
    9292<%
     
    116116  final String subContext = cc.getSubContext();
    117117 
    118   List<TableColumn> columns = new LinkedList<TableColumn>();
    119   DynamicUtil.addFormulaColumns(columns, dc, rawDataType, Formula.Type.COLUMN_EXPRESSION,
     118  List<TableColumn> reporterColumns = new LinkedList<TableColumn>();
     119  DynamicUtil.addReporterColumns(reporterColumns, dc, experiment.getVirtualDb().getReporterCloneTemplate(), "", "@", "");
     120
     121  List<TableColumn> spotColumns = new LinkedList<TableColumn>();
     122  DynamicUtil.addFormulaColumns(spotColumns, dc, rawDataType, Formula.Type.COLUMN_EXPRESSION,
    120123    transform, "frm.", "", maxRawMappings == 1);
    121   DynamicUtil.addExtraColumns(columns, dc, bioAssaySet, "ev", "#", "[Xtra] ");
     124  DynamicUtil.addExtraColumns(spotColumns, dc, bioAssaySet, "ev", "#", "[Xtra] ");
    122125  if (maxRawMappings == 1)
    123126  {
    124     DynamicUtil.addRawDataColumns(columns, dc, rawDataType, "raw.", "$", "[Raw] ");
    125     columns.add(new TableColumn("raw.spotimage", "$id", "raw('id')", Type.INT,
     127    DynamicUtil.addRawDataColumns(spotColumns, dc, rawDataType, "raw.", "$", "[Raw] ");
     128    spotColumns.add(new TableColumn("raw.spotimage", "$id", "raw('id')", Type.INT,
    126129      "[Raw] Spotimage", "", "auto", false, false, false, null,
    127130      new SpotImageFormatter(dc, rawDataType, root)));
     
    155158  }
    156159
    157   DynamicUtil.SelectedInfo selected = DynamicUtil.getSelectedColumns(cc, columns, isAveraging);
     160  DynamicUtil.SelectedInfo selected = DynamicUtil.getSelectedColumns(cc, spotColumns, isAveraging);
    158161 
    159162  List<String> sortProperties = null;
     
    162165    // We must check that we are not sorting on a non-averagable property
    163166    sortProperties = new ArrayList<String>(Arrays.asList(cc.getSortProperty().split(",")));
    164     for (TableColumn tc : columns)
     167    for (TableColumn tc : spotColumns)
    165168    {
    166169      if (!tc.isAveragable()) sortProperties.remove(tc.getProperty());
     
    382385        value="<%=String.valueOf(bioAssaySetId)%>"
    383386      />
    384       <tbl:columndef id="name" title="Name" show="always" clazz="prompt"/>
    385       <tbl:columndef id="externalId" title="External ID" clazz="prompt"/>
    386       <tbl:columndef id="symbol" title="Gene symbol" clazz="prompt"/>
    387       <tbl:columndef id="lastUpdate" title="Last update" clazz="prompt"/>
    388       <tbl:columndef id="type" title="Type" clazz="prompt"/>
    389       <tbl:columndef id="description" title="Description" clazz="prompt"/>
     387     
     388      <%
     389      for (TableColumn tc : reporterColumns)
     390      {
     391        %>
     392        <tbl:columndef
     393          id="<%=tc.getId()%>"
     394          clazz="prompt"
     395          title="<%=HTML.encodeTags(tc.getTitle())%>"
     396         
     397          formatter="<%=tc.getFormatter()%>"
     398        />
     399        <%
     400      }
     401      %>
     402     
    390403      <%
    391404      List<ExtendedProperty> reporterProperties = ExtendedProperties.getProperties("ReporterData");
    392       if (reporterProperties != null)
    393       {
    394         for (ExtendedProperty ep : reporterProperties)
    395         {
    396           String name = ep.getName();
    397           Formatter formatter = FormatterFactory.getExtendedPropertyFormatter(sc, ep);
    398           %>
    399           <tbl:columndef
    400             id="<%=ep.getName()%>"
    401             title="<%=HTML.encodeTags(ep.getTitle())%>"
    402             clazz="prompt"
    403             formatter="<%=formatter%>"
    404           />
    405           <%
    406         }
    407       }
    408405      %>
    409406      <tbl:form width="2">
     407        <tbl:cell column="id"><%=reporter.getId()%></tbl:cell>
     408        <tbl:cell column="version"><%=reporter.getVersion()%></tbl:cell>
    410409        <tbl:cell column="name"><%=Base.getLink(ID, reporter.getName(), Item.REPORTER, reporter.getId(), true)%></tbl:cell>
    411         <tbl:cell column="externalId"><%=HTML.encodeTags(reporter.getExternalId())%></tbl:cell>
     410        <tbl:cell column="externalId"><%=Base.getLink(ID, reporter.getExternalId(), Item.REPORTER, reporter.getId(), true)%></tbl:cell>
    412411        <tbl:cell column="symbol"><%=HTML.encodeTags(reporter.getSymbol())%></tbl:cell>
    413412        <tbl:cell column="lastUpdate"><%=dateFormatter.format(reporter.getLastUpdate())%></tbl:cell>
     
    710709      %>
    711710      <%
    712       for (TableColumn tc : columns)
     711      for (TableColumn tc : spotColumns)
    713712      {
    714713        %>
Note: See TracChangeset for help on using the changeset viewer.