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

Last change on this file since 4866 was 4866, checked in by Martin Svensson, 13 years ago

Fixes #1282 Change display-format of well coordinates.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 5.3 KB
Line 
1<%-- $Id: index.jsp 4866 2009-03-31 07:36:06Z martin $
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 3
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 BASE. If not, see <http://www.gnu.org/licenses/>.
20  ------------------------------------------------------------------
21
22  @author Nicklas
23  @version 2.0
24--%>
25<%@ page session="false"
26  import="net.sf.basedb.core.SessionControl"
27  import="net.sf.basedb.core.DbControl"
28  import="net.sf.basedb.core.Item"
29  import="net.sf.basedb.core.ItemContext"
30  import="net.sf.basedb.core.ItemQuery"
31  import="net.sf.basedb.core.DataQuery"
32  import="net.sf.basedb.core.DataResultIterator"
33  import="net.sf.basedb.core.Permission"
34  import="net.sf.basedb.core.PermissionDeniedException"
35  import="net.sf.basedb.core.ArrayDesign"
36  import="net.sf.basedb.core.data.FeatureData"
37  import="net.sf.basedb.core.data.ReporterData"
38  import="net.sf.basedb.clients.web.Base"
39  import="net.sf.basedb.clients.web.WebException"
40  import="net.sf.basedb.clients.web.util.HTML"
41  import="net.sf.basedb.util.Values"
42  import="net.sf.basedb.util.formatter.WellCoordinateFormatter"
43  import="java.util.List"
44%>
45<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
46<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
47<%!
48  private static final ItemContext defaultContext = Base.createDefaultContext("position", 
49    "position,externalId,block,row,column,reporter.name,reporter.externalId");
50  private static final Item itemType = Item.FEATURE;
51 
52  private static void registerExportFormatters(ItemContext cc)
53  {
54    cc.setObject("export.formatter.well.row", new WellCoordinateFormatter(true));
55    cc.setObject("export.formatter.well.column", new WellCoordinateFormatter(false));
56  }
57%>
58<%
59final int arrayDesignId = Values.getInt(request.getParameter("arraydesign_id"));
60
61final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
62final String ID = sc.getId();
63final String cmd = request.getParameter("cmd");
64final String root = request.getContextPath()+"/";
65final String listPage = "list_features.jsp?ID="+ID+"&arraydesign_id="+arrayDesignId;
66final String viewPage = "view_feature.jsp?ID="+ID+"&arraydesign_id="+arrayDesignId;
67
68String forward = null;
69String redirect = null;
70String message = null;
71DbControl dc = null;
72
73try
74{
75  if (cmd == null || "List".equals(cmd))
76  {
77    // Display the list page without updatinging the current context
78    Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true);
79    redirect = listPage;
80  }
81  else if ("UpdateContext".equals(cmd))
82  {
83    // Display the list page after updating the current context from the request parameters
84    Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
85    redirect = listPage;
86  }
87  else if ("LoadContext".equals(cmd))
88  {
89    // Display the list page after loading a saved context
90    int contextId = Values.getInt(request.getParameter("context"));
91    Base.loadContext(sc, contextId, defaultContext);
92    redirect = listPage;
93  }
94  else if ("ViewItem".equals(cmd))
95  {
96    // Display the view page for a single item
97    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
98    forward = viewPage;
99  }
100  else if ("ExportItems".equals(cmd))
101  {
102    // Run an export plugin in a list context
103    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
104    dc = sc.newDbControl();   
105    final ArrayDesign arrayDesign = ArrayDesign.getById(dc, arrayDesignId);
106    final DataQuery<FeatureData> query = arrayDesign.getFeatures();
107    cc.configureQuery(query, true);
108    registerExportFormatters(cc);
109    cc.setQuery(query);
110    redirect = "../../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+features+of+array+design";
111  }
112  else if ("CreateReporterList".equals(cmd))
113  {
114    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
115    dc = sc.newDbControl();   
116    final ArrayDesign arrayDesign = ArrayDesign.getById(dc, arrayDesignId);
117    final DataQuery<ReporterData> query = arrayDesign.getReporters();
118    cc.configureQuery(query, true);
119    cc.setQuery(query);
120    redirect = "../../../views/reporterlists/index.jsp?ID="+ID+
121      "&cmd=NewItem&addReporters=1&formId=features&fromContext=FEATURE" +
122      "&name=" + HTML.urlEncode(arrayDesign.getName());
123  }
124  else
125  {
126    throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd);
127  }
128
129}
130finally
131{
132  if (dc != null) dc.close();
133}
134if (forward != null)
135{
136  pageContext.forward(forward);
137}
138else if (redirect != null)
139{
140  response.sendRedirect(redirect);
141}
142else if (message == null)
143{
144  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0");
145}
146else
147{
148  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message));
149}
150
151%>
Note: See TracBrowser for help on using the repository browser.