Changeset 2490


Ignore:
Timestamp:
Aug 8, 2006, 9:29:35 AM (16 years ago)
Author:
Nicklas Nordborg
Message:

References #127: Experiment explorer

  • Added annotations, support for formula columns. Now mostly needs to be cleaned up and documented.
  • Fixed another problem with COUNT(DISTINCT) queries.
  • Changed stylesheet for forms on view pages
Location:
trunk
Files:
17 edited

Legend:

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

    r2487 r2490  
    115115 
    116116  // TODO - fix for use with table listings
    117   public static void addFormulaColumns(List<TableColumn> columns, DbControl dc, RawDataType rawDataType, Formula.Type type)
     117  public static void addFormulaColumns(List<TableColumn> columns, DbControl dc, RawDataType rawDataType, Formula.Type type, String idPrefix, String titlePrefix)
    118118  {
    119119    ItemQuery<Formula> query = Formula.getQuery(type, rawDataType);
     
    124124    {
    125125      Formula f = result.next();
    126       TableColumn tc = new TableColumn(null, null, f.getFormula(0), Type.FLOAT, f.getName(), f.getDescription());
     126      String jepExpression = f.getFormula(0);
     127      TableColumn tc = new TableColumn(idPrefix+f.getId(), "="+jepExpression, jepExpression, Type.FLOAT,
     128        titlePrefix + f.getName(), f.getDescription());
    127129      columns.add(tc);
    128130    }
  • trunk/src/clients/web/net/sf/basedb/clients/web/ExperimentExplorer.java

    r2487 r2490  
    7070  public static final int SPOT_AVG = -2;
    7171 
    72   private static final Map<RawDataType, ItemContext> defaultContexts =
     72  private static final ItemContext defaultReporterContext =
     73    Base.createDefaultContext("@externalId", "name,externalId");
     74 
     75  private static final Map<RawDataType, ItemContext> defaultSpotContexts =
    7376    new HashMap<RawDataType, ItemContext>();
    7477
     
    7881    {
    7982      // Default visible columns are: position, ch1, ch2, ...
    80       StringBuilder columns = new StringBuilder("POSITION");
     83      StringBuilder columns = new StringBuilder("bioassay,position");
    8184      for (int ch = 1; ch <= rdt.getChannels(); ++ch)
    8285      {
    8386        columns.append(",ch").append(ch);
    8487      }
    85       defaultContexts.put(rdt,
     88      defaultSpotContexts.put(rdt,
    8689        Base.createDefaultContext("POSITION", columns.toString()));
    8790    }
     
    101104  }
    102105 
    103   private static final int CACHE_SIZE = 10;
     106  private static final int DEFAULT_CACHE_SIZE = 100;
    104107 
    105108  private final BioAssaySet bioAssaySet;
    106109  private final Map<Short, Integer> bioAssays;
    107110  private int[] reporterIds;
     111  private int cacheSize;
    108112  private int firstCachedIndex = 0;
    109113  private int lastCachedIndex = -1;
    110114  private int reporterIndex = 0;
    111115  private int positionIndex = 0;
     116  private int matchingReporters = -1;
     117  private int annotationTypeId = 0;
    112118 
    113119  private ExperimentExplorer(BioAssaySet bioAssaySet)
     
    115121    this.bioAssaySet = bioAssaySet;
    116122    this.bioAssays = new HashMap<Short, Integer>();
     123    this.cacheSize = DEFAULT_CACHE_SIZE;
    117124    for (BioAssay ba : bioAssaySet.getBioAssays().list(bioAssaySet.getDbControl()))
    118125    {
     
    121128  }
    122129
     130  public int getCacheSize()
     131  {
     132    return cacheSize;
     133  }
     134 
     135  public void setCacheSize(int cacheSize)
     136  {
     137    this.cacheSize = cacheSize;
     138  }
     139 
    123140  /**
    124141    Get the bioassay set that is currently beeing explored.
     
    176193  }
    177194 
    178   public ItemContext getDefaultContext()
    179   {
    180     return defaultContexts.get(bioAssaySet.getRawDataType());
     195  public ItemContext getDefaultSpotContext()
     196  {
     197    return defaultSpotContexts.get(bioAssaySet.getRawDataType());
     198  }
     199
     200  public ItemContext getDefaultReporterContext()
     201  {
     202    return defaultReporterContext;
    181203  }
    182204 
    183205  public ItemContext getAndSetSpotContext(SessionControl sc, PageContext pageContext)
    184206  {
    185     ItemContext cc = Base.getAndSetCurrentContext(sc, Item.SPOTDATA, getSubContext(), pageContext, getDefaultContext());
     207    ItemContext cc = Base.getAndSetCurrentContext(sc, Item.SPOTDATA, getSubContext(), pageContext, getDefaultSpotContext());
    186208    if (pageContext != null)
    187209    {
     
    192214  }
    193215 
    194   public ItemContext getAndSetReporterContext(SessionControl sc, PageContext pageContext, ItemContext defaultContext)
    195   {
    196     ItemContext cc = Base.getAndSetCurrentContext(sc, Item.REPORTER, getSubContext(), pageContext, defaultContext);
     216  public ItemContext getAndSetReporterContext(SessionControl sc, PageContext pageContext)
     217  {
     218    ItemContext cc = Base.getAndSetCurrentContext(sc, Item.REPORTER, getSubContext(), pageContext, getDefaultReporterContext());
     219    if (pageContext != null)
     220    {
     221      // Settings may have changes, clear cache
     222      firstCachedIndex = 0;
     223      lastCachedIndex = -1;
     224      matchingReporters = -1;
     225    }
    197226    return cc;
    198227  }
     
    204233  public int getMatchingReporters(DbControl dc)
    205234  {
    206     return (int)getReporterQuery(dc, null).count(dc);
     235    if (matchingReporters == -1)
     236    {
     237      matchingReporters = (int)getReporterQuery(dc, null).count(dc);
     238    }
     239    return matchingReporters;
     240  }
     241 
     242  public int getAnnotationTypeId()
     243  {
     244    return annotationTypeId;
     245  }
     246 
     247  public void setAnnotationTypeId(int annotationTypeId)
     248  {
     249    this.annotationTypeId = annotationTypeId;
    207250  }
    208251 
     
    218261  /**
    219262    Set the index of the currently viewed reporter. If the index is below
    220     zero or greater than or equal to {@link #getMatchingReporters()} it is set
     263    zero or greater than or equal to {@link #getMatchingReporters(DbControl)} it is set
    221264    to the nearest index.
    222265    @param reporterIndex The new index
     
    224267  public void setReporterIndex(int reporterIndex)
    225268  {
     269    if (reporterIndex >= matchingReporters) reporterIndex = matchingReporters - 1;
    226270    if (reporterIndex < 0) reporterIndex = 0;
    227 //    if (reporterIndex >= getMatchingReporters()) reporterIndex = getMatchingReporters() - 1;
    228271    this.reporterIndex = reporterIndex;
    229272  }
     
    237280  public ReporterData getReporter(DbControl dc, int index)
    238281  {
    239     if (reporterIds == null)
    240     {
    241       reporterIds = new int[CACHE_SIZE];
     282    if (reporterIds == null || reporterIds.length != cacheSize)
     283    {
     284      reporterIds = new int[cacheSize];
    242285    }
    243286   
    244287    if (index < firstCachedIndex || index > lastCachedIndex)
    245288    {
    246       // The index is outside the cached range, reload another range: index +/- CACHE_SIZE / 2
     289      // The index is outside the cached range, reload another range: index +/- (cacheSize / 2)
    247290      BioAssaySet bas = getBioAssaySet(dc);
    248291     
    249292      DynamicSpotQuery reporterQuery = getReporterQuery(dc, null);
    250293     
    251       this.firstCachedIndex = Math.max(0, index - CACHE_SIZE / 2);
     294      this.firstCachedIndex = Math.max(0, index - cacheSize / 2);
    252295      reporterQuery.setFirstResult(firstCachedIndex);
    253       reporterQuery.setMaxResults(CACHE_SIZE);
     296      reporterQuery.setMaxResults(cacheSize);
    254297      try
    255298      {
     
    356399    reporterQuery.joinReporters(JoinType.INNER);
    357400    reporterQuery.setDistinct(true);
    358     reporterQuery.select(Dynamic.selectReporter("id"));
    359 
     401    reporterQuery.select(Selects.expression(Dynamic.reporter("id"), "id", true));
     402   
    360403    ItemContext cc = dc.getSessionControl().getCurrentContext(Item.REPORTER, getSubContext(), null);
    361404    cc.configureQuery(reporterQuery, selectionList);
  • trunk/src/core/net/sf/basedb/core/AbstractEntityQuery.java

    r2474 r2490  
    153153    this.requiredFilter = QueryRuntimeFilterFactory.getRequiredFilter(itemType);
    154154    this.optionalFilter = optionalFilter;
    155     super.selectPermanent(Selects.expression(Hql.alias(itemType.getAlias()), null));
     155    super.selectPermanent(Selects.expression(Hql.alias(itemType.getAlias()), null, true));
    156156    this.includes = EnumSet.of(Include.NOT_REMOVED, Include.MINE, Include.IN_PROJECT);
    157157    this.permission = Permission.READ;
  • trunk/src/core/net/sf/basedb/core/AbstractQuery.java

    r2487 r2490  
    687687    for (Select s : selects)
    688688    {
    689       ql.append(deliminator);
    690       ql.append(dc == null ? s.toString() : s.toQl(this, dc));
    691       appended++;
    692       deliminator = ", ";
     689      if (!isCounting || s.useInDistinctCount())
     690      {
     691        ql.append(deliminator);
     692        ql.append(dc == null ? s.toString() : s.toQl(this, dc));
     693        appended++;
     694        deliminator = ", ";
     695      }
    693696    }
    694697    return appended;
  • trunk/src/core/net/sf/basedb/core/ItemContext.java

    r2487 r2490  
    3939import net.sf.basedb.core.data.UserData;
    4040import net.sf.basedb.core.data.ClientData;
     41import net.sf.basedb.util.jep.ChannelFunction;
     42import net.sf.basedb.util.jep.Jep;
     43import net.sf.basedb.util.jep.JepFunction;
     44import net.sf.basedb.util.jep.RawFunction;
    4145
    4246import java.util.Collection;
     
    148152  public static final String DEFAULT_NAME = "- default -";
    149153
     154  // For parsing JEP expressions
     155  private static final JepFunction ch = new ChannelFunction();
     156  private static final JepFunction raw = new RawFunction();
     157 
    150158  private final String name;
    151159  private final Item itemType;
     
    942950      // TODO - implement extra values
    943951    }
     952    else if (propertyDef.startsWith("="))
     953    {
     954      // propertyDef is JEP expression
     955      joins.joinRawData |= propertyDef.contains("raw(");
     956      e = Jep.formulaToExpression(propertyDef.substring(1), ch, raw);
     957    }
    944958    else
    945959    {
  • trunk/src/core/net/sf/basedb/core/Operator.java

    r2304 r2490  
    151151  }
    152152
     153  public String toString()
     154  {
     155    return symbol;
     156  }
     157 
    153158  /**
    154159    Get the integer value that is used when storing an operator in the database.
  • trunk/src/core/net/sf/basedb/core/PropertyFilter.java

    r2304 r2490  
    9898    return filter;
    9999  }
     100 
     101  /*
     102    From the Object class
     103    -------------------------------------------
     104  */
     105  public String toString()
     106  {
     107    return property + " " + operator + " " + value;
     108  }
     109  // -------------------------------------------
     110
    100111 
    101112  /**
  • trunk/src/core/net/sf/basedb/core/RawDataType.java

    r2392 r2490  
    2727import java.util.HashMap;
    2828import java.util.Collections;
     29
     30import net.sf.basedb.core.data.RawData;
    2931
    3032/**
     
    232234    return name;
    233235  }
     236 
     237  public RawData getRawDataById(DbControl dc, int id)
     238    throws ItemNotFoundException, PermissionDeniedException, BaseException
     239  {
     240    if (!isStoredInDb())
     241    {
     242      throw new BaseException("Raw data for raw data type '" + this + "' is not stored in the database.");
     243    }
     244    RawData rd = HibernateUtil.loadData(dc.getStatelessSession(),
     245      RawData.class, getEntityName(), id);
     246    if (rd == null) throw new ItemNotFoundException("RawData[id = " + id + "]");
     247   
     248    RawDataUtil.getRawBioAssay(dc, rd); // To check for read permission
     249    return rd;
     250  }
     251 
    234252}
  • trunk/src/core/net/sf/basedb/core/query/ExpressionSelect.java

    r2487 r2490  
    4646  private final Expression e1;
    4747  private final String alias;
     48  private final boolean useInDistinctCount;
    4849
    49   ExpressionSelect(Expression e1, String alias)
     50  ExpressionSelect(Expression e1, String alias, boolean useInDistinctCount)
    5051  {
    5152    this.e1 = e1;
    5253    this.alias = alias;
     54    this.useInDistinctCount = useInDistinctCount;
    5355  }
    5456
     
    8082    return e1;
    8183  }
     84  public boolean useInDistinctCount()
     85  {
     86    return useInDistinctCount;
     87  }
    8288  // -------------------------------------------
    8389  /*
  • trunk/src/core/net/sf/basedb/core/query/Select.java

    r2304 r2490  
    5555  */
    5656  public Expression getExpression();
     57 
     58  /**
     59    If this expression should be use in count distinct queries or not.
     60    <pre class="code">
     61SELECT COUNT(DISTINCT expression)
     62</pre>
     63    @return TRUE or FALSE
     64  */
     65  public boolean useInDistinctCount();
    5766
    5867}
  • trunk/src/core/net/sf/basedb/core/query/Selects.java

    r2304 r2490  
    4545
    4646  /**
    47     Create a selection from an expression, optionally giving it an alias.
    48     The alias can be used when getting the result to find the column
    49     index. See {@link SqlResultIterator#getIndex(String)}.
    50     <p>
    51 <pre class="code">
    52 SELECT <i>&lt;expression&gt;</i> AS <i>&lt;alias&gt;</i>
    53 FROM ...
    54 </pre>
    55     <p>
    56     TODO - more example code
    57    
    58     @param e1 The expression to select
    59     @param alias The alias to give the expression
    60     @return A selection query element
    61     @throws InvalidDataException If the expression is null or if the
    62       alias contains invalid characters
     47    Same as <code>expression(e1, alias, false)</code>.
     48    @see #expression(Expression, String, boolean)
    6349  */
    6450  public static final Select expression(Expression e1, String alias)
     
    7056      throw new InvalidDataException("Alias '"+alias+"' has one or more invalid characters. Only a-z, A-Z and 0-9 is allowed.");
    7157    }
    72     return new ExpressionSelect(e1, alias);
     58    return new ExpressionSelect(e1, alias, false);
     59  }
     60 
     61  /**
     62    Create a selection from an expression, optionally giving it an alias.
     63    The alias can be used when getting the result to find the column
     64    index. See {@link SqlResultIterator#getIndex(String)}.
     65    <p>
     66  <pre class="code">
     67SELECT <i>&lt;expression&gt;</i> AS <i>&lt;alias&gt;</i>
     68FROM ...
     69  </pre>
     70    <p>
     71    The useInDistinctCount parameter affects the {@link Query#count(DbControl)}
     72    method, if the {@link Query#setDistinct(boolean)} has been set to true. In this
     73    case only expressions which has been created for use with the distinct function
     74    are used in the selection list:
     75    <pre class="code">
     76SELECT COUNT(DISTINCT <i>&lt;expression&gt;</i>)
     77FROM ...
     78  </pre>
     79    <p>
     80   
     81    TODO - more example code
     82   
     83    @param e1 The expression to select
     84    @param alias The alias to give the expression
     85    @param useInDistinctCount If the expression should be used when counting distinct values
     86    @return A selection query element
     87    @throws InvalidDataException If the expression is null or if the
     88      alias contains invalid characters
     89  */ 
     90  public static final Select expression(Expression e1, String alias, boolean useInDistinctCount)
     91    throws InvalidDataException
     92  {
     93    if (e1 == null) throw new InvalidUseOfNullException("e1");
     94    if (alias != null && !ALIAS_REGEXP.matcher(alias).matches())
     95    {
     96      throw new InvalidDataException("Alias '"+alias+"' has one or more invalid characters. Only a-z, A-Z and 0-9 is allowed.");
     97    }
     98    return new ExpressionSelect(e1, alias, useInDistinctCount);
    7399  }
    74100 
  • trunk/www/include/styles/main.css

    r2487 r2490  
    173173a.disabled {
    174174  color: #666666;
    175   xtext-decoration: none;
    176175  cursor: default;
    177176}
     
    182181.form .prompt {
    183182  font-weight: bold;
    184   padding: 2px 4px 2px 0px;
     183  padding: 2px 4px 2px 2px;
    185184  white-space: nowrap;
    186 }
     185  background: #E0E0E0;
     186}
     187
     188.form tr {
     189  vertical-align: top;
     190}
     191     
    187192
    188193.error {
  • trunk/www/views/experiments/bioassaysets/view_bioassayset.jsp

    r2487 r2490  
    232232        image="explorer.png"
    233233        onclick="<%="openExperimentExplorer(" + itemId + ")"%>"
    234         title="Experiment explorer&hellip;"
     234        title="Experiment explorer"
    235235        tooltip="View the data reporter by reporter"
    236236      />
  • trunk/www/views/experiments/explorer/search/index.jsp

    r2487 r2490  
    4141<%!
    4242  private static final Item itemType = Item.REPORTER;
    43   private static final ItemContext defaultContext =
    44     Base.createDefaultContext("@externalId", "name,externalId");
     43
    4544%>
    4645<%
     
    6665  if (cmd == null || "List".equals(cmd))
    6766  {
    68     ItemContext cc = explorer.getAndSetReporterContext(sc, null, defaultContext);
     67    ItemContext cc = explorer.getAndSetReporterContext(sc, null);
    6968    redirect = listPage;
    7069  }
    7170  else if ("UpdateContext".equals(cmd))
    7271  {
    73     ItemContext cc = explorer.getAndSetReporterContext(sc, pageContext, defaultContext);
     72    ItemContext cc = explorer.getAndSetReporterContext(sc, pageContext);
    7473    redirect = listPage;
    75 //    throw new WebException("popup", "Page", request.getParameter("page") + ":" + cc.getPage()+":"+request.getParameter("sortby")+":"+cc.getSortProperty());
    7674  }
    7775  else
  • trunk/www/views/experiments/explorer/search/list.jsp

    r2487 r2490  
    8484 
    8585  final ExperimentExplorer explorer = ExperimentExplorer.getExplorer(bioAssaySet);
    86   final ItemContext cc = explorer.getAndSetReporterContext(sc, null, null);
     86  final ItemContext cc = explorer.getAndSetReporterContext(sc, null);
    8787  final String subContext = cc.getSubContext();
    8888
    8989  List<TableColumn> columns = new LinkedList<TableColumn>();
    90   //DynamicUtil.addSpotColumns(columns, rawDataType.getChannels());
    91   //DynamicUtil.addRawDataColumns(columns, rawDataType, "raw.", "$", "[Raw] ");
    9290  DynamicUtil.addReporterColumns(columns, "", "@", "");
    9391 
     
    9896    selectedIndex.put(selected.selectedIds.get(i), i+2); 
    9997  }
    100   /*
    101   final int matchingReporters = explorer.getMatchingReporters();
    102   final int reporterIndex = explorer.getReporterIndex();
    103   final int positionIndex = explorer.getPositionIndex();
    104   final ReporterData reporter = explorer.getReporter(dc, reporterIndex);
    105   final int matchingPositions = explorer.getNumPositions(dc, reporter);
    106   */
    10798 
    10899  DynamicSpotQuery reporterQuery = explorer.getReporterQuery(dc, selected.selectedProperties);
  • trunk/www/views/experiments/explorer/view/index.jsp

    r2487 r2490  
    6262  BioAssaySet bioAssaySet = BioAssaySet.getById(dc, bioAssaySetId);
    6363  ExperimentExplorer explorer = ExperimentExplorer.getExplorer(bioAssaySet);
    64   if (cmd == null)
     64  if (cmd == null || "Explore".equals(cmd))
    6565  {
    66     explorer.setReporterIndex(0);
    67     explorer.setPositionIndex(0);
     66    //explorer.setReporterIndex(0);
     67    //explorer.setPositionIndex(0);
    6868    redirect = viewPage;
    6969  }
     
    8181  {
    8282    explorer.setPositionIndex(Values.getInt(request.getParameter("spotIndex")));
     83    redirect = viewPage;
     84  }
     85  else if ("SetAnnotationType".equals(cmd))
     86  {
     87    explorer.setAnnotationTypeId(Values.getInt(request.getParameter("annotationtype_id")));
     88   
     89    // Fix visible columns
     90    ItemContext cc = explorer.getAndSetSpotContext(sc, null);
     91    String columns = cc.getSetting("columns");
     92    if (explorer.getAnnotationTypeId() != 0)
     93    {
     94      if (!columns.contains("annotation")) columns = "annotation," + columns;
     95    }
     96    else
     97    {
     98      columns.replace("annotation", "");
     99    }
     100    cc.setSetting("columns", columns);
    83101    redirect = viewPage;
    84102  }
  • trunk/www/views/experiments/explorer/view/view.jsp

    r2487 r2490  
    3030  import="net.sf.basedb.core.Item"
    3131  import="net.sf.basedb.core.ItemContext"
     32  import="net.sf.basedb.core.Include"
    3233  import="net.sf.basedb.core.BioAssaySet"
     34  import="net.sf.basedb.core.BioAssay"
    3335  import="net.sf.basedb.core.Experiment"
    3436  import="net.sf.basedb.core.RawDataType"
     37  import="net.sf.basedb.core.RawBioAssay"
     38  import="net.sf.basedb.core.RawDataUtil"
    3539  import="net.sf.basedb.core.ExtendedProperties"
    3640  import="net.sf.basedb.core.ExtendedProperty"
     41  import="net.sf.basedb.core.AnnotationType"
     42  import="net.sf.basedb.core.Annotation"
     43  import="net.sf.basedb.core.Formula"
     44  import="net.sf.basedb.core.ItemQuery"
     45  import="net.sf.basedb.core.ItemResultIterator"
    3746  import="net.sf.basedb.core.DynamicSpotQuery"
    3847  import="net.sf.basedb.core.DynamicResultIterator"
    3948  import="net.sf.basedb.core.VirtualColumn"
     49  import="net.sf.basedb.core.Type"
    4050  import="net.sf.basedb.core.data.ReporterData"
     51  import="net.sf.basedb.core.data.RawData"
    4152  import="net.sf.basedb.core.query.Restrictions"
    4253  import="net.sf.basedb.core.query.Expressions"
     
    5566  import="net.sf.basedb.clients.web.taglib.table.TableColumn"
    5667  import="java.util.Date"
     68  import="java.util.Set"
     69  import="java.util.HashSet"
    5770  import="java.util.List"
    5871  import="java.util.LinkedList"
     
    8396  final ExperimentExplorer explorer = ExperimentExplorer.getExplorer(bioAssaySet);
    8497  final ItemContext cc = explorer.getAndSetSpotContext(sc, pageContext);
     98  final ItemContext reporterContext = explorer.getAndSetReporterContext(sc, null);
    8599  final String subContext = cc.getSubContext();
    86 
     100 
    87101  List<TableColumn> columns = new LinkedList<TableColumn>();
    88102  DynamicUtil.addSpotColumns(columns, rawDataType.getChannels());
     103  DynamicUtil.addFormulaColumns(columns, dc, rawDataType, Formula.Type.COLUMN_EXPRESSION, "frm", "");
    89104  DynamicUtil.addRawDataColumns(columns, rawDataType, "raw.", "$", "[Raw] ");
    90   //DynamicUtil.addReporterColumns(columns, "rep.", "@", "[Rep] ");
    91105  // TODO - DynamicUtil.addExtraColumns(columns);
    92   // TODO - DynamicUtil.addFormulaColumns(columns);
    93  
    94   columns.remove(0);
     106  columns.add(new TableColumn("raw.spotimage", "$id", "raw('id')", Type.INT, "[Raw] Spotimage", "", "auto", false, false, false));
     107
     108  columns.remove(0); // The position column, it is added in another place
    95109 
    96110  DynamicUtil.SelectedInfo selected = DynamicUtil.getSelectedColumns(cc, columns);
     111 
     112  final int annotationTypeId = explorer.getAnnotationTypeId();
     113  final AnnotationType annotationType = annotationTypeId == 0 ?
     114    null : AnnotationType.getById(dc, annotationTypeId);
    97115 
    98116  final int matchingReporters = explorer.getMatchingReporters(dc);
     
    145163      Forms.createHidden(frm, 'spotIndex', spotIndex-1);
    146164      return true;
     165    }
     166    function annotationTypeOnChange()
     167    {
     168      var frm = document.forms['explorer'];
     169      frm.cmd.value = 'SetAnnotationType';
     170      frm.submit();
    147171    }
    148172    function viewSearch()
     
    178202   
    179203    <t:tab id="view" title="Reporter view">
    180 
    181204    <div class="boxed">
    182205   
     
    186209    <input type="hidden" name="cmd" value="">
    187210   
    188      
     211   
     212    <table width="100%" cellspacing="2" cellpadding="0" border="0">
     213    <tr valign="bottom">
     214      <td width="50%">
     215
    189216      <h4>Current reporter
    190217      <input name="newReporterIndex" type="text" class="text" value="<%=reporterIndex+1%>"
     
    231258      %>
    232259      </h4>
    233       <p>
    234      
     260     
     261      </td>
     262      <td width="50%">
     263        <h4>Annotation</h4>
     264      </td>
     265      </tr>
     266     
     267      <tr valign="top">
     268      <td>
     269
    235270      <%
    236271      if (reporter != null)
    237272      {
    238273        %>
    239         <table class="form" cellspacing=0>
     274        <table class="form" cellspacing=0 width="100%">
    240275        <tr>
    241           <td class="prompt">Name</td>
     276          <td class="prompt" >Name</td>
    242277          <td colspan="7"><%=Base.getLink(ID, reporter.getName(), Item.REPORTER, reporter.getId(), true)%></td>
    243278        </tr>
     
    248283          <td class="prompt">Type</td>
    249284          <td><base:propertyvalue dbcontrol="<%=dc%>" item="<%=reporter%>" property="reporterType" /></td>
    250           <td>&nbsp;&nbsp;</td>
     285        </tr>
     286        <tr valign="top">
    251287          <td class="prompt">Gene symbol</td>
    252288          <td><%=HTML.encodeTags(reporter.getSymbol())%></td>
     289          <td>&nbsp;&nbsp;</td>
     290          <td class="prompt">Description</td>
     291          <td><%=HTML.niceFormat(reporter.getDescription())%></td>
    253292        </tr>
    254293        <tr valign="top">
    255           <td class="prompt">Description</td>
    256           <td><%=HTML.niceFormat(reporter.getDescription())%></td>
    257           <td>&nbsp;&nbsp;</td>
    258294          <td class="prompt">Last update</td>
    259295          <td><%=Values.formatDate(reporter.getLastUpdate())%></td>
    260296          <td>&nbsp;&nbsp;</td>
    261297          <%
    262           int column = 2;
     298          int column = 1;
    263299          for (ExtendedProperty ep : ExtendedProperties.getProperties("ReporterData"))
    264300          {
     
    267303            String link = ep.getUrl(value);
    268304            if (value instanceof Date) value = Values.formatDate((Date)value);
    269             value = value == null ? "<i>- no value -</i>" : HTML.encodeTags(value.toString());
     305            value = value == null ? "" : HTML.encodeTags(value.toString());
    270306            if (link != null)
    271307            {
     
    277313              <td><%=value%></td>
    278314              <td>&nbsp;&nbsp;</td>
    279               <%=column == 2 ? "</tr>" : ""%>
     315              <%=column == 1 ? "</tr>" : ""%>
    280316            <%
    281317            column++;
    282             if (column > 2) column = 0;
     318            if (column > 1) column = 0;
    283319          }
    284320          %>
    285           <%=column < 2 ? "</tr>" : ""%>
     321          <%=column < 1 ? "</tr>" : ""%>
    286322        </table>
    287323
     
    349385        }
    350386        %>
    351         <a href="index.jsp?ID=<%=ID%>&cmd=SetSpotIndex&bioassayset_id=<%=bioAssaySetId%>&spotIndex=-1"
     387        [ <a href="index.jsp?ID=<%=ID%>&cmd=SetSpotIndex&bioassayset_id=<%=bioAssaySetId%>&spotIndex=-1"
    352388          title="Show all positions">all</a>
    353         <a href="index.jsp?ID=<%=ID%>&cmd=SetSpotIndex&bioassayset_id=<%=bioAssaySetId%>&spotIndex=-2"
     389        | <a href="index.jsp?ID=<%=ID%>&cmd=SetSpotIndex&bioassayset_id=<%=bioAssaySetId%>&spotIndex=-2"
    354390          title="Calculate average values for each bioassay">avg</a>
     391        ]
    355392        <%
    356393      }
    357394      %>
    358395      </h4>
     396     
     397      </td>
     398      <td>
     399        <select name="annotationtype_id" onchange="annotationTypeOnChange()">
     400        <option value="0">- none -
     401        <%
     402        ItemQuery<AnnotationType> annotationTypeQuery = experiment.getExperimentalFactors();
     403        annotationTypeQuery.include(Include.MINE, Include.SHARED, Include.IN_PROJECT, Include.OTHERS);
     404        ItemResultIterator<AnnotationType> annotationTypes = annotationTypeQuery.iterate(dc);
     405        while (annotationTypes.hasNext())
     406        {
     407          AnnotationType at = annotationTypes.next();
     408          String isSelected = at.getId() == annotationTypeId ? "selected" : "";
     409          %>
     410          <option value="<%=at.getId()%>" <%=isSelected%>><%=HTML.encodeTags(at.getName())%>
     411          <%
     412        }
     413        %>
     414        </select>
     415        <p>
     416        <%
     417        if (annotationType != null)
     418        {
     419          %>
     420          <b>Summary</b><br>
     421          TODO
     422          <%
     423        }
     424        %>
     425      </td>
     426      </tr>
     427      </table>
     428     
    359429      </form>
    360430     
     
    375445        value="<%=String.valueOf(bioAssaySetId)%>"
    376446      />
     447      <%
     448      if (annotationType != null)
     449      {
     450        %>
     451        <tbl:columndef
     452          id="annotation"
     453          title="<%=HTML.encodeTags(annotationType.getName()) %>"
     454          show="always"
     455        />
     456        <%
     457      }
     458      %>
    377459      <tbl:columndef
    378460        id="bioassay"
     461        property="COLUMN"
    379462        title="Bioassay"
    380463        show="always"
     464        sortable="true"
    381465      />
    382466      <tbl:columndef
    383467        id="position"
     468        property="POSITION"
    384469        title="Position"
    385470        show="<%=positionIndex == ExperimentExplorer.SPOT_AVG ? "never" : "always" %>"
     471        sortable="true"
    386472      />
    387473      <tbl:columndef
     
    417503      </tbl:toolbar>
    418504      <tbl:data>
    419         <tbl:columns>
    420         </tbl:columns>
     505        <tbl:columns />
    421506        <tbl:rows>
    422        
    423507      <%
    424508      int index = 0;
     
    430514        %>
    431515        <tbl:row>
     516          <%
     517          if (annotationType != null)
     518          {
     519            BioAssay ba = explorer.getBioAssay(dc, item.getShort(1));
     520            ItemQuery<RawBioAssay> rbaQuery = ba.getRawBioAssays();
     521            rbaQuery.include(Include.MINE, Include.SHARED, Include.IN_PROJECT, Include.OTHERS);
     522            List<RawBioAssay> rba = rbaQuery.list(dc);
     523
     524            Set<Object> allValues = new HashSet<Object>();
     525            for (RawBioAssay rb : rba)
     526            {
     527              Annotation a = rb.isAnnotated() ?
     528                rb.getAnnotationSet().findAnnotation(annotationType) : null;
     529              allValues.addAll(a.getValues());
     530            }
     531            %>
     532            <tbl:cell column="annotation">
     533            <%=Values.getString(allValues, ", ", true)%>
     534            </tbl:cell>
     535            <%
     536          }
     537          %>
    432538          <tbl:cell column="bioassay"><%=Base.getLinkedName(ID, explorer.getBioAssay(dc, item.getShort(1)), false, true)%></tbl:cell>
    433539          <tbl:cell column="position"><%=item.getInt(2)%></tbl:cell>
     
    435541          <%
    436542          int i = 3;
     543          int spotImageIndex = 0;
    437544          for (String columnId : selected.selectedIds)
    438545          {
    439             Object value = item.getObject(i++);
    440             %>
    441             <tbl:cell column="<%=columnId%>"><%=value%></tbl:cell>
    442             <%
     546            if ("raw.spotimage".equals(columnId))
     547            {
     548              RawData rd = rawDataType.getRawDataById(dc, item.getInt(i++));
     549              RawBioAssay rba = RawDataUtil.getRawBioAssay(dc, rd);
     550              %>
     551              <tbl:cell column="raw.spotimage">
     552                <%
     553                if (rba.hasSpotImages())
     554                {
     555                  %>
     556                  <img src="../../../rawbioassays/rawdata/spotimage/<%=ID%>/<%=rba.getId()%>/<%=rd.getId()%>/spot<%=rd.getPosition()%>.png">
     557                  <%
     558                }
     559                else
     560                {
     561                  %>
     562                  <i>- none -</i>
     563                  <%
     564                }
     565                %>
     566              </tbl:cell>
     567              <%
     568            }
     569            else
     570            {
     571              Object value = item.getObject(i++);
     572              %>
     573              <tbl:cell column="<%=columnId%>"><%=value%></tbl:cell>
     574              <%
     575            }
    443576          }
    444577          %>
Note: See TracChangeset for help on using the changeset viewer.