Changeset 4057


Ignore:
Timestamp:
Dec 13, 2007, 1:45:00 PM (16 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #771: Make annotations for Bioassays available in bioassay table within a BioassaySet?

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/taglib/table/CellValue.java

    r3675 r4057  
    2323*/
    2424package net.sf.basedb.clients.web.taglib.table;
    25 
    26 import java.util.List;
    2725
    2826import javax.servlet.jsp.JspException;
     
    9795  */
    9896  private Object value = null;
    99   private List<?> list = null;
     97  private Iterable<?> list = null;
    10098  private String separator = "; ";
    10199
     
    113111  }
    114112 
    115   public void setList(List<?> list)
     113  public void setList(Iterable<?> list)
    116114  {
    117115    this.list = list;
    118116  }
    119117 
    120   public List<?> getList()
     118  public Iterable<?> getList()
    121119  {
    122120    return list;
     
    151149      theSeparator = separator;
    152150    }
    153     if (list != null && list.size() > 0)
     151    if (list != null)
    154152    {
    155153      for (Object o : list)
  • trunk/src/core/net/sf/basedb/core/AnnotationRestriction.java

    r3857 r4057  
    191191       
    192192        sqlQuery = HibernateUtil.createSqlQuery(session, sql);
    193         sqlQuery.addScalar("annotationset_id", org.hibernate.Hibernate.INTEGER);
     193        sqlQuery.addScalar("sid", org.hibernate.Hibernate.INTEGER);
    194194        if (debugSqlEnabled) logSql.debug("Executing annotation query: " + sql);
    195195        List<Integer> ids = HibernateUtil.loadList(Integer.class, sqlQuery, sc);
  • trunk/src/core/net/sf/basedb/core/PropertyFilter.java

    r3679 r4057  
    189189    property before proceeding.
    190190    <p>
    191     If the property starts with a # it is a filter on annotations. The rest of
     191    If the property starts with a # or ## it is a filter on annotations. The rest of
    192192    the property is the ID of the annotation type, and we use a
    193     {@link AnnotationSimpleRestriction} object for the restriction.
     193    {@link AnnotationSimpleRestriction} object for the restriction. If there
     194    is only one # in the prefix only direct annotations are searched, if there
     195    are two ##, inherited annotations are also searched.
    194196    <p>
    195197    If the property starts with a @ the property is a collection of values and
     
    227229    {
    228230      // Property is id of annotation type: #id
    229       int annotationTypeId = (Integer)Type.INT.parseString(property.substring(1));
     231      // If prefixed with two ## inherited annotations should be searched
     232      boolean searchInherited = property.startsWith("##");
     233      int annotationTypeId = (Integer)Type.INT.parseString(property.substring(searchInherited ? 2 : 1));
    230234      restriction = new AnnotationSimpleRestriction(alias, annotationTypeId, getValueType(),
    231         getOperator(), getValueAsObject(), false);
     235        getOperator(), getValueAsObject(), searchInherited);
    232236    }
    233237    else
  • trunk/www/views/experiments/bioassays/list_bioassays.jsp

    r3679 r4057  
    8888ItemResultIterator<BioAssay> bioAssays = null;
    8989ItemResultList<AnnotationType> annotationTypes = null;
     90ItemResultList<AnnotationType> experimentalFactors = null;
    9091try
    9192{
     
    9394  final BioAssaySet bioAssaySet = BioAssaySet.getById(dc, bioAssaySetId);
    9495  final Experiment experiment = bioAssaySet.getExperiment();
     96  final ItemQuery<AnnotationType> experimentalFactorQuery = experiment.getExperimentalFactors();
     97  experimentalFactorQuery.include(Include.MINE, Include.SHARED, Include.IN_PROJECT, Include.OTHERS);
    9598  final int experimentId = experiment.getId();
    9699  final RawDataType rawDataType = experiment.getRawDataType();
     
    108111  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
    109112  annotationTypes = annotationTypeQuery.list(dc);
     113  experimentalFactors = experimentalFactorQuery.list(dc);
    110114  try
    111115  {
    112116    final ItemQuery<BioAssay> query = Base.getConfiguredQuery(cc, true, bioAssaySet.getBioAssays(), mode);
     117    query.join(Hql.leftJoin("rawParents", "rba"));
    113118    bioAssays = query.iterate(dc);
    114119  }
    115120  catch (Throwable t)
    116121  {
     122    t.printStackTrace();
    117123    cc.setMessage(t.getMessage());
    118124  }
    119125  int numListed = 0;
    120126  %>
    121   <base:page title="<%=title%>" type="<%=mode.getPageType()%>">
     127  <%@page import="net.sf.basedb.util.BioAssaySetUtil"%>
     128<base:page title="<%=title%>" type="<%=mode.getPageType()%>">
    122129  <base:head scripts="table.js,tabcontrol.js" styles="table.css,headertabcontrol.css,path.css">
    123130    <script language="JavaScript">
     
    292299          title="<%=HTML.encodeTags(at.getName())+" [A]"%>"
    293300          property="<%="#"+at.getId()%>"
     301          annotation="true"
     302          datatype="<%=at.getValueType().getStringValue()%>"
     303          enumeration="<%=annotationEnum%>"
     304          sortable="false"
     305          filterable="true"
     306          exportable="true"
     307          formatter="<%=formatter%>"
     308        />
     309        <%
     310      }
     311      %>
     312      <%
     313      for (AnnotationType at : experimentalFactors)
     314      {
     315        Enumeration<String, String> annotationEnum = null;
     316        Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType());
     317        if (at.isEnumeration())
     318        {
     319          annotationEnum = new Enumeration<String, String>();
     320          List<?> values = at.getValues();
     321          for (Object value : values)
     322          {
     323            String encoded = formatter.format(value);
     324            annotationEnum.add(encoded, encoded);
     325          }
     326        }
     327        %>
     328        <tbl:columndef
     329          id="<%="ef"+at.getId()%>"
     330          title="<%=HTML.encodeTags(at.getName())+" [EF]"%>"
     331          property="<%="$rba.##"+at.getId()%>"
    294332          annotation="true"
    295333          datatype="<%=at.getValueType().getStringValue()%>"
     
    484522                  }
    485523                }
     524                for (AnnotationType at : experimentalFactors)
     525                {
     526                  %>
     527                  <tbl:cell column="<%="ef"+at.getId()%>"
     528                    ><tbl:cellvalue
     529                    list="<%=BioAssaySetUtil.getAnnotationValues(dc, item, at)%>"
     530                  /></tbl:cell>
     531                  <%
     532                }               
    486533                %>
    487534                <tbl:cell column="tools">
  • trunk/www/views/experiments/bioassays/view_bioassay.jsp

    r3679 r4057  
    3636  import="net.sf.basedb.core.BioAssay"
    3737  import="net.sf.basedb.core.RawBioAssay"
     38  import="net.sf.basedb.core.Annotatable"
     39  import="net.sf.basedb.core.AnnotationSet"
     40  import="net.sf.basedb.core.AnnotationType"
     41  import="net.sf.basedb.core.Annotation"
    3842  import="net.sf.basedb.core.ItemQuery"
    3943  import="net.sf.basedb.core.ItemResultList"
     
    4549  import="net.sf.basedb.core.query.Orders"
    4650  import="net.sf.basedb.core.query.Hql"
     51  import="net.sf.basedb.util.formatter.Formatter"
     52  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    4753  import="net.sf.basedb.clients.web.Base"
    4854  import="net.sf.basedb.clients.web.PermissionUtil"
     
    5056  import="net.sf.basedb.util.Values"
    5157  import="java.util.Map"
     58  import="java.util.List"
     59  import="java.util.HashMap"
     60  import="java.util.LinkedList"
    5261%>
    5362<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    214223          title="Description"
    215224        />
     225        <%
     226        ItemQuery<AnnotationType> efQuery = experiment.getExperimentalFactors();
     227        efQuery.include(Include.ALL);
     228        efQuery.order(Orders.asc(Hql.property("name")));
     229        ItemResultList<AnnotationType> experimentalFactors = efQuery.list(dc);
     230        for (AnnotationType at : experimentalFactors)
     231        {
     232          Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType());
     233          %>
     234          <tbl:columndef
     235            id="<%="at"+at.getId()%>"
     236            title="<%=HTML.encodeTags(at.getName())%>"
     237            formatter="<%=formatter%>"
     238          />
     239          <%
     240        }
     241        %>
    216242        <tbl:data>
    217243          <tbl:columns>
     
    226252              <tbl:cell column="spots"><%=item.getSpots()%></tbl:cell>
    227253              <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
     254              <%
     255              AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null;
     256              for (AnnotationType at : experimentalFactors)
     257              {
     258                String value = "<i>- none -</i>";
     259                List<Annotation> all = as == null ? null : as.findAnnotations(dc, at, true);
     260                Map<Annotatable, List> factorValues = new HashMap<Annotatable, List>();
     261                if (all != null && all.size() > 0)
     262                {
     263                  for (Annotation a : all)
     264                  {
     265                    List values = a.getValues();
     266                    Annotatable aItem = null;
     267                    try
     268                    {
     269                      aItem = a.getAnnotationSet().getItem();
     270                    }
     271                    catch (Throwable t)
     272                    {}
     273                    List toAdd = factorValues.get(aItem);
     274                    if (toAdd == null)
     275                    {
     276                      toAdd = new LinkedList();
     277                      factorValues.put(aItem, toAdd);
     278                    }
     279                    toAdd.addAll(values);
     280                  }
     281                }
     282                %>
     283                <tbl:cell column="<%="at"+at.getId()%>"
     284                  >
     285                  <%
     286                  for (Map.Entry<Annotatable, List> entry : factorValues.entrySet())
     287                  {
     288                    Annotatable aItem = entry.getKey();
     289                    List values = entry.getValue();
     290                    %>
     291                    <tbl:cellvalue list="<%=values%>" />
     292                    <%
     293                    if (aItem != null && aItem.hasPermission(Permission.WRITE))
     294                    {
     295                      %>: <base:icon image="edit.gif"
     296                        onclick="<%="editInheritedAnnotation('"+aItem.getType().name()+"',"+aItem.getId()+","+at.getId()+")"%>"
     297                        tooltip="Modify the values of this experimental factor" />
     298                      <%
     299                    }
     300                  }
     301                  %>
     302                </tbl:cell>
     303                <%
     304              }
     305              %>
    228306            </tbl:row>
    229307            <%
Note: See TracChangeset for help on using the changeset viewer.