Changeset 4306


Ignore:
Timestamp:
May 21, 2008, 3:39:59 PM (14 years ago)
Author:
Nicklas Nordborg
Message:

References #1015: Add reporter list from tables that list reporters/reporter info

It is now working from dynamic queries as well.

Location:
trunk
Files:
8 edited

Legend:

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

    r4020 r4306  
    121121    return rd;
    122122  }
     123 
     124  /**
     125    Get a proxy reporter object. This method is usefult when linking
     126    reporters to other items, and you are sure that a reporter with the given ID
     127    exists. Since this method doesn't hit the database, there are some things to
     128    be aware of:
     129    <ul>
     130    <li>There is no check to see if a reporter with the given ID exists or
     131      not
     132    <li>The returned object doesn't contain any reporter information
     133      except the ID.
     134    </ul>
     135   
     136    @param reporterId The ID of the reporter
     137    @return A reporter object
     138    @since 2.8
     139  */
     140  public static ReporterData getProxy(int reporterId)
     141  {
     142    return new ReporterData(reporterId);
     143  }
    123144
    124145  /**
  • trunk/src/core/net/sf/basedb/core/data/ReporterData.java

    r4082 r4306  
    6060
    6161  /**
     62    Create a reporter object with a given ID.
     63    @param id The reporter ID
     64    @since 2.8
     65  */
     66  public ReporterData(int id)
     67  {
     68    setId(id);
     69  }
     70 
     71  /**
    6272    The maximum length of the external ID that can be stored in the database.
    6373    @see #setExternalId(String)
  • trunk/www/views/experiments/explorer/search/index.jsp

    r2978 r4306  
    3333  import="net.sf.basedb.core.ItemContext"
    3434  import="net.sf.basedb.core.BioAssaySet"
     35  import="net.sf.basedb.core.DynamicSpotQuery"
    3536  import="net.sf.basedb.clients.web.Base"
    3637  import="net.sf.basedb.clients.web.ExperimentExplorer"
     
    3839  import="net.sf.basedb.util.Values"
    3940  import="net.sf.basedb.clients.web.util.HTML"
     41  import="java.util.Collections"
    4042%>
    4143<%
     
    6870    redirect = listPage;
    6971  }
     72  else if ("CreateReporterList".equals(cmd))
     73  {
     74    ItemContext cc = explorer.getAndSetReporterContext(sc, pageContext);
     75    DynamicSpotQuery query = explorer.getReporterQuery(dc, Collections.singletonList("@id"));
     76    cc.setQuery(query);
     77    redirect = "../../../reporterlists/index.jsp?ID="+ID+
     78        "&cmd=NewItem&addReporters=1&formId=&fromContext=" + cc.getItemType().name() +
     79        "&subContext="+cc.getSubContext() + "&name=" + HTML.urlEncode(bioAssaySet.getName());
     80  }
     81
    7082  else
    7183  {
  • trunk/www/views/experiments/explorer/search/list.jsp

    r4302 r4306  
    3131  import="net.sf.basedb.core.Item"
    3232  import="net.sf.basedb.core.ItemContext"
     33  import="net.sf.basedb.core.Permission"
    3334  import="net.sf.basedb.core.BioAssaySet"
    3435  import="net.sf.basedb.core.Experiment"
     
    157158      }
    158159    }
     160    function newReporterList()
     161    {
     162      Table.submitToPopup(formId, 'CreateReporterList', 540, 400);
     163    }
    159164  </script>
    160165  </base:head>
     
    231236          title="Columns&hellip;"
    232237          tooltip="Show, hide and re-order columns"
     238        />
     239        <tbl:button
     240          image="add.png"
     241          onclick="newReporterList()"
     242          title="New reporter list&hellip;"
     243          tooltip="Create a new reporter list from matching reporters"
     244          visible="<%=sc.hasPermission(Permission.CREATE, Item.REPORTERLIST)%>"
    233245        />
    234246      </tbl:toolbar>
  • trunk/www/views/experiments/spotdata/index.jsp

    r3679 r4306  
    4141  import="java.util.Map"
    4242  import="java.util.HashMap"
     43  import="java.util.Collections"
    4344%>
    4445<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    127128    redirect = "../../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+spot+data";
    128129  }
     130  else if ("CreateReporterList".equals(cmd))
     131  {
     132    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, subContext, pageContext, defaultContext);
     133    dc = sc.newDbControl();
     134    if (bas != null) dc.reattachItem(bas);
     135    if (ba != null) dc.reattachItem(ba);
     136    final DynamicSpotQuery query = ba != null ? ba.getSpotData() : bas.getSpotData();
     137    cc.configureQuery(dc, query, Collections.singletonList("@id"));
     138    cc.setQuery(query);
     139    redirect = "../../../views/reporterlists/index.jsp?ID="+ID+
     140      "&cmd=NewItem&addReporters=1&formId=&fromContext=SPOTDATA&subContext=" + subContext +
     141      "&name=" + HTML.urlEncode(ba != null ? ba.getName() : bas.getName());
     142  }
     143 
    129144  else
    130145  {
  • trunk/www/views/experiments/spotdata/list_spotdata.jsp

    r4302 r4306  
    169169      }
    170170    }
     171    function newReporterList()
     172    {
     173      Table.submitToPopup(formId, 'CreateReporterList', 540, 400);
     174    }
    171175    </script>
    172176  </base:head>
     
    306310          title="Columns&hellip;"
    307311          tooltip="Show, hide and re-order columns"
     312        />
     313        <tbl:button
     314          image="add.png"
     315          onclick="newReporterList()"
     316          title="New reporter list&hellip;"
     317          tooltip="Create a new reporter list from matching spots"
     318          visible="<%=sc.hasPermission(Permission.CREATE, Item.REPORTERLIST)%>"
    308319        />
    309320        <tbl:button
  • trunk/www/views/reporterlists/edit_reporterlist.jsp

    r4305 r4306  
    5656  boolean mergeReporterLists = false;
    5757  int numSelectedLists = cc.getSelected().size();
    58   String formId = Values.getString(request.getParameter("formId"), "reporters");
     58  String formId = request.getParameter("formId");
    5959  String fromContext = Values.getString(request.getParameter("fromContext"), "REPORTER");
    6060  String subContext = request.getParameter("subContext");
     
    154154    }
    155155    // Get the ID:s of all selected reorters
    156     var selectedItems;
     156    var selectedItems = new Array();
    157157    function getSelectedItems()
    158158    {
    159       if (!selectedItems)
    160       {
    161         selectedItems = window.opener.Table.getSelected('<%=formId%>');
    162       }
     159      <%
     160      if (formId != null)
     161      {
     162        %>
     163        if (!selectedItems)
     164        {
     165          selectedItems = window.opener.Table.getSelected('<%=formId%>');
     166        }
     167        <%
     168      }
     169      %>
    163170      return selectedItems;
    164171    }
  • trunk/www/views/reporterlists/index.jsp

    r4305 r4306  
    3232  import="net.sf.basedb.core.ReporterList"
    3333  import="net.sf.basedb.core.FileType"
     34  import="net.sf.basedb.core.Reporter"
    3435  import="net.sf.basedb.core.Permission"
    3536  import="net.sf.basedb.core.Type"
     
    3738  import="net.sf.basedb.core.DataQuery"
    3839  import="net.sf.basedb.core.ItemQuery"
     40  import="net.sf.basedb.core.DynamicQuery"
    3941  import="net.sf.basedb.core.DataResultIterator"
     42  import="net.sf.basedb.core.DynamicResultIterator"
    4043  import="net.sf.basedb.core.MultiPermissions"
    4144  import="net.sf.basedb.core.PermissionDeniedException"
    4245  import="net.sf.basedb.core.ItemAlreadyExistsException"
    4346  import="net.sf.basedb.core.data.ReporterData"
     47  import="net.sf.basedb.core.query.Query"
    4448  import="net.sf.basedb.core.query.Restrictions"
    4549  import="net.sf.basedb.core.query.Expressions"
    4650  import="net.sf.basedb.core.query.Hql"
     51  import="net.sf.basedb.core.query.SqlResult"
    4752  import="net.sf.basedb.util.RemovableUtil"
    4853  import="net.sf.basedb.util.ShareableUtil"
     
    147152        Item fromContext = Item.valueOf(request.getParameter("fromContext"));
    148153        String subContext = Values.getString(request.getParameter("subContext"), "");
    149         DataQuery<ReporterData> query =
    150           (DataQuery<ReporterData>)sc.getCurrentContext(fromContext, subContext).getQuery();
     154        Query query = sc.getCurrentContext(fromContext, subContext).getQuery();
    151155        if ("all".equals(which))
    152156        {
     
    169173        // else -- no modifications to the query mean that we only get the current page
    170174       
    171         DataResultIterator<ReporterData> result = query.iterate(dc);
    172         while (result.hasNext())
    173         {
    174           ReporterData reporter = result.next();
    175           if (reporter != null) rl.addReporter(reporter, null);
     175        if (query instanceof DataQuery)
     176        {
     177          DataResultIterator<ReporterData> result = ((DataQuery<ReporterData>)query).iterate(dc);
     178          while (result.hasNext())
     179          {
     180            ReporterData reporter = result.next();
     181            if (reporter != null) rl.addReporter(reporter, null);
     182          }
     183        }
     184        else if (query instanceof DynamicQuery)
     185        {
     186          DynamicResultIterator result = ((DynamicQuery)query).iterate(dc);
     187          while (result.hasNext())
     188          {
     189            SqlResult i = result.next();
     190            int reporterId = i.getInt(1);
     191            if (reporterId != 0)
     192            {
     193              rl.addReporter(Reporter.getProxy(reporterId), null);
     194            }
     195          }
    176196        }
    177197      }
Note: See TracChangeset for help on using the changeset viewer.