6916 |
22 May 15 |
nicklas |
1 |
<%-- $Id: index.jsp 6192 2012-10-31 12:34:19Z nicklas $ |
6916 |
22 May 15 |
nicklas |
2 |
------------------------------------------------------------------ |
6916 |
22 May 15 |
nicklas |
Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg |
6916 |
22 May 15 |
nicklas |
4 |
|
6916 |
22 May 15 |
nicklas |
5 |
This file is part of BASE - BioArray Software Environment. |
6916 |
22 May 15 |
nicklas |
6 |
Available at http://base.thep.lu.se/ |
6916 |
22 May 15 |
nicklas |
7 |
|
6916 |
22 May 15 |
nicklas |
8 |
BASE is free software; you can redistribute it and/or |
6916 |
22 May 15 |
nicklas |
9 |
modify it under the terms of the GNU General Public License |
6916 |
22 May 15 |
nicklas |
10 |
as published by the Free Software Foundation; either version 3 |
6916 |
22 May 15 |
nicklas |
11 |
of the License, or (at your option) any later version. |
6916 |
22 May 15 |
nicklas |
12 |
|
6916 |
22 May 15 |
nicklas |
13 |
BASE is distributed in the hope that it will be useful, |
6916 |
22 May 15 |
nicklas |
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
6916 |
22 May 15 |
nicklas |
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
6916 |
22 May 15 |
nicklas |
16 |
GNU General Public License for more details. |
6916 |
22 May 15 |
nicklas |
17 |
|
6916 |
22 May 15 |
nicklas |
18 |
You should have received a copy of the GNU General Public License |
6916 |
22 May 15 |
nicklas |
19 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
6916 |
22 May 15 |
nicklas |
20 |
------------------------------------------------------------------ |
6916 |
22 May 15 |
nicklas |
21 |
|
6916 |
22 May 15 |
nicklas |
22 |
@author Nicklas |
6916 |
22 May 15 |
nicklas |
23 |
@version 2.0 |
6916 |
22 May 15 |
nicklas |
24 |
--%> |
6916 |
22 May 15 |
nicklas |
25 |
<%@ page pageEncoding="UTF-8" session="false" |
6916 |
22 May 15 |
nicklas |
26 |
import="net.sf.basedb.core.SessionControl" |
6916 |
22 May 15 |
nicklas |
27 |
import="net.sf.basedb.core.DbControl" |
6916 |
22 May 15 |
nicklas |
28 |
import="net.sf.basedb.core.Item" |
6916 |
22 May 15 |
nicklas |
29 |
import="net.sf.basedb.core.Include" |
6916 |
22 May 15 |
nicklas |
30 |
import="net.sf.basedb.core.Experiment" |
6916 |
22 May 15 |
nicklas |
31 |
import="net.sf.basedb.core.RootRawBioAssay" |
6916 |
22 May 15 |
nicklas |
32 |
import="net.sf.basedb.core.RawBioAssay" |
6916 |
22 May 15 |
nicklas |
33 |
import="net.sf.basedb.core.Permission" |
6916 |
22 May 15 |
nicklas |
34 |
import="net.sf.basedb.core.PluginDefinition" |
6916 |
22 May 15 |
nicklas |
35 |
import="net.sf.basedb.core.ItemContext" |
6916 |
22 May 15 |
nicklas |
36 |
import="net.sf.basedb.clients.web.Base" |
6916 |
22 May 15 |
nicklas |
37 |
import="net.sf.basedb.clients.web.WebException" |
6916 |
22 May 15 |
nicklas |
38 |
import="net.sf.basedb.util.Values" |
6916 |
22 May 15 |
nicklas |
39 |
import="net.sf.basedb.clients.web.util.HTML" |
6916 |
22 May 15 |
nicklas |
40 |
import="net.sf.basedb.core.plugin.GuiContext" |
6916 |
22 May 15 |
nicklas |
41 |
import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
6916 |
22 May 15 |
nicklas |
42 |
import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
6916 |
22 May 15 |
nicklas |
43 |
import="net.sf.basedb.clients.web.extensions.JspContext" |
6916 |
22 May 15 |
nicklas |
44 |
import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
7604 |
25 Feb 19 |
nicklas |
45 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveAction" |
6916 |
22 May 15 |
nicklas |
46 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveRenderer" |
6916 |
22 May 15 |
nicklas |
47 |
%> |
6916 |
22 May 15 |
nicklas |
48 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
6916 |
22 May 15 |
nicklas |
49 |
<%! |
6916 |
22 May 15 |
nicklas |
50 |
private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,description"); |
6916 |
22 May 15 |
nicklas |
51 |
private static final Item itemType = Item.ROOTRAWBIOASSAY; |
6916 |
22 May 15 |
nicklas |
52 |
%> |
6916 |
22 May 15 |
nicklas |
53 |
<% |
6916 |
22 May 15 |
nicklas |
54 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
6916 |
22 May 15 |
nicklas |
55 |
final String ID = sc.getId(); |
6916 |
22 May 15 |
nicklas |
56 |
final String cmd = request.getParameter("cmd"); |
6916 |
22 May 15 |
nicklas |
57 |
final String root = request.getContextPath()+"/"; |
6916 |
22 May 15 |
nicklas |
58 |
final String mode = request.getParameter("mode"); |
6916 |
22 May 15 |
nicklas |
59 |
final String callback = request.getParameter("callback"); |
6916 |
22 May 15 |
nicklas |
60 |
final String itemId = request.getParameter("item_id"); |
6916 |
22 May 15 |
nicklas |
61 |
final String viewPage = "view_bioassay.jsp?ID="+ID; |
6916 |
22 May 15 |
nicklas |
62 |
final String editPage = "edit_bioassay.jsp?ID="+ID; |
6916 |
22 May 15 |
nicklas |
63 |
|
6916 |
22 May 15 |
nicklas |
64 |
String forward = null; |
6916 |
22 May 15 |
nicklas |
65 |
String redirect = null; |
6916 |
22 May 15 |
nicklas |
66 |
String message = null; |
6916 |
22 May 15 |
nicklas |
67 |
DbControl dc = null; |
6916 |
22 May 15 |
nicklas |
68 |
|
6916 |
22 May 15 |
nicklas |
69 |
try |
6916 |
22 May 15 |
nicklas |
70 |
{ |
6916 |
22 May 15 |
nicklas |
71 |
if (cmd == null || "ViewItem".equals(cmd)) |
6916 |
22 May 15 |
nicklas |
72 |
{ |
6916 |
22 May 15 |
nicklas |
73 |
// Display the view page for a single item |
6916 |
22 May 15 |
nicklas |
74 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
6916 |
22 May 15 |
nicklas |
75 |
forward = viewPage; |
6916 |
22 May 15 |
nicklas |
76 |
} |
6916 |
22 May 15 |
nicklas |
77 |
else if ("EditItem".equals(cmd)) |
6916 |
22 May 15 |
nicklas |
78 |
{ |
6916 |
22 May 15 |
nicklas |
79 |
// Display the edit page for a single item (should be opened in a popup) |
6916 |
22 May 15 |
nicklas |
80 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
6916 |
22 May 15 |
nicklas |
81 |
redirect = editPage; |
6916 |
22 May 15 |
nicklas |
82 |
} |
6916 |
22 May 15 |
nicklas |
83 |
else if ("UpdateItem".equals(cmd)) |
6916 |
22 May 15 |
nicklas |
84 |
{ |
6916 |
22 May 15 |
nicklas |
85 |
// Update the properties on an item (will close the popup) |
6916 |
22 May 15 |
nicklas |
86 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext); |
7605 |
26 Feb 19 |
nicklas |
87 |
RootRawBioAssay ba = cc.getObject("item"); |
6916 |
22 May 15 |
nicklas |
88 |
if (ba != null) |
6916 |
22 May 15 |
nicklas |
89 |
{ |
7954 |
12 May 21 |
nicklas |
90 |
dc = sc.newDbControl(":Edit "+itemType); |
6916 |
22 May 15 |
nicklas |
91 |
dc.reattachItem(ba, false); |
6916 |
22 May 15 |
nicklas |
92 |
message = "Root raw bioassay updated"; |
6916 |
22 May 15 |
nicklas |
93 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(Item.BIOASSAY), ba); |
7604 |
25 Feb 19 |
nicklas |
94 |
ExtensionsInvoker<OnSaveAction> invoker = EditUtil.useOnSaveExtensions(jspContext); |
6916 |
22 May 15 |
nicklas |
95 |
try |
6916 |
22 May 15 |
nicklas |
96 |
{ |
6916 |
22 May 15 |
nicklas |
97 |
ba.setName(Values.getStringOrNull(request.getParameter("name"))); |
6916 |
22 May 15 |
nicklas |
98 |
ba.setDescription(Values.getStringOrNull(request.getParameter("description"))); |
6916 |
22 May 15 |
nicklas |
99 |
|
6916 |
22 May 15 |
nicklas |
100 |
// Annotations tab |
6916 |
22 May 15 |
nicklas |
101 |
Base.updateAnnotations(dc, ba, ba, request); |
6916 |
22 May 15 |
nicklas |
102 |
|
6916 |
22 May 15 |
nicklas |
103 |
// OnSave extensions |
6916 |
22 May 15 |
nicklas |
104 |
invoker.render(OnSaveRenderer.ON_SAVE); |
6916 |
22 May 15 |
nicklas |
105 |
dc.commit(); |
6916 |
22 May 15 |
nicklas |
106 |
invoker.render(OnSaveRenderer.ON_COMMIT); |
6916 |
22 May 15 |
nicklas |
107 |
} |
6916 |
22 May 15 |
nicklas |
108 |
catch (Exception ex) |
6916 |
22 May 15 |
nicklas |
109 |
{ |
6916 |
22 May 15 |
nicklas |
110 |
invoker.render(OnSaveRenderer.onRollback(ex)); |
6916 |
22 May 15 |
nicklas |
111 |
throw ex; |
6916 |
22 May 15 |
nicklas |
112 |
} |
6916 |
22 May 15 |
nicklas |
113 |
finally |
6916 |
22 May 15 |
nicklas |
114 |
{ |
6916 |
22 May 15 |
nicklas |
115 |
cc.removeObject("item"); |
6916 |
22 May 15 |
nicklas |
116 |
} |
6916 |
22 May 15 |
nicklas |
117 |
} |
6916 |
22 May 15 |
nicklas |
118 |
} |
6916 |
22 May 15 |
nicklas |
119 |
else |
6916 |
22 May 15 |
nicklas |
120 |
{ |
6916 |
22 May 15 |
nicklas |
121 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
6916 |
22 May 15 |
nicklas |
122 |
} |
6916 |
22 May 15 |
nicklas |
123 |
} |
6916 |
22 May 15 |
nicklas |
124 |
finally |
6916 |
22 May 15 |
nicklas |
125 |
{ |
6916 |
22 May 15 |
nicklas |
126 |
if (dc != null) dc.close(); |
6916 |
22 May 15 |
nicklas |
127 |
} |
6916 |
22 May 15 |
nicklas |
128 |
|
6916 |
22 May 15 |
nicklas |
129 |
if (forward != null) |
6916 |
22 May 15 |
nicklas |
130 |
{ |
6916 |
22 May 15 |
nicklas |
131 |
sc.setSessionSetting("alert-message", message); |
6916 |
22 May 15 |
nicklas |
132 |
pageContext.forward(forward); |
6916 |
22 May 15 |
nicklas |
133 |
} |
6916 |
22 May 15 |
nicklas |
134 |
else if (redirect != null) |
6916 |
22 May 15 |
nicklas |
135 |
{ |
6916 |
22 May 15 |
nicklas |
136 |
sc.setSessionSetting("alert-message", message); |
6916 |
22 May 15 |
nicklas |
137 |
response.sendRedirect(redirect); |
6916 |
22 May 15 |
nicklas |
138 |
} |
6916 |
22 May 15 |
nicklas |
139 |
else if (message == null) |
6916 |
22 May 15 |
nicklas |
140 |
{ |
6916 |
22 May 15 |
nicklas |
141 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
6916 |
22 May 15 |
nicklas |
142 |
} |
6916 |
22 May 15 |
nicklas |
143 |
else |
6916 |
22 May 15 |
nicklas |
144 |
{ |
6916 |
22 May 15 |
nicklas |
145 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
6916 |
22 May 15 |
nicklas |
146 |
} |
6916 |
22 May 15 |
nicklas |
147 |
%> |
6916 |
22 May 15 |
nicklas |
148 |
|