4573 |
10 Oct 08 |
martin |
1 |
<%-- $Id$ |
4573 |
10 Oct 08 |
martin |
2 |
------------------------------------------------------------------ |
4573 |
10 Oct 08 |
martin |
Copyright (C) 2008 Martin Svensson |
4573 |
10 Oct 08 |
martin |
4 |
|
4573 |
10 Oct 08 |
martin |
5 |
This file is part of BASE - BioArray Software Environment. |
4573 |
10 Oct 08 |
martin |
6 |
Available at http://base.thep.lu.se/ |
4573 |
10 Oct 08 |
martin |
7 |
|
4573 |
10 Oct 08 |
martin |
8 |
BASE is free software; you can redistribute it and/or |
4573 |
10 Oct 08 |
martin |
9 |
modify it under the terms of the GNU General Public License |
4573 |
10 Oct 08 |
martin |
10 |
as published by the Free Software Foundation; either version 3 |
4573 |
10 Oct 08 |
martin |
11 |
of the License, or (at your option) any later version. |
4573 |
10 Oct 08 |
martin |
12 |
|
4573 |
10 Oct 08 |
martin |
13 |
BASE is distributed in the hope that it will be useful, |
4573 |
10 Oct 08 |
martin |
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
4573 |
10 Oct 08 |
martin |
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4573 |
10 Oct 08 |
martin |
16 |
GNU General Public License for more details. |
4573 |
10 Oct 08 |
martin |
17 |
|
4573 |
10 Oct 08 |
martin |
18 |
You should have received a copy of the GNU General Public License |
4573 |
10 Oct 08 |
martin |
19 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
4573 |
10 Oct 08 |
martin |
20 |
------------------------------------------------------------------ |
4573 |
10 Oct 08 |
martin |
21 |
|
4573 |
10 Oct 08 |
martin |
22 |
Configure the order and visibility of columns in a table of items. |
4573 |
10 Oct 08 |
martin |
23 |
This page will use the TableColumn.getTableColumns(item) to retreive the |
4573 |
10 Oct 08 |
martin |
24 |
list of all available columns for that item type and |
4573 |
10 Oct 08 |
martin |
25 |
getSession().getSetting(item+".columns") to retreive a comma-separated |
4573 |
10 Oct 08 |
martin |
26 |
list of the current order of visible columns. |
4573 |
10 Oct 08 |
martin |
27 |
|
4573 |
10 Oct 08 |
martin |
28 |
@author Martin |
4573 |
10 Oct 08 |
martin |
29 |
@version 2.9 |
4573 |
10 Oct 08 |
martin |
30 |
--%> |
5426 |
24 Sep 10 |
nicklas |
31 |
<%@ page pageEncoding="UTF-8" session="false" |
4573 |
10 Oct 08 |
martin |
32 |
import="net.sf.basedb.core.DbControl" |
4573 |
10 Oct 08 |
martin |
33 |
import="net.sf.basedb.core.Item" |
4573 |
10 Oct 08 |
martin |
34 |
import="net.sf.basedb.core.ItemContext" |
4587 |
15 Oct 08 |
martin |
35 |
import="net.sf.basedb.core.OwnedItem" |
4573 |
10 Oct 08 |
martin |
36 |
import="net.sf.basedb.core.SessionControl" |
4573 |
10 Oct 08 |
martin |
37 |
import="net.sf.basedb.core.User" |
4573 |
10 Oct 08 |
martin |
38 |
import="net.sf.basedb.clients.web.Base" |
4573 |
10 Oct 08 |
martin |
39 |
import="net.sf.basedb.clients.web.util.HTML" |
4573 |
10 Oct 08 |
martin |
40 |
import="net.sf.basedb.clients.web.WebException" |
4573 |
10 Oct 08 |
martin |
41 |
import="net.sf.basedb.util.OwnableUtil" |
4573 |
10 Oct 08 |
martin |
42 |
import="net.sf.basedb.util.Values" |
4573 |
10 Oct 08 |
martin |
43 |
import="java.util.Collections" |
4573 |
10 Oct 08 |
martin |
44 |
import="java.util.Set" |
4573 |
10 Oct 08 |
martin |
45 |
%> |
4573 |
10 Oct 08 |
martin |
46 |
<% |
4573 |
10 Oct 08 |
martin |
47 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
4573 |
10 Oct 08 |
martin |
48 |
final String ID = sc.getId(); |
4573 |
10 Oct 08 |
martin |
49 |
final Item itemType = Item.valueOf(request.getParameter("item_type")); |
4573 |
10 Oct 08 |
martin |
50 |
final String subContext = Values.getString(request.getParameter("subcontext"), ""); |
4573 |
10 Oct 08 |
martin |
51 |
final String cmd = request.getParameter("cmd"); |
4573 |
10 Oct 08 |
martin |
52 |
final String root = request.getContextPath()+"/"; |
4573 |
10 Oct 08 |
martin |
53 |
final ItemContext cc = sc.getCurrentContext(itemType, subContext); |
4573 |
10 Oct 08 |
martin |
54 |
final int maxRecent = Base.getMaxRecent(sc); |
4573 |
10 Oct 08 |
martin |
55 |
|
4573 |
10 Oct 08 |
martin |
56 |
String message = null; |
7954 |
12 May 21 |
nicklas |
57 |
final DbControl dc = sc.newDbControl(":Update owner"); |
4573 |
10 Oct 08 |
martin |
58 |
try |
4573 |
10 Oct 08 |
martin |
59 |
{ |
4573 |
10 Oct 08 |
martin |
60 |
if ("Save".equals(cmd)) |
4573 |
10 Oct 08 |
martin |
61 |
{ |
7605 |
26 Feb 19 |
nicklas |
62 |
Set<OwnedItem> items = cc.getObject("OwnedItems"); |
4573 |
10 Oct 08 |
martin |
63 |
User newOwner = User.getById(dc, Values.getInt(request.getParameter("owner_id"))); |
7703 |
11 Apr 19 |
nicklas |
64 |
cc.setRecent(Item.USER, newOwner, maxRecent); |
4573 |
10 Oct 08 |
martin |
65 |
int numTotal = items.size(); |
4587 |
15 Oct 08 |
martin |
66 |
int numChanged = OwnableUtil.setOwner(dc, items, newOwner); |
4573 |
10 Oct 08 |
martin |
67 |
dc.commit(); |
4573 |
10 Oct 08 |
martin |
68 |
cc.removeObject("OwnedItems"); |
4573 |
10 Oct 08 |
martin |
69 |
if (numTotal != numChanged) |
4573 |
10 Oct 08 |
martin |
70 |
{ |
4573 |
10 Oct 08 |
martin |
71 |
message = (numChanged == 0 ? "No" : "Only "+numChanged+" of "+numTotal) + " items got their owner changed, because you have no SET_OWNER permission"; |
4573 |
10 Oct 08 |
martin |
72 |
} |
4573 |
10 Oct 08 |
martin |
73 |
} |
4573 |
10 Oct 08 |
martin |
74 |
else |
4573 |
10 Oct 08 |
martin |
75 |
{ |
4573 |
10 Oct 08 |
martin |
76 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
4573 |
10 Oct 08 |
martin |
77 |
} |
4573 |
10 Oct 08 |
martin |
78 |
} |
4573 |
10 Oct 08 |
martin |
79 |
finally |
4573 |
10 Oct 08 |
martin |
80 |
{ |
4573 |
10 Oct 08 |
martin |
81 |
if (dc != null) dc.close(); |
4573 |
10 Oct 08 |
martin |
82 |
} |
4573 |
10 Oct 08 |
martin |
83 |
if (message == null) |
4573 |
10 Oct 08 |
martin |
84 |
{ |
4573 |
10 Oct 08 |
martin |
85 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
4573 |
10 Oct 08 |
martin |
86 |
} |
4573 |
10 Oct 08 |
martin |
87 |
else |
4573 |
10 Oct 08 |
martin |
88 |
{ |
4573 |
10 Oct 08 |
martin |
89 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
4573 |
10 Oct 08 |
martin |
90 |
} |
4573 |
10 Oct 08 |
martin |
91 |
%> |