1 | <%-- $Id: index.jsp 6192 2012-10-31 12:34:19Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2005 Nicklas Nordborg |
---|
4 | Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg |
---|
5 | |
---|
6 | This file is part of BASE - BioArray Software Environment. |
---|
7 | Available at http://base.thep.lu.se/ |
---|
8 | |
---|
9 | BASE is free software; you can redistribute it and/or |
---|
10 | modify it under the terms of the GNU General Public License |
---|
11 | as published by the Free Software Foundation; either version 3 |
---|
12 | of the License, or (at your option) any later version. |
---|
13 | |
---|
14 | BASE is distributed in the hope that it will be useful, |
---|
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | GNU General Public License for more details. |
---|
18 | |
---|
19 | You should have received a copy of the GNU General Public License |
---|
20 | along with BASE. If not, see <http://www.gnu.org/licenses/>. |
---|
21 | ------------------------------------------------------------------ |
---|
22 | |
---|
23 | @author Nicklas |
---|
24 | @version 2.0 |
---|
25 | --%> |
---|
26 | <%@ page pageEncoding="UTF-8" session="false" |
---|
27 | import="net.sf.basedb.core.SessionControl" |
---|
28 | import="net.sf.basedb.core.DbControl" |
---|
29 | import="net.sf.basedb.core.Item" |
---|
30 | import="net.sf.basedb.core.ItemContext" |
---|
31 | import="net.sf.basedb.core.data.RawData" |
---|
32 | import="net.sf.basedb.core.data.ReporterData" |
---|
33 | import="net.sf.basedb.core.RawBioAssay" |
---|
34 | import="net.sf.basedb.core.RawDataType" |
---|
35 | import="net.sf.basedb.core.ItemQuery" |
---|
36 | import="net.sf.basedb.core.DataQuery" |
---|
37 | import="net.sf.basedb.core.DataResultIterator" |
---|
38 | import="net.sf.basedb.core.Permission" |
---|
39 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
40 | import="net.sf.basedb.core.query.Hql" |
---|
41 | import="net.sf.basedb.clients.web.Base" |
---|
42 | import="net.sf.basedb.clients.web.WebException" |
---|
43 | import="net.sf.basedb.clients.web.util.HTML" |
---|
44 | import="net.sf.basedb.util.Values" |
---|
45 | import="net.sf.basedb.util.formatter.WellCoordinateFormatter" |
---|
46 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
47 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
48 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
49 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
50 | import="net.sf.basedb.clients.web.extensions.list.ListColumnExportRenderer" |
---|
51 | import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil" |
---|
52 | import="java.util.List" |
---|
53 | %> |
---|
54 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
55 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
56 | <%! |
---|
57 | private static final ItemContext defaultContext = Base.createDefaultContext("position", "position,block,row,column,reporter.name,reporter.externalId"); |
---|
58 | private static final Item itemType = Item.RAWDATA; |
---|
59 | |
---|
60 | private static void registerExportFormatters(ItemContext cc) |
---|
61 | { |
---|
62 | cc.setObject("export.formatter.feature.well.row", new WellCoordinateFormatter(true)); |
---|
63 | cc.setObject("export.formatter.feature.well.column", new WellCoordinateFormatter(false)); |
---|
64 | } |
---|
65 | %> |
---|
66 | <% |
---|
67 | final int rawBioAssayId = Values.getInt(request.getParameter("rawbioassay_id")); |
---|
68 | |
---|
69 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
70 | final String ID = sc.getId(); |
---|
71 | final String cmd = request.getParameter("cmd"); |
---|
72 | final String root = request.getContextPath()+"/"; |
---|
73 | final String listPage = "list_rawdata.jsp?ID="+ID+"&rawbioassay_id="+rawBioAssayId; |
---|
74 | final String viewPage = "view_rawdata.jsp?ID="+ID+"&rawbioassay_id="+rawBioAssayId; |
---|
75 | sc.getCurrentContext(Item.RAWBIOASSAY).setId(rawBioAssayId); |
---|
76 | |
---|
77 | String forward = null; |
---|
78 | String redirect = null; |
---|
79 | String message = null; |
---|
80 | DbControl dc = null; |
---|
81 | |
---|
82 | try |
---|
83 | { |
---|
84 | dc = sc.newDbControl(); |
---|
85 | RawBioAssay rba = RawBioAssay.getById(dc, rawBioAssayId); |
---|
86 | RawDataType rawDataType = rba.getRawDataType(); |
---|
87 | |
---|
88 | if (cmd == null || "List".equals(cmd)) |
---|
89 | { |
---|
90 | // Display the list page without updatinging the current context |
---|
91 | Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), null, defaultContext); |
---|
92 | redirect = listPage; |
---|
93 | } |
---|
94 | else if ("UpdateContext".equals(cmd)) |
---|
95 | { |
---|
96 | // Display the list page after updating the current context from the request parameters |
---|
97 | Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), pageContext, defaultContext); |
---|
98 | redirect = listPage; |
---|
99 | } |
---|
100 | else if ("LoadContext".equals(cmd)) |
---|
101 | { |
---|
102 | // Display the list page after loading a saved context |
---|
103 | int contextId = Values.getInt(request.getParameter("context")); |
---|
104 | Base.loadContext(sc, contextId, defaultContext); |
---|
105 | redirect = listPage; |
---|
106 | } |
---|
107 | else if ("ViewItem".equals(cmd)) |
---|
108 | { |
---|
109 | // Display the view page for a single item |
---|
110 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), pageContext, defaultContext); |
---|
111 | forward = viewPage; |
---|
112 | } |
---|
113 | else if ("ExportItems".equals(cmd)) |
---|
114 | { |
---|
115 | // Run an export plugin in a list context |
---|
116 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), pageContext, defaultContext); |
---|
117 | final DataQuery<RawData> query = rba.getRawData(); |
---|
118 | query.join(Hql.leftJoin(null, "reporter", "r", null, true)); |
---|
119 | query.join(Hql.leftJoin(null, "feature", "f", null, true)); |
---|
120 | cc.configureQuery(dc, query, true); |
---|
121 | cc.setQuery(query); |
---|
122 | registerExportFormatters(cc); |
---|
123 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType, rawDataType.getId()), null); |
---|
124 | ExtensionsInvoker listInvoker = ListColumnUtil.useExtensions(jspContext); |
---|
125 | listInvoker.render(new ListColumnExportRenderer(cc)); |
---|
126 | redirect = "../../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&subcontext="+rawDataType.getId()+"&context_type=LIST&title=Export+raw+data"; |
---|
127 | } |
---|
128 | else if ("ImportItems".equals(cmd)) |
---|
129 | { |
---|
130 | // Run an import plugin in a list context |
---|
131 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), pageContext, defaultContext); |
---|
132 | final DataQuery<RawData> query = rba.getRawData(); |
---|
133 | query.join(Hql.leftJoin(null, "reporter", "r", null, true)); |
---|
134 | query.join(Hql.leftJoin(null, "feature", "f", null, true)); |
---|
135 | cc.configureQuery(dc, query, true); |
---|
136 | cc.setQuery(query); |
---|
137 | redirect = "../../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&subcontext="+rawDataType.getId()+"&context_type=LIST&title=Import+raw+data"; |
---|
138 | } |
---|
139 | else if ("RunListPlugin".equals(cmd)) |
---|
140 | { |
---|
141 | // Run another plugin in a list context |
---|
142 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), pageContext, defaultContext); |
---|
143 | final DataQuery<RawData> query = rba.getRawData(); |
---|
144 | query.join(Hql.leftJoin(null, "reporter", "r", null, true)); |
---|
145 | query.join(Hql.leftJoin(null, "feature", "f", null, true)); |
---|
146 | cc.configureQuery(dc, query, true); |
---|
147 | cc.setQuery(query); |
---|
148 | redirect = "../../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&subcontext="+rawDataType.getId()+"&context_type=LIST&main_type=OTHER&title=Run+plugin"; |
---|
149 | } |
---|
150 | else if ("CreateReporterList".equals(cmd)) |
---|
151 | { |
---|
152 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), pageContext, defaultContext); |
---|
153 | final DataQuery<ReporterData> query = rba.getReporters(); |
---|
154 | cc.configureQuery(dc, query, true); |
---|
155 | cc.setQuery(query); |
---|
156 | redirect = "../../../views/reporterlists/index.jsp?ID="+ID+ |
---|
157 | "&cmd=NewItem&addReporters=1&formId=rawdata&fromContext=RAWDATA&subContext="+rawDataType.getId()+ |
---|
158 | "&name=" + HTML.urlEncode(rba.getName()); |
---|
159 | } |
---|
160 | else |
---|
161 | { |
---|
162 | throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
---|
163 | } |
---|
164 | |
---|
165 | } |
---|
166 | finally |
---|
167 | { |
---|
168 | if (dc != null) dc.close(); |
---|
169 | } |
---|
170 | if (forward != null) |
---|
171 | { |
---|
172 | sc.setSessionSetting("alert-message", message); |
---|
173 | pageContext.forward(forward); |
---|
174 | } |
---|
175 | else if (redirect != null) |
---|
176 | { |
---|
177 | sc.setSessionSetting("alert-message", message); |
---|
178 | response.sendRedirect(redirect); |
---|
179 | } |
---|
180 | else if (message == null) |
---|
181 | { |
---|
182 | response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
---|
183 | } |
---|
184 | else |
---|
185 | { |
---|
186 | response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
---|
187 | } |
---|
188 | |
---|
189 | %> |
---|