1 | <%-- $Id: index.jsp 6949 2015-09-10 12:34:16Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2006 Jari Häkkinen, 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 pageEncoding="UTF-8" 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.core.query.Hql" |
---|
39 | import="net.sf.basedb.clients.web.Base" |
---|
40 | import="net.sf.basedb.clients.web.WebException" |
---|
41 | import="net.sf.basedb.clients.web.util.HTML" |
---|
42 | import="net.sf.basedb.util.Values" |
---|
43 | import="net.sf.basedb.util.formatter.WellCoordinateFormatter" |
---|
44 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
45 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
46 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
47 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
48 | import="net.sf.basedb.clients.web.extensions.list.ListColumnExportRenderer" |
---|
49 | import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil" |
---|
50 | import="java.util.List" |
---|
51 | %> |
---|
52 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
53 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
54 | <%! |
---|
55 | private static final ItemContext defaultContext = Base.createDefaultContext("position", |
---|
56 | "position,externalId,block,row,column,reporter.name,reporter.externalId"); |
---|
57 | private static final Item itemType = Item.FEATURE; |
---|
58 | |
---|
59 | private static void registerExportFormatters(ItemContext cc) |
---|
60 | { |
---|
61 | cc.setObject("export.formatter.well.row", new WellCoordinateFormatter(true)); |
---|
62 | cc.setObject("export.formatter.well.column", new WellCoordinateFormatter(false)); |
---|
63 | } |
---|
64 | %> |
---|
65 | <% |
---|
66 | final int arrayDesignId = Values.getInt(request.getParameter("arraydesign_id")); |
---|
67 | |
---|
68 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
69 | final String ID = sc.getId(); |
---|
70 | final String cmd = request.getParameter("cmd"); |
---|
71 | final String root = request.getContextPath()+"/"; |
---|
72 | final String listPage = "list_features.jsp?ID="+ID+"&arraydesign_id="+arrayDesignId; |
---|
73 | final String viewPage = "view_feature.jsp?ID="+ID+"&arraydesign_id="+arrayDesignId; |
---|
74 | |
---|
75 | String forward = null; |
---|
76 | String redirect = null; |
---|
77 | String message = null; |
---|
78 | DbControl dc = null; |
---|
79 | |
---|
80 | try |
---|
81 | { |
---|
82 | if (cmd == null || "List".equals(cmd)) |
---|
83 | { |
---|
84 | // Display the list page without updatinging the current context |
---|
85 | Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true); |
---|
86 | redirect = listPage; |
---|
87 | } |
---|
88 | else if ("UpdateContext".equals(cmd)) |
---|
89 | { |
---|
90 | // Display the list page after updating the current context from the request parameters |
---|
91 | Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
92 | redirect = listPage; |
---|
93 | } |
---|
94 | else if ("LoadContext".equals(cmd)) |
---|
95 | { |
---|
96 | // Display the list page after loading a saved context |
---|
97 | int contextId = Values.getInt(request.getParameter("context")); |
---|
98 | Base.loadContext(sc, contextId, defaultContext); |
---|
99 | redirect = listPage; |
---|
100 | } |
---|
101 | else if ("ViewItem".equals(cmd)) |
---|
102 | { |
---|
103 | // Display the view page for a single item |
---|
104 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
105 | forward = viewPage; |
---|
106 | } |
---|
107 | else if ("ExportItems".equals(cmd)) |
---|
108 | { |
---|
109 | // Run an export plugin in a list context |
---|
110 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
111 | dc = sc.newDbControl(); |
---|
112 | final ArrayDesign arrayDesign = ArrayDesign.getById(dc, arrayDesignId); |
---|
113 | final DataQuery<FeatureData> query = arrayDesign.getFeatures(); |
---|
114 | query.join(Hql.leftJoin(null, "reporter", "rpt", null, true)); |
---|
115 | cc.configureQuery(dc, query, true); |
---|
116 | cc.setQuery(query); |
---|
117 | registerExportFormatters(cc); |
---|
118 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
---|
119 | ExtensionsInvoker listInvoker = ListColumnUtil.useExtensions(jspContext); |
---|
120 | listInvoker.render(new ListColumnExportRenderer(cc)); |
---|
121 | dc.close(); |
---|
122 | redirect = "../../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+features+of+array+design"; |
---|
123 | } |
---|
124 | else if ("CreateReporterList".equals(cmd)) |
---|
125 | { |
---|
126 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
127 | dc = sc.newDbControl(); |
---|
128 | final ArrayDesign arrayDesign = ArrayDesign.getById(dc, arrayDesignId); |
---|
129 | final DataQuery<ReporterData> query = arrayDesign.getReporters(); |
---|
130 | query.join(Hql.leftJoin("reporter", "rpt")); |
---|
131 | cc.configureQuery(dc, query, true); |
---|
132 | dc.close(); |
---|
133 | cc.setQuery(query); |
---|
134 | redirect = "../../../views/reporterlists/index.jsp?ID="+ID+ |
---|
135 | "&cmd=NewItem&addReporters=1&formId=features&fromContext=FEATURE" + |
---|
136 | "&name=" + HTML.urlEncode(arrayDesign.getName()); |
---|
137 | } |
---|
138 | else |
---|
139 | { |
---|
140 | throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
---|
141 | } |
---|
142 | |
---|
143 | } |
---|
144 | finally |
---|
145 | { |
---|
146 | if (dc != null) dc.close(); |
---|
147 | } |
---|
148 | if (forward != null) |
---|
149 | { |
---|
150 | sc.setSessionSetting("alert-message", message); |
---|
151 | pageContext.forward(forward); |
---|
152 | } |
---|
153 | else if (redirect != null) |
---|
154 | { |
---|
155 | sc.setSessionSetting("alert-message", message); |
---|
156 | response.sendRedirect(redirect); |
---|
157 | } |
---|
158 | else if (message == null) |
---|
159 | { |
---|
160 | response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
---|
161 | } |
---|
162 | else |
---|
163 | { |
---|
164 | response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
---|
165 | } |
---|
166 | |
---|
167 | %> |
---|