1 | <%-- $Id: index.jsp 4305 2008-05-21 11:11:20Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2005 Nicklas Nordborg |
---|
4 | Copyright (C) 2006 Jari Hakkinen, 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 2 |
---|
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 this program; if not, write to the Free Software |
---|
21 | Foundation, Inc., 59 Temple Place - Suite 330, |
---|
22 | Boston, MA 02111-1307, USA. |
---|
23 | ------------------------------------------------------------------ |
---|
24 | |
---|
25 | @author Nicklas |
---|
26 | @version 2.0 |
---|
27 | --%> |
---|
28 | <%@ page session="false" |
---|
29 | import="net.sf.basedb.core.SessionControl" |
---|
30 | import="net.sf.basedb.core.DbControl" |
---|
31 | import="net.sf.basedb.core.Item" |
---|
32 | import="net.sf.basedb.core.ItemContext" |
---|
33 | import="net.sf.basedb.core.data.RawData" |
---|
34 | import="net.sf.basedb.core.data.ReporterData" |
---|
35 | import="net.sf.basedb.core.RawBioAssay" |
---|
36 | import="net.sf.basedb.core.RawDataType" |
---|
37 | import="net.sf.basedb.core.ItemQuery" |
---|
38 | import="net.sf.basedb.core.DataQuery" |
---|
39 | import="net.sf.basedb.core.DataResultIterator" |
---|
40 | import="net.sf.basedb.core.Permission" |
---|
41 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
42 | import="net.sf.basedb.clients.web.Base" |
---|
43 | import="net.sf.basedb.clients.web.WebException" |
---|
44 | import="net.sf.basedb.clients.web.util.HTML" |
---|
45 | import="net.sf.basedb.util.Values" |
---|
46 | import="java.util.List" |
---|
47 | %> |
---|
48 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
49 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
50 | <%! |
---|
51 | private static final ItemContext defaultContext = Base.createDefaultContext("position", "position,block,row,column,reporter.name,reporter.externalId"); |
---|
52 | private static final Item itemType = Item.RAWDATA; |
---|
53 | %> |
---|
54 | <% |
---|
55 | final int rawBioAssayId = Values.getInt(request.getParameter("rawbioassay_id")); |
---|
56 | |
---|
57 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
58 | final String ID = sc.getId(); |
---|
59 | final String cmd = request.getParameter("cmd"); |
---|
60 | final String root = request.getContextPath()+"/"; |
---|
61 | final String listPage = "list_rawdata.jsp?ID="+ID+"&rawbioassay_id="+rawBioAssayId; |
---|
62 | final String viewPage = "view_rawdata.jsp?ID="+ID+"&rawbioassay_id="+rawBioAssayId; |
---|
63 | sc.getCurrentContext(Item.RAWBIOASSAY).setId(rawBioAssayId); |
---|
64 | |
---|
65 | String forward = null; |
---|
66 | String redirect = null; |
---|
67 | String message = null; |
---|
68 | DbControl dc = null; |
---|
69 | |
---|
70 | try |
---|
71 | { |
---|
72 | dc = sc.newDbControl(); |
---|
73 | RawBioAssay rba = RawBioAssay.getById(dc, rawBioAssayId); |
---|
74 | RawDataType rawDataType = rba.getRawDataType(); |
---|
75 | dc.close(); |
---|
76 | |
---|
77 | if (cmd == null || "List".equals(cmd)) |
---|
78 | { |
---|
79 | // Display the list page without updatinging the current context |
---|
80 | Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), null, defaultContext); |
---|
81 | redirect = listPage; |
---|
82 | } |
---|
83 | else if ("UpdateContext".equals(cmd)) |
---|
84 | { |
---|
85 | // Display the list page after updating the current context from the request parameters |
---|
86 | Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), pageContext, defaultContext); |
---|
87 | redirect = listPage; |
---|
88 | } |
---|
89 | else if ("LoadContext".equals(cmd)) |
---|
90 | { |
---|
91 | // Display the list page after loading a saved context |
---|
92 | int contextId = Values.getInt(request.getParameter("context")); |
---|
93 | Base.loadContext(sc, contextId, defaultContext); |
---|
94 | redirect = listPage; |
---|
95 | } |
---|
96 | else if ("ViewItem".equals(cmd)) |
---|
97 | { |
---|
98 | // Display the view page for a single item |
---|
99 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), pageContext, defaultContext); |
---|
100 | forward = viewPage; |
---|
101 | } |
---|
102 | else if ("ExportItems".equals(cmd)) |
---|
103 | { |
---|
104 | // Run an export plugin in a list context |
---|
105 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), pageContext, defaultContext); |
---|
106 | final DataQuery<RawData> query = rba.getRawData(); |
---|
107 | cc.configureQuery(query, true); |
---|
108 | cc.setQuery(query); |
---|
109 | redirect = "../../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&subcontext="+rawDataType.getId()+"&context_type=LIST&title=Export+raw+data"; |
---|
110 | } |
---|
111 | else if ("ImportItems".equals(cmd)) |
---|
112 | { |
---|
113 | // Run an import plugin in a list context |
---|
114 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), pageContext, defaultContext); |
---|
115 | final DataQuery<RawData> query = rba.getRawData(); |
---|
116 | cc.configureQuery(query, true); |
---|
117 | cc.setQuery(query); |
---|
118 | redirect = "../../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&subcontext="+rawDataType.getId()+"&context_type=LIST&title=Import+raw+data"; |
---|
119 | } |
---|
120 | else if ("RunListPlugin".equals(cmd)) |
---|
121 | { |
---|
122 | // Run another plugin in a list context |
---|
123 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), pageContext, defaultContext); |
---|
124 | final DataQuery<RawData> query = rba.getRawData(); |
---|
125 | cc.configureQuery(query, true); |
---|
126 | cc.setQuery(query); |
---|
127 | 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"; |
---|
128 | } |
---|
129 | else if ("CreateReporterList".equals(cmd)) |
---|
130 | { |
---|
131 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), pageContext, defaultContext); |
---|
132 | final DataQuery<ReporterData> query = rba.getReporters(); |
---|
133 | cc.configureQuery(query, true); |
---|
134 | cc.setQuery(query); |
---|
135 | redirect = "../../../views/reporterlists/index.jsp?ID="+ID+ |
---|
136 | "&cmd=NewItem&addReporters=1&formId=rawdata&fromContext=RAWDATA&subContext="+rawDataType.getId()+ |
---|
137 | "&name=" + HTML.urlEncode(rba.getName()); |
---|
138 | } |
---|
139 | else |
---|
140 | { |
---|
141 | throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
---|
142 | } |
---|
143 | |
---|
144 | } |
---|
145 | finally |
---|
146 | { |
---|
147 | if (dc != null) dc.close(); |
---|
148 | } |
---|
149 | if (forward != null) |
---|
150 | { |
---|
151 | pageContext.forward(forward); |
---|
152 | } |
---|
153 | else if (redirect != null) |
---|
154 | { |
---|
155 | response.sendRedirect(redirect); |
---|
156 | } |
---|
157 | else if (message == null) |
---|
158 | { |
---|
159 | response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
---|
160 | } |
---|
161 | else |
---|
162 | { |
---|
163 | response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
---|
164 | } |
---|
165 | |
---|
166 | %> |
---|