source: trunk/www/lims/arraydesigns/features/index.jsp @ 4305

Last change on this file since 4305 was 4305, checked in by Nicklas Nordborg, 15 years ago

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

It is now possible to create reporter lists from features, wells and raw data, eg. all DataQuery?-based item types. Creating the lists using queries from the dynamic database needs a different solution.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 5.0 KB
Line 
1<%-- $Id: index.jsp 4305 2008-05-21 11:11:20Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Hakkinen, Nicklas Nordborg
4
5  This file is part of BASE - BioArray Software Environment.
6  Available at http://base.thep.lu.se/
7
8  BASE is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License
10  as published by the Free Software Foundation; either version 2
11  of the License, or (at your option) any later version.
12
13  BASE is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA  02111-1307, USA.
22  ------------------------------------------------------------------
23
24  @author Nicklas
25  @version 2.0
26--%>
27<%@ page session="false"
28  import="net.sf.basedb.core.SessionControl"
29  import="net.sf.basedb.core.DbControl"
30  import="net.sf.basedb.core.Item"
31  import="net.sf.basedb.core.ItemContext"
32  import="net.sf.basedb.core.ItemQuery"
33  import="net.sf.basedb.core.DataQuery"
34  import="net.sf.basedb.core.DataResultIterator"
35  import="net.sf.basedb.core.Permission"
36  import="net.sf.basedb.core.PermissionDeniedException"
37  import="net.sf.basedb.core.ArrayDesign"
38  import="net.sf.basedb.core.data.FeatureData"
39  import="net.sf.basedb.core.data.ReporterData"
40  import="net.sf.basedb.clients.web.Base"
41  import="net.sf.basedb.clients.web.WebException"
42  import="net.sf.basedb.clients.web.util.HTML"
43  import="net.sf.basedb.util.Values"
44  import="java.util.List"
45%>
46<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
47<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
48<%!
49  private static final ItemContext defaultContext = Base.createDefaultContext("position", 
50    "position,externalId,block,row,column,reporter.name,reporter.externalId");
51  private static final Item itemType = Item.FEATURE;
52%>
53<%
54final int arrayDesignId = Values.getInt(request.getParameter("arraydesign_id"));
55
56final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
57final String ID = sc.getId();
58final String cmd = request.getParameter("cmd");
59final String root = request.getContextPath()+"/";
60final String listPage = "list_features.jsp?ID="+ID+"&arraydesign_id="+arrayDesignId;
61final String viewPage = "view_feature.jsp?ID="+ID+"&arraydesign_id="+arrayDesignId;
62
63String forward = null;
64String redirect = null;
65String message = null;
66DbControl dc = null;
67
68try
69{
70  if (cmd == null || "List".equals(cmd))
71  {
72    // Display the list page without updatinging the current context
73    Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true);
74    redirect = listPage;
75  }
76  else if ("UpdateContext".equals(cmd))
77  {
78    // Display the list page after updating the current context from the request parameters
79    Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
80    redirect = listPage;
81  }
82  else if ("LoadContext".equals(cmd))
83  {
84    // Display the list page after loading a saved context
85    int contextId = Values.getInt(request.getParameter("context"));
86    Base.loadContext(sc, contextId, defaultContext);
87    redirect = listPage;
88  }
89  else if ("ViewItem".equals(cmd))
90  {
91    // Display the view page for a single item
92    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
93    forward = viewPage;
94  }
95  else if ("ExportItems".equals(cmd))
96  {
97    // Run an export plugin in a list context
98    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
99    dc = sc.newDbControl();   
100    final ArrayDesign arrayDesign = ArrayDesign.getById(dc, arrayDesignId);
101    final DataQuery<FeatureData> query = arrayDesign.getFeatures();
102    cc.configureQuery(query, true);
103    cc.setQuery(query);
104    redirect = "../../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+features+of+array+design";
105  }
106  else if ("CreateReporterList".equals(cmd))
107  {
108    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
109    dc = sc.newDbControl();   
110    final ArrayDesign arrayDesign = ArrayDesign.getById(dc, arrayDesignId);
111    final DataQuery<ReporterData> query = arrayDesign.getReporters();
112    cc.configureQuery(query, true);
113    cc.setQuery(query);
114    redirect = "../../../views/reporterlists/index.jsp?ID="+ID+
115      "&cmd=NewItem&addReporters=1&formId=features&fromContext=FEATURE" +
116      "&name=" + HTML.urlEncode(arrayDesign.getName());
117  }
118  else
119  {
120    throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd);
121  }
122
123}
124finally
125{
126  if (dc != null) dc.close();
127}
128if (forward != null)
129{
130  pageContext.forward(forward);
131}
132else if (redirect != null)
133{
134  response.sendRedirect(redirect);
135}
136else if (message == null)
137{
138  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0");
139}
140else
141{
142  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message));
143}
144
145%>
Note: See TracBrowser for help on using the repository browser.