1 | <%-- $Id: index.jsp 5111 2009-09-30 10:56:51Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2006 Nicklas Nordborg |
---|
4 | |
---|
5 | This file is part of BASE - BioArray Software Environment. |
---|
6 | Available at http://base.thep.lu.se/ |
---|
7 | |
---|
8 | This file is part of BASE. |
---|
9 | |
---|
10 | BASE is free software; you can redistribute it and/or |
---|
11 | modify it under the terms of the GNU General Public License |
---|
12 | as published by the Free Software Foundation; either version 3 |
---|
13 | of the License, or (at your option) any later version. |
---|
14 | |
---|
15 | BASE is distributed in the hope that it will be useful, |
---|
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
18 | GNU General Public License for more details. |
---|
19 | |
---|
20 | You should have received a copy of the GNU General Public License |
---|
21 | along with BASE. If not, see <http://www.gnu.org/licenses/>. |
---|
22 | ------------------------------------------------------------------ |
---|
23 | |
---|
24 | @author Nicklas |
---|
25 | @version 2.0 |
---|
26 | --%> |
---|
27 | <%@ page session="false" |
---|
28 | import="net.sf.basedb.core.SessionControl" |
---|
29 | import="net.sf.basedb.core.DbControl" |
---|
30 | import="net.sf.basedb.core.Item" |
---|
31 | import="net.sf.basedb.core.ItemContext" |
---|
32 | import="net.sf.basedb.core.BioAssaySet" |
---|
33 | import="net.sf.basedb.clients.web.Base" |
---|
34 | import="net.sf.basedb.clients.web.ExperimentExplorer" |
---|
35 | import="net.sf.basedb.clients.web.WebException" |
---|
36 | import="net.sf.basedb.util.Values" |
---|
37 | import="net.sf.basedb.clients.web.util.HTML" |
---|
38 | import="java.util.Set" |
---|
39 | import="java.util.Arrays" |
---|
40 | %> |
---|
41 | <% |
---|
42 | final int bioAssaySetId = Values.getInt(request.getParameter("bioassayset_id")); |
---|
43 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
44 | final String ID = sc.getId(); |
---|
45 | final String cmd = request.getParameter("cmd"); |
---|
46 | final String root = request.getContextPath()+"/"; |
---|
47 | |
---|
48 | final String viewPage = "view.jsp?ID="+ID+"&bioassayset_id="+bioAssaySetId; |
---|
49 | |
---|
50 | String forward = null; |
---|
51 | String redirect = null; |
---|
52 | String message = null; |
---|
53 | |
---|
54 | DbControl dc = null; |
---|
55 | try |
---|
56 | { |
---|
57 | dc = sc.newDbControl(); |
---|
58 | BioAssaySet bioAssaySet = BioAssaySet.getById(dc, bioAssaySetId); |
---|
59 | ExperimentExplorer explorer = ExperimentExplorer.getExplorer(bioAssaySet); |
---|
60 | if (cmd == null || "Explore".equals(cmd)) |
---|
61 | { |
---|
62 | redirect = viewPage; |
---|
63 | } |
---|
64 | else if ("UpdateContext".equals(cmd)) |
---|
65 | { |
---|
66 | ItemContext cc = explorer.getAndSetSpotContext(sc, pageContext); |
---|
67 | redirect = viewPage; |
---|
68 | } |
---|
69 | else if ("SetReporterColumns".equals(cmd)) |
---|
70 | { |
---|
71 | ItemContext cc = explorer.getAndSetSpotContext(sc, null); |
---|
72 | cc.setSetting("reporter-columns", Values.getString(request.getParameter("columns"), cc.getSetting("reporter-columns"))); |
---|
73 | redirect = viewPage; |
---|
74 | } |
---|
75 | else if ("SetReporterIndex".equals(cmd)) |
---|
76 | { |
---|
77 | explorer.setReporterIndex(Values.getInt(request.getParameter("reporterIndex"))); |
---|
78 | redirect = viewPage; |
---|
79 | } |
---|
80 | else if ("SetSpotIndex".equals(cmd)) |
---|
81 | { |
---|
82 | explorer.setPositionIndex(Values.getInt(request.getParameter("spotIndex"))); |
---|
83 | redirect = viewPage; |
---|
84 | } |
---|
85 | else if ("SetAnnotationType".equals(cmd)) |
---|
86 | { |
---|
87 | Integer[] annotationTypes = Values.getInt(request.getParameter("annotationtype_id").split("|")); |
---|
88 | Set<Integer> tmp = explorer.getAnnotationTypeIds(); |
---|
89 | tmp.clear(); |
---|
90 | tmp.addAll(Arrays.asList(annotationTypes)); |
---|
91 | |
---|
92 | // If an annotation type is selected the annotation column must be visible as the first column |
---|
93 | ItemContext cc = explorer.getAndSetSpotContext(sc, null); |
---|
94 | String columns = cc.getSetting("columns"); |
---|
95 | columns = columns.replaceAll("annotation\\.\\d+,", ""); |
---|
96 | for (Integer atId : annotationTypes) |
---|
97 | { |
---|
98 | columns = "annotation." + atId + "," + columns; |
---|
99 | } |
---|
100 | cc.setSetting("columns", columns); |
---|
101 | redirect = viewPage; |
---|
102 | } |
---|
103 | else |
---|
104 | { |
---|
105 | throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
---|
106 | } |
---|
107 | } |
---|
108 | finally |
---|
109 | { |
---|
110 | if (dc != null) dc.close(); |
---|
111 | } |
---|
112 | if (forward != null) |
---|
113 | { |
---|
114 | pageContext.forward(forward); |
---|
115 | } |
---|
116 | else if (redirect != null) |
---|
117 | { |
---|
118 | response.sendRedirect(redirect); |
---|
119 | } |
---|
120 | else if (message == null) |
---|
121 | { |
---|
122 | response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
---|
123 | } |
---|
124 | else |
---|
125 | { |
---|
126 | response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
---|
127 | } |
---|
128 | |
---|
129 | %> |
---|
130 | |
---|
131 | |
---|
132 | |
---|
133 | |
---|