1 | <%-- $Id: index.jsp 4864 2009-03-30 07:18:50Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2009 Nicklas Nordborg |
---|
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 3 |
---|
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 BASE. If not, see <http://www.gnu.org/licenses/>. |
---|
20 | ------------------------------------------------------------------ |
---|
21 | --%> |
---|
22 | <%@ page session="false" |
---|
23 | import="net.sf.basedb.core.SessionControl" |
---|
24 | import="net.sf.basedb.core.DbControl" |
---|
25 | import="net.sf.basedb.core.Item" |
---|
26 | import="net.sf.basedb.core.BasicItem" |
---|
27 | import="net.sf.basedb.core.Project" |
---|
28 | import="net.sf.basedb.core.ItemContext" |
---|
29 | import="net.sf.basedb.core.Presets" |
---|
30 | import="net.sf.basedb.core.Presets.Preset" |
---|
31 | import="net.sf.basedb.util.overview.GenericOverview" |
---|
32 | import="net.sf.basedb.util.overview.Node" |
---|
33 | import="net.sf.basedb.util.overview.Validator" |
---|
34 | import="net.sf.basedb.util.overview.ValidationOptions" |
---|
35 | import="net.sf.basedb.util.overview.Severity" |
---|
36 | import="net.sf.basedb.clients.web.Base" |
---|
37 | import="net.sf.basedb.clients.web.WebException" |
---|
38 | import="net.sf.basedb.util.Values" |
---|
39 | import="net.sf.basedb.util.overview.OverviewUtil" |
---|
40 | import="net.sf.basedb.clients.web.util.HTML" |
---|
41 | import="java.util.Map" |
---|
42 | import="java.util.List" |
---|
43 | %> |
---|
44 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
45 | <% |
---|
46 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
47 | final String ID = sc.getId(); |
---|
48 | final String cmd = request.getParameter("cmd"); |
---|
49 | final String root = request.getContextPath()+"/"; |
---|
50 | |
---|
51 | String forward = null; |
---|
52 | String redirect = null; |
---|
53 | String message = null; |
---|
54 | DbControl dc = null; |
---|
55 | try |
---|
56 | { |
---|
57 | if (cmd == null || "Overview".equals(cmd)) |
---|
58 | { |
---|
59 | // Display the overview page |
---|
60 | final Item itemType = Item.valueOf(request.getParameter("item_type")); |
---|
61 | final int itemId = Values.getInt(request.getParameter("item_id")); |
---|
62 | dc = sc.newDbControl(); |
---|
63 | BasicItem item = itemType.getById(dc, itemId); |
---|
64 | Project project = sc.getActiveProjectId() == 0 ? |
---|
65 | null : Project.getById(dc, sc.getActiveProjectId()); |
---|
66 | GenericOverview overview = OverviewUtil.getNewOrCurrentOverview(dc, item, project); |
---|
67 | overview.getNodeValidatorFactory().setDisabled(true); |
---|
68 | overview.expand(dc, overview.getRootNode(), false); |
---|
69 | dc.close(); |
---|
70 | redirect = "frameset.jsp?ID="+ID+"&show_failures="+false; |
---|
71 | } |
---|
72 | else if ("Validate".equals(cmd)) |
---|
73 | { |
---|
74 | final Item itemType = Item.valueOf(request.getParameter("item_type")); |
---|
75 | final int itemId = Values.getInt(request.getParameter("item_id")); |
---|
76 | dc = sc.newDbControl(); |
---|
77 | BasicItem item = itemType.getById(dc, itemId); |
---|
78 | Project project = sc.getActiveProjectId() == 0 ? |
---|
79 | null : Project.getById(dc, sc.getActiveProjectId()); |
---|
80 | GenericOverview overview = OverviewUtil.getNewOverview(dc, item, project); |
---|
81 | overview.expand(dc, overview.getRootNode(), true); |
---|
82 | overview.updateFailureCountOnNodes(); |
---|
83 | dc.close(); |
---|
84 | redirect = "frameset.jsp?ID="+ID+"&item_type="+itemType.name()+"&item_id="+itemId+"&show_failures="+true; |
---|
85 | } |
---|
86 | else if ("SaveValidationOptions".equals(cmd)) |
---|
87 | { |
---|
88 | GenericOverview overview = OverviewUtil.getCurrentOverview(sc); |
---|
89 | ValidationOptions options = overview.getValidationOptions(); |
---|
90 | Presets presets = OverviewUtil.getValidationPresets(sc); |
---|
91 | for (Map.Entry<String, List<Validator>> entry : OverviewUtil.getValidators().entrySet()) |
---|
92 | { |
---|
93 | for (Validator validator : entry.getValue()) |
---|
94 | { |
---|
95 | options.setSeverity(validator, Severity.valueOf(request.getParameter(validator.getId()))); |
---|
96 | } |
---|
97 | } |
---|
98 | options.saveToPreset(presets.getDefault()); |
---|
99 | OverviewUtil.saveValidationPresets(sc); |
---|
100 | overview.updateFailureCountOnNodes(); |
---|
101 | } |
---|
102 | else if ("SaveAsPreset".equals(cmd)) |
---|
103 | { |
---|
104 | Presets presets = OverviewUtil.getValidationPresets(sc); |
---|
105 | String name = request.getParameter("presetName"); |
---|
106 | Preset preset = presets.getPreset(name); |
---|
107 | for (Map.Entry<String, List<Validator>> entry : OverviewUtil.getValidators().entrySet()) |
---|
108 | { |
---|
109 | for (Validator validator : entry.getValue()) |
---|
110 | { |
---|
111 | preset.setSetting(validator.getId(), request.getParameter(validator.getId())); |
---|
112 | } |
---|
113 | } |
---|
114 | OverviewUtil.saveValidationPresets(sc); |
---|
115 | forward = "options.jsp"; |
---|
116 | } |
---|
117 | else if ("RemovePreset".equals(cmd)) |
---|
118 | { |
---|
119 | Presets presets = OverviewUtil.getValidationPresets(sc); |
---|
120 | String name = request.getParameter("presetName"); |
---|
121 | presets.deletePreset(name); |
---|
122 | OverviewUtil.saveValidationPresets(sc); |
---|
123 | redirect = "options.jsp?ID=" + ID; |
---|
124 | } |
---|
125 | else |
---|
126 | { |
---|
127 | throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
---|
128 | } |
---|
129 | } |
---|
130 | finally |
---|
131 | { |
---|
132 | if (dc != null) dc.close(); |
---|
133 | } |
---|
134 | |
---|
135 | if (forward != null) |
---|
136 | { |
---|
137 | pageContext.forward(forward); |
---|
138 | } |
---|
139 | else if (redirect != null) |
---|
140 | { |
---|
141 | response.sendRedirect(redirect); |
---|
142 | } |
---|
143 | else if (message == null) |
---|
144 | { |
---|
145 | response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
---|
146 | } |
---|
147 | else |
---|
148 | { |
---|
149 | response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
---|
150 | } |
---|
151 | %> |
---|
152 | |
---|