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