1 | <%-- $Id: index.jsp 3523 2007-06-20 12:32:41Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) Authors contributing to this file. |
---|
4 | |
---|
5 | This file is part of BASE - BioArray Software Environment. |
---|
6 | Available at http://base.thep.lu.se/ |
---|
7 | |
---|
8 | BASE is free software; you can redistribute it and/or |
---|
9 | modify it under the terms of the GNU General Public License |
---|
10 | as published by the Free Software Foundation; either version 2 |
---|
11 | of the License, or (at your option) any later version. |
---|
12 | |
---|
13 | BASE is distributed in the hope that it will be useful, |
---|
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | GNU General Public License for more details. |
---|
17 | |
---|
18 | You should have received a copy of the GNU General Public License |
---|
19 | along with this program; if not, write to the Free Software |
---|
20 | Foundation, Inc., 59 Temple Place - Suite 330, |
---|
21 | Boston, MA 02111-1307, USA. |
---|
22 | ------------------------------------------------------------------ |
---|
23 | |
---|
24 | @author Nicklas |
---|
25 | @version 2.0 |
---|
26 | --%> |
---|
27 | <%@ page session="false" |
---|
28 | import="net.sf.basedb.core.Application" |
---|
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.Include" |
---|
33 | import="net.sf.basedb.core.RawBioAssay" |
---|
34 | import="net.sf.basedb.core.Affymetrix" |
---|
35 | import="net.sf.basedb.core.Scan" |
---|
36 | import="net.sf.basedb.core.Protocol" |
---|
37 | import="net.sf.basedb.core.Software" |
---|
38 | import="net.sf.basedb.core.ArrayDesign" |
---|
39 | import="net.sf.basedb.core.File" |
---|
40 | import="net.sf.basedb.core.FileType" |
---|
41 | import="net.sf.basedb.core.RawDataType" |
---|
42 | import="net.sf.basedb.core.RawDataTypes" |
---|
43 | import="net.sf.basedb.core.User" |
---|
44 | import="net.sf.basedb.core.Path" |
---|
45 | import="net.sf.basedb.core.ItemQuery" |
---|
46 | import="net.sf.basedb.core.ItemResultIterator" |
---|
47 | import="net.sf.basedb.core.Permission" |
---|
48 | import="net.sf.basedb.core.ItemContext" |
---|
49 | import="net.sf.basedb.core.MultiPermissions" |
---|
50 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
51 | import="net.sf.basedb.core.ItemAlreadyExistsException" |
---|
52 | import="net.sf.basedb.core.PluginDefinition" |
---|
53 | import="net.sf.basedb.core.Job" |
---|
54 | import="net.sf.basedb.core.ProgressReporter" |
---|
55 | import="net.sf.basedb.core.IntegerParameterType" |
---|
56 | import="net.sf.basedb.core.FloatParameterType" |
---|
57 | import="net.sf.basedb.core.StringParameterType" |
---|
58 | import="net.sf.basedb.core.FileParameterType" |
---|
59 | import="net.sf.basedb.core.ItemParameterType" |
---|
60 | import="net.sf.basedb.core.BooleanParameterType" |
---|
61 | import="net.sf.basedb.util.RemovableUtil" |
---|
62 | import="net.sf.basedb.util.ShareableUtil" |
---|
63 | import="net.sf.basedb.util.OwnableUtil" |
---|
64 | import="net.sf.basedb.clients.web.Base" |
---|
65 | import="net.sf.basedb.clients.web.WebException" |
---|
66 | import="net.sf.basedb.util.Values" |
---|
67 | import="net.sf.basedb.clients.web.util.HTML" |
---|
68 | import="java.util.Enumeration" |
---|
69 | import="java.util.Set" |
---|
70 | import="java.util.HashSet" |
---|
71 | import="java.util.List" |
---|
72 | import="java.util.ArrayList" |
---|
73 | import="java.util.Arrays" |
---|
74 | import="java.util.Collections" |
---|
75 | %> |
---|
76 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
77 | <%! |
---|
78 | private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,rawDataType,spots,description"); |
---|
79 | private static final Item itemType = Item.RAWBIOASSAY; |
---|
80 | |
---|
81 | private static class UpdateArrayDesign |
---|
82 | implements Runnable |
---|
83 | { |
---|
84 | private final int jobId; |
---|
85 | private final int rawBioAssayId; |
---|
86 | private final int arrayDesignId; |
---|
87 | private final SessionControl sc; |
---|
88 | |
---|
89 | private UpdateArrayDesign(Job job, RawBioAssay rba, ArrayDesign design) |
---|
90 | { |
---|
91 | this.jobId = job.getId(); |
---|
92 | this.rawBioAssayId = rba.getId(); |
---|
93 | this.arrayDesignId = design.getId(); |
---|
94 | this.sc = job.getSessionControl(); |
---|
95 | } |
---|
96 | |
---|
97 | public void run() |
---|
98 | { |
---|
99 | DbControl dc = sc.newDbControl(); |
---|
100 | try |
---|
101 | { |
---|
102 | Job j = Job.getById(dc, jobId); |
---|
103 | j.start("Initialising...", Application.getHostName()); |
---|
104 | dc.commit(); |
---|
105 | dc = sc.newDbControl(); |
---|
106 | RawBioAssay rba = RawBioAssay.getById(dc, rawBioAssayId); |
---|
107 | ArrayDesign design = ArrayDesign.getById(dc, arrayDesignId); |
---|
108 | ProgressReporter progress = j.getProgressReporter(null); |
---|
109 | try |
---|
110 | { |
---|
111 | rba.updateArrayDesign(design, progress); |
---|
112 | progress.display(99, "Committing changes to database..."); |
---|
113 | dc.commit(); |
---|
114 | dc = sc.newDbControl(); |
---|
115 | j = Job.getById(dc, jobId); |
---|
116 | j.doneOk("Array design updated successfully"); |
---|
117 | j.setRemoved(true); |
---|
118 | dc.commit(); |
---|
119 | } |
---|
120 | catch (Throwable t) |
---|
121 | { |
---|
122 | dc = sc.newDbControl(); |
---|
123 | j = Job.getById(dc, jobId); |
---|
124 | j.doneError(t.getMessage(), Arrays.asList(t)); |
---|
125 | j.setRemoved(true); |
---|
126 | dc.commit(); |
---|
127 | } |
---|
128 | } |
---|
129 | finally |
---|
130 | { |
---|
131 | if (dc != null) dc.close(); |
---|
132 | } |
---|
133 | } |
---|
134 | } |
---|
135 | %> |
---|
136 | <% |
---|
137 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
138 | final String ID = sc.getId(); |
---|
139 | final String cmd = request.getParameter("cmd"); |
---|
140 | final String root = request.getContextPath()+"/"; |
---|
141 | final String mode = request.getParameter("mode"); |
---|
142 | final String callback = request.getParameter("callback"); |
---|
143 | final String itemId = request.getParameter("item_id"); |
---|
144 | final String listPage = "list_rawbioassays.jsp?ID="+ID |
---|
145 | +(mode == null ? "" : "&mode="+mode) |
---|
146 | +(callback == null ? "" : "&callback="+callback) |
---|
147 | +(itemId == null ? "" : "&item_id="+itemId); |
---|
148 | final String viewPage = "view_rawbioassay.jsp?ID="+ID; |
---|
149 | final String editPage = "edit_rawbioassay.jsp?ID="+ID; |
---|
150 | |
---|
151 | String forward = null; |
---|
152 | String redirect = null; |
---|
153 | String message = null; |
---|
154 | DbControl dc = null; |
---|
155 | |
---|
156 | try |
---|
157 | { |
---|
158 | if (cmd == null || "List".equals(cmd)) |
---|
159 | { |
---|
160 | // Display the list page without updatinging the current context |
---|
161 | Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true); |
---|
162 | redirect = listPage; |
---|
163 | } |
---|
164 | else if ("UpdateContext".equals(cmd)) |
---|
165 | { |
---|
166 | // Display the list page after updating the current context from the request parameters |
---|
167 | Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
168 | redirect = listPage; |
---|
169 | } |
---|
170 | else if ("LoadContext".equals(cmd)) |
---|
171 | { |
---|
172 | // Display the list page after loading a saved context |
---|
173 | int contextId = Values.getInt(request.getParameter("context")); |
---|
174 | Base.loadContext(sc, contextId, defaultContext); |
---|
175 | redirect = listPage; |
---|
176 | } |
---|
177 | |
---|
178 | else if ("ViewItem".equals(cmd)) |
---|
179 | { |
---|
180 | // Display the view page for a single item |
---|
181 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
182 | forward = viewPage; |
---|
183 | } |
---|
184 | else if ("EditItem".equals(cmd)) |
---|
185 | { |
---|
186 | // Display the edit page for a single item (should be opened in a popup) |
---|
187 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
188 | redirect = editPage; |
---|
189 | } |
---|
190 | else if ("EditSpotImages".equals(cmd)) |
---|
191 | { |
---|
192 | // Display the spot images edit page for a single item (should be opened in a popup) |
---|
193 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
194 | redirect = "edit_spotimages.jsp?ID="+ID; |
---|
195 | } |
---|
196 | else if ("NewItem".equals(cmd)) |
---|
197 | { |
---|
198 | // Display the edit page for a new item (should be opened in a popup) |
---|
199 | if (!sc.hasPermission(Permission.CREATE, itemType)) |
---|
200 | { |
---|
201 | throw new PermissionDeniedException(Permission.CREATE, itemType.toString()); |
---|
202 | } |
---|
203 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
204 | cc.setId(0); |
---|
205 | forward = editPage; |
---|
206 | } |
---|
207 | else if ("UpdateItem".equals(cmd)) |
---|
208 | { |
---|
209 | // Update the properties on an item (will close the popup) |
---|
210 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext); |
---|
211 | final int maxRecent = Base.getMaxRecent(sc); |
---|
212 | dc = sc.newDbControl(); |
---|
213 | RawBioAssay rba = (RawBioAssay)cc.getObject("item"); |
---|
214 | RawDataType rdt = RawDataTypes.getRawDataType(Values.getStringOrNull(request.getParameter("rawdatatype"))); |
---|
215 | if (rdt != null) cc.setRecent("RawDataType", rdt.getId(), maxRecent); |
---|
216 | |
---|
217 | if (rba == null) |
---|
218 | { |
---|
219 | rba = RawBioAssay.getNew(dc, rdt); |
---|
220 | message = "Raw bioassay created"; |
---|
221 | dc.saveItem(rba); |
---|
222 | } |
---|
223 | else |
---|
224 | { |
---|
225 | if (rdt != null) rba.setRawDataType(rdt); |
---|
226 | dc.reattachItem(rba); |
---|
227 | message = "Raw bioassay updated"; |
---|
228 | } |
---|
229 | rba.setName(Values.getStringOrNull(request.getParameter("name"))); |
---|
230 | rba.setDescription(Values.getStringOrNull(request.getParameter("description"))); |
---|
231 | int protocolId = Values.getInt(request.getParameter("protocol_id"), -1); |
---|
232 | if (protocolId >= 0) // < 0 = denied or unchanged |
---|
233 | { |
---|
234 | Protocol pt = protocolId == 0 ? null : Protocol.getById(dc, protocolId); |
---|
235 | rba.setProtocol(pt); |
---|
236 | if (pt != null) cc.setRecent(pt, maxRecent); |
---|
237 | } |
---|
238 | int softwareId = Values.getInt(request.getParameter("software_id"), -1); |
---|
239 | if (softwareId >= 0) // < 0 = denied or unchanged |
---|
240 | { |
---|
241 | Software sw = softwareId == 0 ? null : Software.getById(dc, softwareId); |
---|
242 | rba.setSoftware(sw); |
---|
243 | if (sw != null) cc.setRecent(sw, maxRecent); |
---|
244 | } |
---|
245 | int scanId = Values.getInt(request.getParameter("scan_id"), -1); |
---|
246 | if (scanId >= 0) // < 0 = denied or unchanged |
---|
247 | { |
---|
248 | Scan scan = scanId == 0 ? null : Scan.getById(dc, scanId); |
---|
249 | rba.setScan(scan); |
---|
250 | if (scan != null) cc.setRecent(scan, maxRecent); |
---|
251 | } |
---|
252 | Job job = null; |
---|
253 | ArrayDesign ad = null; |
---|
254 | int arrayDesignId = Values.getInt(request.getParameter("arraydesign_id"), -1); |
---|
255 | if (arrayDesignId >= 0) // < 0 = denied or unchanged |
---|
256 | { |
---|
257 | ad = arrayDesignId == 0 ? null : ArrayDesign.getById(dc, arrayDesignId); |
---|
258 | if (rba.getSpots() > 0) |
---|
259 | { |
---|
260 | if (rba.getRawDataType().isStoredInDb() && ad != null && ad.hasFeatures()) |
---|
261 | { |
---|
262 | // Create job and assign it to another thread |
---|
263 | job = Job.getNew(dc, null, null); |
---|
264 | job.setName("Validating array design on " + rba.getName()); |
---|
265 | job.setPrepared(Application.getHostName()); |
---|
266 | dc.saveItem(job); |
---|
267 | } |
---|
268 | else |
---|
269 | { |
---|
270 | rba.updateArrayDesign(ad, null); |
---|
271 | } |
---|
272 | } |
---|
273 | else |
---|
274 | { |
---|
275 | rba.setArrayDesign(ad); |
---|
276 | } |
---|
277 | if (ad != null) cc.setRecent(ad, maxRecent); |
---|
278 | } |
---|
279 | rdt = rba.getRawDataType(); |
---|
280 | if (rdt.isAffymetrix()) |
---|
281 | { |
---|
282 | int celFileId = Values.getInt(request.getParameter("celfile_id"), -1); |
---|
283 | if (celFileId >= 0) // < 0 = denied or unchanged |
---|
284 | { |
---|
285 | File celFile = celFileId == 0 ? null : File.getById(dc, celFileId); |
---|
286 | Affymetrix.setCelFile(rba, celFile); |
---|
287 | } |
---|
288 | } |
---|
289 | |
---|
290 | // Annotations tab |
---|
291 | Base.updateAnnotations(dc, rba, rba, request); |
---|
292 | dc.commit(); |
---|
293 | cc.removeObject("item"); |
---|
294 | if (job != null) |
---|
295 | { |
---|
296 | redirect = "../jobs/index.jsp?ID="+ID+"&cmd=ViewItem&item_id="+job.getId(); |
---|
297 | Thread updateThread = new Thread(new UpdateArrayDesign(job, rba, ad)); |
---|
298 | updateThread.setPriority(Thread.currentThread().getPriority() - 1); |
---|
299 | updateThread.start(); |
---|
300 | } |
---|
301 | } |
---|
302 | else if ("DeleteItem".equals(cmd)) |
---|
303 | { |
---|
304 | // Delete a single item and then return to the view page |
---|
305 | dc = sc.newDbControl(); |
---|
306 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
307 | RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), true); |
---|
308 | dc.commit(); |
---|
309 | redirect = viewPage; |
---|
310 | } |
---|
311 | else if ("DeleteItems".equals(cmd)) |
---|
312 | { |
---|
313 | // Delete all selected items on the list page |
---|
314 | dc = sc.newDbControl(); |
---|
315 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
316 | int numTotal = cc.getSelected().size(); |
---|
317 | int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), true); |
---|
318 | dc.commit(); |
---|
319 | if (numTotal != numRemoved) |
---|
320 | { |
---|
321 | message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be deleted, because you have no DELETE permission"; |
---|
322 | } |
---|
323 | redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : ""); |
---|
324 | } |
---|
325 | else if ("RestoreItem".equals(cmd)) |
---|
326 | { |
---|
327 | // Restore a single item and then return to the view page |
---|
328 | dc = sc.newDbControl(); |
---|
329 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
330 | RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), false); |
---|
331 | dc.commit(); |
---|
332 | redirect = viewPage; |
---|
333 | } |
---|
334 | else if ("RestoreItems".equals(cmd)) |
---|
335 | { |
---|
336 | // Restore all selected items on the list page |
---|
337 | dc = sc.newDbControl(); |
---|
338 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
339 | int numTotal = cc.getSelected().size(); |
---|
340 | int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), false); |
---|
341 | dc.commit(); |
---|
342 | if (numTotal != numRemoved) |
---|
343 | { |
---|
344 | message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be restored, because you have no WRITE permission"; |
---|
345 | } |
---|
346 | redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : ""); |
---|
347 | } |
---|
348 | else if ("ShareItem".equals(cmd)) |
---|
349 | { |
---|
350 | // Display a popup window for sharing a single item |
---|
351 | dc = sc.newDbControl(); |
---|
352 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
353 | MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, Collections.singleton(cc.getId())); |
---|
354 | dc.close(); |
---|
355 | cc.setObject("MultiPermissions", permissions); |
---|
356 | redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name(); |
---|
357 | } |
---|
358 | else if ("ShareItems".equals(cmd)) |
---|
359 | { |
---|
360 | // Display a popup window for sharing all selected items on the list page |
---|
361 | dc = sc.newDbControl(); |
---|
362 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
363 | MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, cc.getSelected()); |
---|
364 | dc.close(); |
---|
365 | cc.setObject("MultiPermissions", permissions); |
---|
366 | redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name(); |
---|
367 | } |
---|
368 | else if ("TakeOwnershipOfItem".equals(cmd)) |
---|
369 | { |
---|
370 | // Take ownership a single item and then return to the view page |
---|
371 | dc = sc.newDbControl(); |
---|
372 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
373 | OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null); |
---|
374 | dc.commit(); |
---|
375 | redirect = viewPage; |
---|
376 | } |
---|
377 | else if ("TakeOwnershipOfItems".equals(cmd)) |
---|
378 | { |
---|
379 | // Take ownership all selected items on the list page |
---|
380 | dc = sc.newDbControl(); |
---|
381 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
382 | int numTotal = cc.getSelected().size(); |
---|
383 | int numOwned = OwnableUtil.setOwner(dc, itemType, cc.getSelected(), null); |
---|
384 | dc.commit(); |
---|
385 | if (numTotal != numOwned) |
---|
386 | { |
---|
387 | message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission"; |
---|
388 | } |
---|
389 | redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : ""); |
---|
390 | } |
---|
391 | else if ("ExportItems".equals(cmd)) |
---|
392 | { |
---|
393 | // Run an export plugin in a list context |
---|
394 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
395 | final ItemQuery<RawBioAssay> query = RawBioAssay.getQuery(); |
---|
396 | cc.configureQuery(query, true); |
---|
397 | cc.setQuery(query); |
---|
398 | redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+raw+bioassays"; |
---|
399 | } |
---|
400 | else if ("ExportItem".equals(cmd)) |
---|
401 | { |
---|
402 | // Run an export plugin in single-item context |
---|
403 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
404 | redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+raw+bioassay"; |
---|
405 | } |
---|
406 | else if ("ImportItems".equals(cmd)) |
---|
407 | { |
---|
408 | // Run an import plugin in a list context |
---|
409 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
410 | final ItemQuery<RawBioAssay> query = RawBioAssay.getQuery(); |
---|
411 | cc.configureQuery(query, true); |
---|
412 | cc.setQuery(query); |
---|
413 | redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Import+raw+bioassays"; |
---|
414 | } |
---|
415 | else if ("ImportItem".equals(cmd)) |
---|
416 | { |
---|
417 | // Run an import plugin in single-item context |
---|
418 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
419 | // Set file type filter |
---|
420 | ItemContext fileContext = sc.getCurrentContext(Item.FILE); |
---|
421 | fileContext.setPropertyFilter(FileType.getPropertyFilter(FileType.RAW_DATA)); |
---|
422 | redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Import+raw+bioassay"; |
---|
423 | } |
---|
424 | else if ("RunListPlugin".equals(cmd)) |
---|
425 | { |
---|
426 | // Run another plugin in a list context |
---|
427 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
428 | final ItemQuery<RawBioAssay> query = RawBioAssay.getQuery(); |
---|
429 | cc.configureQuery(query, true); |
---|
430 | cc.setQuery(query); |
---|
431 | redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&main_type=OTHER&title=Run+plugin"; |
---|
432 | } |
---|
433 | else if ("RunPlugin".equals(cmd)) |
---|
434 | { |
---|
435 | // Run another plugin in single-item context |
---|
436 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
437 | redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=OTHER&title=Run+plugin"; |
---|
438 | } |
---|
439 | else if ("CreateSpotImages".equals(cmd)) |
---|
440 | { |
---|
441 | dc = sc.newDbControl(); |
---|
442 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
443 | RawBioAssay rba = RawBioAssay.getById(dc, cc.getId()); |
---|
444 | |
---|
445 | int redFileId = Values.getInt(request.getParameter("redfile_id")); |
---|
446 | File red = redFileId == 0 ? null : File.getById(dc, redFileId); |
---|
447 | int greenFileId = Values.getInt(request.getParameter("greenfile_id")); |
---|
448 | File green = greenFileId == 0 ? null : File.getById(dc, greenFileId); |
---|
449 | int blueFileId = Values.getInt(request.getParameter("bluefile_id")); |
---|
450 | File blue = blueFileId == 0 ? null : File.getById(dc, blueFileId); |
---|
451 | |
---|
452 | String path = Values.getStringOrNull(request.getParameter("path")); |
---|
453 | if (path.startsWith("~/")) |
---|
454 | { |
---|
455 | User user = User.getById(dc, sc.getLoggedInUserId()); |
---|
456 | path = "~"+user.getLogin()+path.substring(1); |
---|
457 | } |
---|
458 | Path p = new Path(path, Path.Type.FILE); |
---|
459 | File saveAs = File.getByPath(dc, p, true); |
---|
460 | if (saveAs.isInDatabase() && !Values.getBoolean(request.getParameter("overwrite"))) |
---|
461 | { |
---|
462 | throw new ItemAlreadyExistsException("File[path="+path+"]"); |
---|
463 | } |
---|
464 | |
---|
465 | IntegerParameterType integerParameter = new IntegerParameterType(); |
---|
466 | FloatParameterType floatParameter = new FloatParameterType(); |
---|
467 | FileParameterType fileParameter = new FileParameterType(); |
---|
468 | ItemParameterType<RawBioAssay> itemParameter = new ItemParameterType(RawBioAssay.class, null); |
---|
469 | StringParameterType stringParameter = new StringParameterType(); |
---|
470 | BooleanParameterType booleanParameter = new BooleanParameterType(); |
---|
471 | |
---|
472 | PluginDefinition plugin = PluginDefinition.getByClassName(dc, "net.sf.basedb.plugins.SpotImageCreator"); |
---|
473 | Job job = Job.getNew(dc, plugin, null); |
---|
474 | job.setName("Create spot images for raw bioassay: " + rba.getName()); |
---|
475 | job.setParameterValue("rawBioAssay", "Raw bioassay", |
---|
476 | "The raw bioassay to create spot images for", itemParameter, rba); |
---|
477 | job.setParameterValue("xScale", "X scale factor", |
---|
478 | "The raw data X value will be divided by this value to get the pixel coordinate", |
---|
479 | integerParameter, Values.getInt(request.getParameter("x_scale"))); |
---|
480 | job.setParameterValue("yScale", "Y scale factor", |
---|
481 | "The raw data Y value will be divided by this value to get the pixel coordinate", |
---|
482 | integerParameter, Values.getInt(request.getParameter("y_scale"))); |
---|
483 | job.setParameterValue("xOffset", "X offset value", |
---|
484 | "The offset is subtracted from the raw data X value", |
---|
485 | integerParameter, Values.getInt(request.getParameter("x_offset"))); |
---|
486 | job.setParameterValue("yOffset", "Y offset value", |
---|
487 | "The offset is subtracted from the raw data Y value", |
---|
488 | integerParameter, Values.getInt(request.getParameter("y_offset"))); |
---|
489 | job.setParameterValue("spotsize", "Spot size", "The size of each spot in pixels", |
---|
490 | integerParameter, Values.getInt(request.getParameter("spotsize"))); |
---|
491 | job.setParameterValue("gamma", "Gamma", "Gamma correction for display", |
---|
492 | floatParameter, Values.getFloat(request.getParameter("gamma"))); |
---|
493 | job.setParameterValue("quality", "Quality", |
---|
494 | "The quality is a number between 0.0 and 1.0, with 1.0 indicating highest quality.", |
---|
495 | floatParameter, Values.getFloat(request.getParameter("quality"))); |
---|
496 | job.setParameterValue("redFile", "Red image", |
---|
497 | "The file containing the image to use for the red part", fileParameter, red); |
---|
498 | job.setParameterValue("greenFile", "Green image", |
---|
499 | "The file containing the image to use for the green part", fileParameter, green); |
---|
500 | job.setParameterValue("blueFile", "Blue image", |
---|
501 | "The file containing the image to use for the red part", fileParameter, blue); |
---|
502 | job.setParameterValue("path", "Save as", |
---|
503 | "The file name where the spot images should be saved", stringParameter, path); |
---|
504 | job.setParameterValue("overwrite", "Overwrite", |
---|
505 | "If an existing file should be overwritten or not", booleanParameter, Values.getBoolean(request.getParameter("overwrite"))); |
---|
506 | |
---|
507 | dc.saveItem(job); |
---|
508 | dc.commit(); |
---|
509 | |
---|
510 | redirect = "../jobs/index.jsp?ID="+ID+"&cmd=ViewItem&item_id="+job.getId(); |
---|
511 | } |
---|
512 | else |
---|
513 | { |
---|
514 | throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
---|
515 | } |
---|
516 | |
---|
517 | |
---|
518 | /* |
---|
519 | else if ("ImportRawData".equals(cmd)) |
---|
520 | { |
---|
521 | RawBioAssay rba = (RawBioAssay)sc.getSessionSetting(itemType.name()+".item"); |
---|
522 | ItemContext context = sc.getCurrentContext(itemType); |
---|
523 | context.setId(rba.getId()); |
---|
524 | redirect = "../../common/import/configure.jsp?ID="+ID+"&item_type="+itemType.name()+"&context_type=ITEM&title=Import+raw+data+for+"+HTML.urlEncode(rba.getName()); |
---|
525 | |
---|
526 | } |
---|
527 | */ |
---|
528 | } |
---|
529 | finally |
---|
530 | { |
---|
531 | if (dc != null) dc.close(); |
---|
532 | } |
---|
533 | |
---|
534 | if (forward != null) |
---|
535 | { |
---|
536 | pageContext.forward(forward); |
---|
537 | } |
---|
538 | else if (redirect != null) |
---|
539 | { |
---|
540 | response.sendRedirect(redirect); |
---|
541 | } |
---|
542 | else if (message == null) |
---|
543 | { |
---|
544 | response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
---|
545 | } |
---|
546 | else |
---|
547 | { |
---|
548 | response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
---|
549 | } |
---|
550 | %> |
---|
551 | |
---|