1666 |
25 Nov 05 |
nicklas |
1 |
<%-- $Id$ |
1666 |
25 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, Martin Svensson |
1666 |
25 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/ |
1666 |
25 Nov 05 |
nicklas |
8 |
|
1666 |
25 Nov 05 |
nicklas |
9 |
BASE is free software; you can redistribute it and/or |
1666 |
25 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 |
1666 |
25 Nov 05 |
nicklas |
12 |
of the License, or (at your option) any later version. |
1666 |
25 Nov 05 |
nicklas |
13 |
|
1666 |
25 Nov 05 |
nicklas |
14 |
BASE is distributed in the hope that it will be useful, |
1666 |
25 Nov 05 |
nicklas |
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
1666 |
25 Nov 05 |
nicklas |
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1666 |
25 Nov 05 |
nicklas |
17 |
GNU General Public License for more details. |
1666 |
25 Nov 05 |
nicklas |
18 |
|
1666 |
25 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/>. |
1666 |
25 Nov 05 |
nicklas |
21 |
------------------------------------------------------------------ |
1666 |
25 Nov 05 |
nicklas |
22 |
|
1666 |
25 Nov 05 |
nicklas |
23 |
@author Nicklas |
1666 |
25 Nov 05 |
nicklas |
24 |
@version 2.0 |
1666 |
25 Nov 05 |
nicklas |
25 |
--%> |
5426 |
24 Sep 10 |
nicklas |
26 |
<%@ page pageEncoding="UTF-8" session="false" |
1666 |
25 Nov 05 |
nicklas |
27 |
import="net.sf.basedb.core.SessionControl" |
1666 |
25 Nov 05 |
nicklas |
28 |
import="net.sf.basedb.core.DbControl" |
1666 |
25 Nov 05 |
nicklas |
29 |
import="net.sf.basedb.core.Item" |
1812 |
24 Jan 06 |
nicklas |
30 |
import="net.sf.basedb.core.Include" |
5642 |
26 May 11 |
nicklas |
31 |
import="net.sf.basedb.core.PhysicalBioAssay " |
1666 |
25 Nov 05 |
nicklas |
32 |
import="net.sf.basedb.core.ArraySlide" |
1812 |
24 Jan 06 |
nicklas |
33 |
import="net.sf.basedb.core.ArrayBatch" |
1812 |
24 Jan 06 |
nicklas |
34 |
import="net.sf.basedb.core.Protocol" |
1666 |
25 Nov 05 |
nicklas |
35 |
import="net.sf.basedb.core.ItemQuery" |
1666 |
25 Nov 05 |
nicklas |
36 |
import="net.sf.basedb.core.ItemResultIterator" |
1666 |
25 Nov 05 |
nicklas |
37 |
import="net.sf.basedb.core.Permission" |
1812 |
24 Jan 06 |
nicklas |
38 |
import="net.sf.basedb.core.ItemContext" |
1812 |
24 Jan 06 |
nicklas |
39 |
import="net.sf.basedb.core.MultiPermissions" |
4587 |
15 Oct 08 |
martin |
40 |
import="net.sf.basedb.core.OwnedItem" |
6695 |
28 Jan 15 |
nicklas |
41 |
import="net.sf.basedb.core.AnnotatedItem" |
6695 |
28 Jan 15 |
nicklas |
42 |
import="net.sf.basedb.core.InvalidDataException" |
1812 |
24 Jan 06 |
nicklas |
43 |
import="net.sf.basedb.core.PermissionDeniedException" |
1812 |
24 Jan 06 |
nicklas |
44 |
import="net.sf.basedb.core.ItemAlreadyExistsException" |
4220 |
14 Apr 08 |
nicklas |
45 |
import="net.sf.basedb.core.HibernateUtil" |
1812 |
24 Jan 06 |
nicklas |
46 |
import="net.sf.basedb.util.RemovableUtil" |
1812 |
24 Jan 06 |
nicklas |
47 |
import="net.sf.basedb.util.ShareableUtil" |
2919 |
15 Nov 06 |
nicklas |
48 |
import="net.sf.basedb.util.OwnableUtil" |
1666 |
25 Nov 05 |
nicklas |
49 |
import="net.sf.basedb.clients.web.Base" |
1812 |
24 Jan 06 |
nicklas |
50 |
import="net.sf.basedb.clients.web.WebException" |
2753 |
20 Oct 06 |
nicklas |
51 |
import="net.sf.basedb.util.Values" |
1666 |
25 Nov 05 |
nicklas |
52 |
import="net.sf.basedb.clients.web.util.HTML" |
5498 |
17 Nov 10 |
nicklas |
53 |
import="net.sf.basedb.core.plugin.GuiContext" |
5498 |
17 Nov 10 |
nicklas |
54 |
import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
5498 |
17 Nov 10 |
nicklas |
55 |
import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
5498 |
17 Nov 10 |
nicklas |
56 |
import="net.sf.basedb.clients.web.extensions.JspContext" |
5498 |
17 Nov 10 |
nicklas |
57 |
import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
7604 |
25 Feb 19 |
nicklas |
58 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveAction" |
5498 |
17 Nov 10 |
nicklas |
59 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveRenderer" |
6039 |
29 Mar 12 |
nicklas |
60 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnExportRenderer" |
7604 |
25 Feb 19 |
nicklas |
61 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnAction" |
6039 |
29 Mar 12 |
nicklas |
62 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil" |
1812 |
24 Jan 06 |
nicklas |
63 |
import="java.util.Enumeration" |
1812 |
24 Jan 06 |
nicklas |
64 |
import="java.util.Set" |
1812 |
24 Jan 06 |
nicklas |
65 |
import="java.util.HashSet" |
4220 |
14 Apr 08 |
nicklas |
66 |
import="java.util.TreeSet" |
1666 |
25 Nov 05 |
nicklas |
67 |
import="java.util.List" |
1812 |
24 Jan 06 |
nicklas |
68 |
import="java.util.ArrayList" |
1812 |
24 Jan 06 |
nicklas |
69 |
import="java.util.Collections" |
1666 |
25 Nov 05 |
nicklas |
70 |
%> |
1666 |
25 Nov 05 |
nicklas |
71 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
1666 |
25 Nov 05 |
nicklas |
72 |
<%! |
5642 |
26 May 11 |
nicklas |
73 |
private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,arrayDesign,physicalBioAssay,description"); |
1812 |
24 Jan 06 |
nicklas |
74 |
private static final Item itemType = Item.ARRAYSLIDE; |
1666 |
25 Nov 05 |
nicklas |
75 |
%> |
1666 |
25 Nov 05 |
nicklas |
76 |
<% |
1812 |
24 Jan 06 |
nicklas |
77 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
1666 |
25 Nov 05 |
nicklas |
78 |
final String ID = sc.getId(); |
1812 |
24 Jan 06 |
nicklas |
79 |
final String cmd = request.getParameter("cmd"); |
1812 |
24 Jan 06 |
nicklas |
80 |
final String root = request.getContextPath()+"/"; |
1812 |
24 Jan 06 |
nicklas |
81 |
final String mode = request.getParameter("mode"); |
1812 |
24 Jan 06 |
nicklas |
82 |
final String callback = request.getParameter("callback"); |
1812 |
24 Jan 06 |
nicklas |
83 |
final String itemId = request.getParameter("item_id"); |
1812 |
24 Jan 06 |
nicklas |
84 |
final String listPage = "list_slides.jsp?ID="+ID |
1812 |
24 Jan 06 |
nicklas |
85 |
+(mode == null ? "" : "&mode="+mode) |
1812 |
24 Jan 06 |
nicklas |
86 |
+(callback == null ? "" : "&callback="+callback) |
1812 |
24 Jan 06 |
nicklas |
87 |
+(itemId == null ? "" : "&item_id="+itemId); |
1812 |
24 Jan 06 |
nicklas |
88 |
final String viewPage = "view_slide.jsp?ID="+ID; |
1812 |
24 Jan 06 |
nicklas |
89 |
final String editPage = "edit_slide.jsp?ID="+ID; |
2231 |
10 May 06 |
martin |
90 |
final String wizardPage = "create_wizard.jsp?ID="+ID+"&cmd=WizardStep1"; |
1666 |
25 Nov 05 |
nicklas |
91 |
|
1812 |
24 Jan 06 |
nicklas |
92 |
String forward = null; |
1812 |
24 Jan 06 |
nicklas |
93 |
String redirect = null; |
1812 |
24 Jan 06 |
nicklas |
94 |
String message = null; |
1812 |
24 Jan 06 |
nicklas |
95 |
DbControl dc = null; |
1812 |
24 Jan 06 |
nicklas |
96 |
|
1666 |
25 Nov 05 |
nicklas |
97 |
try |
1666 |
25 Nov 05 |
nicklas |
98 |
{ |
1812 |
24 Jan 06 |
nicklas |
99 |
if (cmd == null || "List".equals(cmd)) |
1666 |
25 Nov 05 |
nicklas |
100 |
{ |
1812 |
24 Jan 06 |
nicklas |
101 |
// Display the list page without updatinging the current context |
2811 |
26 Oct 06 |
nicklas |
102 |
Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true); |
1812 |
24 Jan 06 |
nicklas |
103 |
redirect = listPage; |
1666 |
25 Nov 05 |
nicklas |
104 |
} |
1812 |
24 Jan 06 |
nicklas |
105 |
else if ("UpdateContext".equals(cmd)) |
1812 |
24 Jan 06 |
nicklas |
106 |
{ |
1812 |
24 Jan 06 |
nicklas |
107 |
// Display the list page after updating the current context from the request parameters |
1812 |
24 Jan 06 |
nicklas |
108 |
Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1812 |
24 Jan 06 |
nicklas |
109 |
redirect = listPage; |
1812 |
24 Jan 06 |
nicklas |
110 |
} |
1812 |
24 Jan 06 |
nicklas |
111 |
else if ("LoadContext".equals(cmd)) |
1812 |
24 Jan 06 |
nicklas |
112 |
{ |
1812 |
24 Jan 06 |
nicklas |
113 |
// Display the list page after loading a saved context |
1812 |
24 Jan 06 |
nicklas |
114 |
int contextId = Values.getInt(request.getParameter("context")); |
1812 |
24 Jan 06 |
nicklas |
115 |
Base.loadContext(sc, contextId, defaultContext); |
1812 |
24 Jan 06 |
nicklas |
116 |
redirect = listPage; |
1812 |
24 Jan 06 |
nicklas |
117 |
} |
1666 |
25 Nov 05 |
nicklas |
118 |
|
1812 |
24 Jan 06 |
nicklas |
119 |
else if ("ViewItem".equals(cmd)) |
1812 |
24 Jan 06 |
nicklas |
120 |
{ |
1812 |
24 Jan 06 |
nicklas |
121 |
// Display the view page for a single item |
1812 |
24 Jan 06 |
nicklas |
122 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1812 |
24 Jan 06 |
nicklas |
123 |
forward = viewPage; |
1812 |
24 Jan 06 |
nicklas |
124 |
} |
1812 |
24 Jan 06 |
nicklas |
125 |
else if ("EditItem".equals(cmd)) |
1812 |
24 Jan 06 |
nicklas |
126 |
{ |
1812 |
24 Jan 06 |
nicklas |
127 |
// Display the edit page for a single item (should be opened in a popup) |
1812 |
24 Jan 06 |
nicklas |
128 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1812 |
24 Jan 06 |
nicklas |
129 |
redirect = editPage; |
1812 |
24 Jan 06 |
nicklas |
130 |
} |
1812 |
24 Jan 06 |
nicklas |
131 |
else if ("NewItem".equals(cmd)) |
1812 |
24 Jan 06 |
nicklas |
132 |
{ |
1812 |
24 Jan 06 |
nicklas |
133 |
// Display the edit page for a new item (should be opened in a popup) |
1812 |
24 Jan 06 |
nicklas |
134 |
if (!sc.hasPermission(Permission.CREATE, itemType)) |
1666 |
25 Nov 05 |
nicklas |
135 |
{ |
1812 |
24 Jan 06 |
nicklas |
136 |
throw new PermissionDeniedException(Permission.CREATE, itemType.toString()); |
1666 |
25 Nov 05 |
nicklas |
137 |
} |
1812 |
24 Jan 06 |
nicklas |
138 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1812 |
24 Jan 06 |
nicklas |
139 |
cc.setId(0); |
2449 |
29 Jun 06 |
nicklas |
140 |
forward = editPage; |
2231 |
10 May 06 |
martin |
141 |
} |
1812 |
24 Jan 06 |
nicklas |
142 |
else if ("UpdateItem".equals(cmd)) |
1812 |
24 Jan 06 |
nicklas |
143 |
{ |
1812 |
24 Jan 06 |
nicklas |
144 |
// Update the properties on an item (will close the popup) |
1812 |
24 Jan 06 |
nicklas |
145 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext); |
2598 |
28 Aug 06 |
nicklas |
146 |
final int maxRecent = Base.getMaxRecent(sc); |
7954 |
12 May 21 |
nicklas |
147 |
dc = sc.newDbControl(":Edit "+itemType); |
7605 |
26 Feb 19 |
nicklas |
148 |
ArraySlide slide = cc.getObject("item"); |
1812 |
24 Jan 06 |
nicklas |
149 |
if (slide == null) |
1666 |
25 Nov 05 |
nicklas |
150 |
{ |
1812 |
24 Jan 06 |
nicklas |
151 |
int batchId = Values.getInt(request.getParameter("arraybatch_id"), -1); |
2598 |
28 Aug 06 |
nicklas |
152 |
ArrayBatch batch = ArrayBatch.getById(dc, batchId); |
2598 |
28 Aug 06 |
nicklas |
153 |
slide = ArraySlide.getNew(dc, batch); |
1812 |
24 Jan 06 |
nicklas |
154 |
message = "Array slide created"; |
1812 |
24 Jan 06 |
nicklas |
155 |
dc.saveItem(slide); |
7703 |
11 Apr 19 |
nicklas |
156 |
cc.setRecent(Item.ARRAYBATCH, batch, maxRecent); |
1666 |
25 Nov 05 |
nicklas |
157 |
} |
1812 |
24 Jan 06 |
nicklas |
158 |
else |
1666 |
25 Nov 05 |
nicklas |
159 |
{ |
5060 |
19 Aug 09 |
nicklas |
160 |
dc.reattachItem(slide, false); |
1812 |
24 Jan 06 |
nicklas |
161 |
message = "Array slide updated"; |
1666 |
25 Nov 05 |
nicklas |
162 |
} |
5498 |
17 Nov 10 |
nicklas |
163 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(Item.ARRAYSLIDE), slide); |
7604 |
25 Feb 19 |
nicklas |
164 |
ExtensionsInvoker<OnSaveAction> invoker = EditUtil.useOnSaveExtensions(jspContext); |
5498 |
17 Nov 10 |
nicklas |
165 |
try |
4220 |
14 Apr 08 |
nicklas |
166 |
{ |
5498 |
17 Nov 10 |
nicklas |
167 |
slide.setName(Values.getStringOrNull(request.getParameter("name"))); |
5498 |
17 Nov 10 |
nicklas |
168 |
String newBarcode = Values.getStringOrNull(request.getParameter("barcode")); |
5498 |
17 Nov 10 |
nicklas |
169 |
if (newBarcode != null && !newBarcode.equals(slide.getBarcode())) |
4220 |
14 Apr 08 |
nicklas |
170 |
{ |
5498 |
17 Nov 10 |
nicklas |
171 |
if (ArraySlide.barcodeExists(dc, newBarcode)) |
5498 |
17 Nov 10 |
nicklas |
172 |
{ |
5498 |
17 Nov 10 |
nicklas |
173 |
throw new ItemAlreadyExistsException("ArraySlide[barcode=" + newBarcode + "]"); |
5498 |
17 Nov 10 |
nicklas |
174 |
} |
4220 |
14 Apr 08 |
nicklas |
175 |
} |
5498 |
17 Nov 10 |
nicklas |
176 |
slide.setBarcode(newBarcode); |
5498 |
17 Nov 10 |
nicklas |
177 |
slide.setBatchIndex(Values.getInt(request.getParameter("batch_index"))); |
5498 |
17 Nov 10 |
nicklas |
178 |
slide.setDestroyed(Values.getBoolean(request.getParameter("destroyed"))); |
5498 |
17 Nov 10 |
nicklas |
179 |
slide.setDescription(Values.getStringOrNull(request.getParameter("description"))); |
5498 |
17 Nov 10 |
nicklas |
180 |
|
5498 |
17 Nov 10 |
nicklas |
181 |
// Annotations tab |
5498 |
17 Nov 10 |
nicklas |
182 |
Base.updateAnnotations(dc, slide, slide, request); |
5498 |
17 Nov 10 |
nicklas |
183 |
|
5498 |
17 Nov 10 |
nicklas |
184 |
// OnSave extensions |
5498 |
17 Nov 10 |
nicklas |
185 |
invoker.render(OnSaveRenderer.ON_SAVE); |
5498 |
17 Nov 10 |
nicklas |
186 |
dc.commit(); |
5498 |
17 Nov 10 |
nicklas |
187 |
invoker.render(OnSaveRenderer.ON_COMMIT); |
4220 |
14 Apr 08 |
nicklas |
188 |
} |
5498 |
17 Nov 10 |
nicklas |
189 |
catch (Exception ex) |
5498 |
17 Nov 10 |
nicklas |
190 |
{ |
5498 |
17 Nov 10 |
nicklas |
191 |
invoker.render(OnSaveRenderer.onRollback(ex)); |
5498 |
17 Nov 10 |
nicklas |
192 |
throw ex; |
5498 |
17 Nov 10 |
nicklas |
193 |
} |
5498 |
17 Nov 10 |
nicklas |
194 |
finally |
5498 |
17 Nov 10 |
nicklas |
195 |
{ |
5498 |
17 Nov 10 |
nicklas |
196 |
cc.removeObject("item"); |
5498 |
17 Nov 10 |
nicklas |
197 |
} |
1812 |
24 Jan 06 |
nicklas |
198 |
} |
2231 |
10 May 06 |
martin |
199 |
else if ("NewItems".equals(cmd)) |
2231 |
10 May 06 |
martin |
200 |
{ |
2231 |
10 May 06 |
martin |
201 |
// Display the wizard page for new items wizard(should be open in a popup) |
2231 |
10 May 06 |
martin |
202 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2231 |
10 May 06 |
martin |
203 |
cc.setId(0); |
2449 |
29 Jun 06 |
nicklas |
204 |
forward = wizardPage; |
2231 |
10 May 06 |
martin |
205 |
} |
2231 |
10 May 06 |
martin |
206 |
else if ("CreateItems".equals(cmd)) |
2231 |
10 May 06 |
martin |
207 |
{ |
2231 |
10 May 06 |
martin |
208 |
//Finish the wizard and create the given quantity of Array slides |
2231 |
10 May 06 |
martin |
209 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext); |
2598 |
28 Aug 06 |
nicklas |
210 |
final int maxRecent = Base.getMaxRecent(sc); |
7954 |
12 May 21 |
nicklas |
211 |
dc = sc.newDbControl(":Batch create array slides"); |
2231 |
10 May 06 |
martin |
212 |
int quantity = Values.getInt(request.getParameter("quantity")); |
5136 |
15 Oct 09 |
nicklas |
213 |
int batchId = Values.getInt(request.getParameter("arraybatch_id")); |
5136 |
15 Oct 09 |
nicklas |
214 |
int startAt = Values.getInt(request.getParameter("start_at"), 1); |
2267 |
17 May 06 |
nicklas |
215 |
String description = Values.getStringOrNull(request.getParameter("description")); |
2267 |
17 May 06 |
nicklas |
216 |
ArrayBatch batch = ArrayBatch.getById(dc, batchId); |
7703 |
11 Apr 19 |
nicklas |
217 |
cc.setRecent(Item.ARRAYBATCH, batch, maxRecent); |
4220 |
14 Apr 08 |
nicklas |
218 |
boolean caseInsensitive = HibernateUtil.getDbEngine().caseInsensitiveComparison(); |
4220 |
14 Apr 08 |
nicklas |
219 |
Set<String> barcodes = caseInsensitive ? |
4220 |
14 Apr 08 |
nicklas |
220 |
new TreeSet<String>(String.CASE_INSENSITIVE_ORDER) : new HashSet<String>(); |
2457 |
30 Jun 06 |
nicklas |
221 |
for (int i = 0; i < quantity; ++i) |
2267 |
17 May 06 |
nicklas |
222 |
{ |
2267 |
17 May 06 |
nicklas |
223 |
ArraySlide slide = ArraySlide.getNew(dc, batch); |
2231 |
10 May 06 |
martin |
224 |
dc.saveItem(slide); |
2267 |
17 May 06 |
nicklas |
225 |
slide.setName(Values.getStringOrNull(request.getParameter("name"+i))); |
5136 |
15 Oct 09 |
nicklas |
226 |
slide.setBatchIndex(startAt + i); |
4220 |
14 Apr 08 |
nicklas |
227 |
|
4220 |
14 Apr 08 |
nicklas |
228 |
String newBarcode = Values.getStringOrNull(request.getParameter("barcode" + i)); |
4220 |
14 Apr 08 |
nicklas |
229 |
if (newBarcode != null) |
4220 |
14 Apr 08 |
nicklas |
230 |
{ |
4220 |
14 Apr 08 |
nicklas |
231 |
if (barcodes.contains(newBarcode)) |
4220 |
14 Apr 08 |
nicklas |
232 |
{ |
4220 |
14 Apr 08 |
nicklas |
233 |
throw new InvalidDataException("Trying to create more than one slide with barcode=" + newBarcode); |
4220 |
14 Apr 08 |
nicklas |
234 |
} |
4220 |
14 Apr 08 |
nicklas |
235 |
else if (ArraySlide.barcodeExists(dc, newBarcode)) |
4220 |
14 Apr 08 |
nicklas |
236 |
{ |
4220 |
14 Apr 08 |
nicklas |
237 |
throw new ItemAlreadyExistsException("ArraySlide[barcode=" + newBarcode + "]"); |
4220 |
14 Apr 08 |
nicklas |
238 |
} |
4220 |
14 Apr 08 |
nicklas |
239 |
barcodes.add(newBarcode); |
4220 |
14 Apr 08 |
nicklas |
240 |
} |
4220 |
14 Apr 08 |
nicklas |
241 |
slide.setBarcode(newBarcode); |
2231 |
10 May 06 |
martin |
242 |
slide.setDescription(description); |
2231 |
10 May 06 |
martin |
243 |
} |
2231 |
10 May 06 |
martin |
244 |
dc.commit(); |
2231 |
10 May 06 |
martin |
245 |
message = quantity + " Array slides created"; |
2231 |
10 May 06 |
martin |
246 |
} |
1812 |
24 Jan 06 |
nicklas |
247 |
else if ("DeleteItem".equals(cmd)) |
1812 |
24 Jan 06 |
nicklas |
248 |
{ |
1812 |
24 Jan 06 |
nicklas |
249 |
// Delete a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
250 |
dc = sc.newDbControl(":Delete "+itemType); |
1812 |
24 Jan 06 |
nicklas |
251 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1812 |
24 Jan 06 |
nicklas |
252 |
RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), true); |
1812 |
24 Jan 06 |
nicklas |
253 |
dc.commit(); |
1812 |
24 Jan 06 |
nicklas |
254 |
redirect = viewPage; |
1812 |
24 Jan 06 |
nicklas |
255 |
} |
1812 |
24 Jan 06 |
nicklas |
256 |
else if ("DeleteItems".equals(cmd)) |
1812 |
24 Jan 06 |
nicklas |
257 |
{ |
1812 |
24 Jan 06 |
nicklas |
258 |
// Delete all selected items on the list page |
7954 |
12 May 21 |
nicklas |
259 |
dc = sc.newDbControl(":Delete "+itemType); |
1812 |
24 Jan 06 |
nicklas |
260 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1812 |
24 Jan 06 |
nicklas |
261 |
int numTotal = cc.getSelected().size(); |
1812 |
24 Jan 06 |
nicklas |
262 |
int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), true); |
1812 |
24 Jan 06 |
nicklas |
263 |
dc.commit(); |
1812 |
24 Jan 06 |
nicklas |
264 |
if (numTotal != numRemoved) |
1666 |
25 Nov 05 |
nicklas |
265 |
{ |
1812 |
24 Jan 06 |
nicklas |
266 |
message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be deleted, because you have no DELETE permission"; |
1666 |
25 Nov 05 |
nicklas |
267 |
} |
6192 |
31 Oct 12 |
nicklas |
268 |
redirect = listPage; |
1812 |
24 Jan 06 |
nicklas |
269 |
} |
1812 |
24 Jan 06 |
nicklas |
270 |
else if ("RestoreItem".equals(cmd)) |
1812 |
24 Jan 06 |
nicklas |
271 |
{ |
1812 |
24 Jan 06 |
nicklas |
272 |
// Restore a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
273 |
dc = sc.newDbControl(":Restore "+itemType); |
1812 |
24 Jan 06 |
nicklas |
274 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1812 |
24 Jan 06 |
nicklas |
275 |
RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), false); |
1812 |
24 Jan 06 |
nicklas |
276 |
dc.commit(); |
1812 |
24 Jan 06 |
nicklas |
277 |
redirect = viewPage; |
1812 |
24 Jan 06 |
nicklas |
278 |
} |
1812 |
24 Jan 06 |
nicklas |
279 |
else if ("RestoreItems".equals(cmd)) |
1812 |
24 Jan 06 |
nicklas |
280 |
{ |
1812 |
24 Jan 06 |
nicklas |
281 |
// Restore all selected items on the list page |
7954 |
12 May 21 |
nicklas |
282 |
dc = sc.newDbControl(":Restore "+itemType); |
1812 |
24 Jan 06 |
nicklas |
283 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1812 |
24 Jan 06 |
nicklas |
284 |
int numTotal = cc.getSelected().size(); |
1812 |
24 Jan 06 |
nicklas |
285 |
int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), false); |
1812 |
24 Jan 06 |
nicklas |
286 |
dc.commit(); |
1812 |
24 Jan 06 |
nicklas |
287 |
if (numTotal != numRemoved) |
1666 |
25 Nov 05 |
nicklas |
288 |
{ |
2528 |
15 Aug 06 |
martin |
289 |
message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be restored, because you have no WRITE permission"; |
1666 |
25 Nov 05 |
nicklas |
290 |
} |
6192 |
31 Oct 12 |
nicklas |
291 |
redirect = listPage; |
1812 |
24 Jan 06 |
nicklas |
292 |
} |
1812 |
24 Jan 06 |
nicklas |
293 |
else if ("ShareItem".equals(cmd)) |
1812 |
24 Jan 06 |
nicklas |
294 |
{ |
1812 |
24 Jan 06 |
nicklas |
295 |
// Display a popup window for sharing a single item |
7954 |
12 May 21 |
nicklas |
296 |
dc = sc.newDbControl(":Share "+itemType); |
1812 |
24 Jan 06 |
nicklas |
297 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1812 |
24 Jan 06 |
nicklas |
298 |
MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, Collections.singleton(cc.getId())); |
1812 |
24 Jan 06 |
nicklas |
299 |
dc.close(); |
1812 |
24 Jan 06 |
nicklas |
300 |
cc.setObject("MultiPermissions", permissions); |
1812 |
24 Jan 06 |
nicklas |
301 |
redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name(); |
1812 |
24 Jan 06 |
nicklas |
302 |
} |
1812 |
24 Jan 06 |
nicklas |
303 |
else if ("ShareItems".equals(cmd)) |
1812 |
24 Jan 06 |
nicklas |
304 |
{ |
1812 |
24 Jan 06 |
nicklas |
305 |
// Display a popup window for sharing all selected items on the list page |
7954 |
12 May 21 |
nicklas |
306 |
dc = sc.newDbControl(":Share "+itemType); |
1812 |
24 Jan 06 |
nicklas |
307 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1812 |
24 Jan 06 |
nicklas |
308 |
MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, cc.getSelected()); |
1812 |
24 Jan 06 |
nicklas |
309 |
dc.close(); |
1812 |
24 Jan 06 |
nicklas |
310 |
cc.setObject("MultiPermissions", permissions); |
1812 |
24 Jan 06 |
nicklas |
311 |
redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name(); |
1812 |
24 Jan 06 |
nicklas |
312 |
} |
4578 |
13 Oct 08 |
martin |
313 |
else if ("SetOwnerOfItem".equals(cmd)) |
2919 |
15 Nov 06 |
nicklas |
314 |
{ |
4578 |
13 Oct 08 |
martin |
315 |
// Change owner of items selected on a list page |
7954 |
12 May 21 |
nicklas |
316 |
dc = sc.newDbControl(":Set owner of "+itemType); |
2919 |
15 Nov 06 |
nicklas |
317 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4587 |
15 Oct 08 |
martin |
318 |
OwnedItem item = (OwnedItem)itemType.getById(dc, cc.getId()); |
4587 |
15 Oct 08 |
martin |
319 |
cc.setObject("OwnedItems", Collections.singleton(item)); |
4578 |
13 Oct 08 |
martin |
320 |
redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name(); |
2919 |
15 Nov 06 |
nicklas |
321 |
} |
4578 |
13 Oct 08 |
martin |
322 |
else if ("SetOwnerOfItems".equals(cmd)) |
2919 |
15 Nov 06 |
nicklas |
323 |
{ |
4578 |
13 Oct 08 |
martin |
324 |
// Change owner of items selected on a list page |
7954 |
12 May 21 |
nicklas |
325 |
dc = sc.newDbControl(":Set owner of "+itemType); |
2919 |
15 Nov 06 |
nicklas |
326 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4587 |
15 Oct 08 |
martin |
327 |
Set<OwnedItem> items = new HashSet<OwnedItem>(); |
4587 |
15 Oct 08 |
martin |
328 |
for (Integer id : cc.getSelected()) |
4587 |
15 Oct 08 |
martin |
329 |
{ |
4587 |
15 Oct 08 |
martin |
330 |
if (id != null) items.add((OwnedItem)itemType.getById(dc, id)); |
4587 |
15 Oct 08 |
martin |
331 |
} |
4587 |
15 Oct 08 |
martin |
332 |
dc.close(); |
4587 |
15 Oct 08 |
martin |
333 |
cc.setObject("OwnedItems", items); |
4578 |
13 Oct 08 |
martin |
334 |
redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name(); |
2919 |
15 Nov 06 |
nicklas |
335 |
} |
6695 |
28 Jan 15 |
nicklas |
336 |
else if ("InheritAnnotations".equals(cmd)) |
6695 |
28 Jan 15 |
nicklas |
337 |
{ |
6695 |
28 Jan 15 |
nicklas |
338 |
// Change owner of items selected on a list page |
7954 |
12 May 21 |
nicklas |
339 |
dc = sc.newDbControl(":Inherit annotations "+itemType); |
6695 |
28 Jan 15 |
nicklas |
340 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
6695 |
28 Jan 15 |
nicklas |
341 |
Set<AnnotatedItem> items = new HashSet<AnnotatedItem>(); |
6695 |
28 Jan 15 |
nicklas |
342 |
for (Integer id : cc.getSelected()) |
6695 |
28 Jan 15 |
nicklas |
343 |
{ |
6695 |
28 Jan 15 |
nicklas |
344 |
if (id != null) items.add((AnnotatedItem)itemType.getById(dc, id)); |
6695 |
28 Jan 15 |
nicklas |
345 |
} |
6695 |
28 Jan 15 |
nicklas |
346 |
dc.close(); |
6695 |
28 Jan 15 |
nicklas |
347 |
cc.setObject("AnnotatedItems", items); |
6695 |
28 Jan 15 |
nicklas |
348 |
redirect = "../../common/annotations/batch_inherit.jsp?ID="+ID+"&item_type="+itemType.name(); |
6695 |
28 Jan 15 |
nicklas |
349 |
} |
1812 |
24 Jan 06 |
nicklas |
350 |
else if ("ExportItems".equals(cmd)) |
1812 |
24 Jan 06 |
nicklas |
351 |
{ |
1812 |
24 Jan 06 |
nicklas |
352 |
// Run an export plugin in a list context |
1812 |
24 Jan 06 |
nicklas |
353 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1812 |
24 Jan 06 |
nicklas |
354 |
final ItemQuery<ArraySlide> query = ArraySlide.getQuery(); |
7954 |
12 May 21 |
nicklas |
355 |
dc = sc.newDbControl(":Export "+itemType); |
7914 |
23 Feb 21 |
nicklas |
356 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
357 |
cc.configureQuery(dc, query, jspContext, true); |
6039 |
29 Mar 12 |
nicklas |
358 |
cc.setQuery(query); |
7604 |
25 Feb 19 |
nicklas |
359 |
ExtensionsInvoker<ListColumnAction<ArraySlide,?>> listInvoker = ListColumnUtil.useExtensions(jspContext); |
7604 |
25 Feb 19 |
nicklas |
360 |
listInvoker.render(new ListColumnExportRenderer<ArraySlide>(cc)); |
5590 |
16 Mar 11 |
nicklas |
361 |
dc.close(); |
4835 |
24 Mar 09 |
nicklas |
362 |
redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+array+slides"; |
1812 |
24 Jan 06 |
nicklas |
363 |
} |
1812 |
24 Jan 06 |
nicklas |
364 |
else if ("ExportItem".equals(cmd)) |
1812 |
24 Jan 06 |
nicklas |
365 |
{ |
1812 |
24 Jan 06 |
nicklas |
366 |
// Run an export plugin in single-item context |
1812 |
24 Jan 06 |
nicklas |
367 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4835 |
24 Mar 09 |
nicklas |
368 |
redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+array+slide"; |
1812 |
24 Jan 06 |
nicklas |
369 |
} |
1812 |
24 Jan 06 |
nicklas |
370 |
else if ("ImportItems".equals(cmd)) |
1812 |
24 Jan 06 |
nicklas |
371 |
{ |
1812 |
24 Jan 06 |
nicklas |
372 |
// Run an import plugin in a list context |
1812 |
24 Jan 06 |
nicklas |
373 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1812 |
24 Jan 06 |
nicklas |
374 |
final ItemQuery<ArraySlide> query = ArraySlide.getQuery(); |
7954 |
12 May 21 |
nicklas |
375 |
dc = sc.newDbControl(":Import "+itemType); |
7914 |
23 Feb 21 |
nicklas |
376 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
377 |
cc.configureQuery(dc, query, jspContext, true); |
5590 |
16 Mar 11 |
nicklas |
378 |
dc.close(); |
1812 |
24 Jan 06 |
nicklas |
379 |
cc.setQuery(query); |
4835 |
24 Mar 09 |
nicklas |
380 |
redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Import+array+slides"; |
1812 |
24 Jan 06 |
nicklas |
381 |
} |
1812 |
24 Jan 06 |
nicklas |
382 |
else if ("ImportItem".equals(cmd)) |
1812 |
24 Jan 06 |
nicklas |
383 |
{ |
1812 |
24 Jan 06 |
nicklas |
384 |
// Run an import plugin in single-item context |
1812 |
24 Jan 06 |
nicklas |
385 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4835 |
24 Mar 09 |
nicklas |
386 |
redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Import+array+slide"; |
1812 |
24 Jan 06 |
nicklas |
387 |
} |
1812 |
24 Jan 06 |
nicklas |
388 |
else if ("RunListPlugin".equals(cmd)) |
1812 |
24 Jan 06 |
nicklas |
389 |
{ |
1812 |
24 Jan 06 |
nicklas |
390 |
// Run another plugin in a list context |
1812 |
24 Jan 06 |
nicklas |
391 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1812 |
24 Jan 06 |
nicklas |
392 |
final ItemQuery<ArraySlide> query = ArraySlide.getQuery(); |
7954 |
12 May 21 |
nicklas |
393 |
dc = sc.newDbControl(":Run plugin "+itemType); |
7914 |
23 Feb 21 |
nicklas |
394 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
395 |
cc.configureQuery(dc, query, jspContext, true); |
5590 |
16 Mar 11 |
nicklas |
396 |
dc.close(); |
1812 |
24 Jan 06 |
nicklas |
397 |
cc.setQuery(query); |
1812 |
24 Jan 06 |
nicklas |
398 |
redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&main_type=OTHER&title=Run+plugin"; |
1812 |
24 Jan 06 |
nicklas |
399 |
} |
1812 |
24 Jan 06 |
nicklas |
400 |
else if ("RunPlugin".equals(cmd)) |
1812 |
24 Jan 06 |
nicklas |
401 |
{ |
1812 |
24 Jan 06 |
nicklas |
402 |
// Run another plugin in single-item context |
1812 |
24 Jan 06 |
nicklas |
403 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1812 |
24 Jan 06 |
nicklas |
404 |
redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=OTHER&title=Run+plugin"; |
1812 |
24 Jan 06 |
nicklas |
405 |
} |
1812 |
24 Jan 06 |
nicklas |
406 |
else |
1812 |
24 Jan 06 |
nicklas |
407 |
{ |
1812 |
24 Jan 06 |
nicklas |
408 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
1812 |
24 Jan 06 |
nicklas |
409 |
} |
1666 |
25 Nov 05 |
nicklas |
410 |
} |
1666 |
25 Nov 05 |
nicklas |
411 |
finally |
1666 |
25 Nov 05 |
nicklas |
412 |
{ |
1666 |
25 Nov 05 |
nicklas |
413 |
if (dc != null) dc.close(); |
1666 |
25 Nov 05 |
nicklas |
414 |
} |
1812 |
24 Jan 06 |
nicklas |
415 |
|
1812 |
24 Jan 06 |
nicklas |
416 |
if (forward != null) |
1812 |
24 Jan 06 |
nicklas |
417 |
{ |
6192 |
31 Oct 12 |
nicklas |
418 |
sc.setSessionSetting("alert-message", message); |
1812 |
24 Jan 06 |
nicklas |
419 |
pageContext.forward(forward); |
1812 |
24 Jan 06 |
nicklas |
420 |
} |
1812 |
24 Jan 06 |
nicklas |
421 |
else if (redirect != null) |
1812 |
24 Jan 06 |
nicklas |
422 |
{ |
6192 |
31 Oct 12 |
nicklas |
423 |
sc.setSessionSetting("alert-message", message); |
1812 |
24 Jan 06 |
nicklas |
424 |
response.sendRedirect(redirect); |
1812 |
24 Jan 06 |
nicklas |
425 |
} |
1812 |
24 Jan 06 |
nicklas |
426 |
else if (message == null) |
1812 |
24 Jan 06 |
nicklas |
427 |
{ |
1812 |
24 Jan 06 |
nicklas |
428 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
1812 |
24 Jan 06 |
nicklas |
429 |
} |
1812 |
24 Jan 06 |
nicklas |
430 |
else |
1812 |
24 Jan 06 |
nicklas |
431 |
{ |
1812 |
24 Jan 06 |
nicklas |
432 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
1812 |
24 Jan 06 |
nicklas |
433 |
} |
1812 |
24 Jan 06 |
nicklas |
434 |
%> |
1812 |
24 Jan 06 |
nicklas |
435 |
|