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