4745 |
10 Feb 09 |
nicklas |
1 |
<%-- $Id$ |
4745 |
10 Feb 09 |
nicklas |
2 |
------------------------------------------------------------------ |
4745 |
10 Feb 09 |
nicklas |
Copyright (C) 2009 Nicklas Nordborg |
4745 |
10 Feb 09 |
nicklas |
4 |
|
4745 |
10 Feb 09 |
nicklas |
5 |
This file is part of BASE - BioArray Software Environment. |
4745 |
10 Feb 09 |
nicklas |
6 |
Available at http://base.thep.lu.se/ |
4745 |
10 Feb 09 |
nicklas |
7 |
|
4745 |
10 Feb 09 |
nicklas |
8 |
BASE is free software; you can redistribute it and/or |
4745 |
10 Feb 09 |
nicklas |
9 |
modify it under the terms of the GNU General Public License |
4745 |
10 Feb 09 |
nicklas |
10 |
as published by the Free Software Foundation; either version 3 |
4745 |
10 Feb 09 |
nicklas |
11 |
of the License, or (at your option) any later version. |
4745 |
10 Feb 09 |
nicklas |
12 |
|
4745 |
10 Feb 09 |
nicklas |
13 |
BASE is distributed in the hope that it will be useful, |
4745 |
10 Feb 09 |
nicklas |
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
4745 |
10 Feb 09 |
nicklas |
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4745 |
10 Feb 09 |
nicklas |
16 |
GNU General Public License for more details. |
4745 |
10 Feb 09 |
nicklas |
17 |
|
4745 |
10 Feb 09 |
nicklas |
18 |
You should have received a copy of the GNU General Public License |
4745 |
10 Feb 09 |
nicklas |
19 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
4745 |
10 Feb 09 |
nicklas |
20 |
------------------------------------------------------------------ |
4745 |
10 Feb 09 |
nicklas |
21 |
--%> |
5426 |
24 Sep 10 |
nicklas |
22 |
<%@ page pageEncoding="UTF-8" session="false" |
4745 |
10 Feb 09 |
nicklas |
23 |
import="net.sf.basedb.core.SessionControl" |
4745 |
10 Feb 09 |
nicklas |
24 |
import="net.sf.basedb.core.DbControl" |
4745 |
10 Feb 09 |
nicklas |
25 |
import="net.sf.basedb.core.Item" |
4745 |
10 Feb 09 |
nicklas |
26 |
import="net.sf.basedb.core.BasicItem" |
4745 |
10 Feb 09 |
nicklas |
27 |
import="net.sf.basedb.core.Project" |
4745 |
10 Feb 09 |
nicklas |
28 |
import="net.sf.basedb.core.ItemContext" |
4745 |
10 Feb 09 |
nicklas |
29 |
import="net.sf.basedb.core.Presets" |
4745 |
10 Feb 09 |
nicklas |
30 |
import="net.sf.basedb.core.Presets.Preset" |
4745 |
10 Feb 09 |
nicklas |
31 |
import="net.sf.basedb.util.overview.GenericOverview" |
4745 |
10 Feb 09 |
nicklas |
32 |
import="net.sf.basedb.util.overview.Node" |
4745 |
10 Feb 09 |
nicklas |
33 |
import="net.sf.basedb.util.overview.Validator" |
4745 |
10 Feb 09 |
nicklas |
34 |
import="net.sf.basedb.util.overview.ValidationOptions" |
4745 |
10 Feb 09 |
nicklas |
35 |
import="net.sf.basedb.util.overview.Severity" |
6047 |
18 Apr 12 |
nicklas |
36 |
import="net.sf.basedb.util.overview.extensions.ValidationRuleAction" |
4745 |
10 Feb 09 |
nicklas |
37 |
import="net.sf.basedb.clients.web.Base" |
4745 |
10 Feb 09 |
nicklas |
38 |
import="net.sf.basedb.clients.web.WebException" |
4745 |
10 Feb 09 |
nicklas |
39 |
import="net.sf.basedb.util.Values" |
4745 |
10 Feb 09 |
nicklas |
40 |
import="net.sf.basedb.util.overview.OverviewUtil" |
4745 |
10 Feb 09 |
nicklas |
41 |
import="net.sf.basedb.clients.web.util.HTML" |
4745 |
10 Feb 09 |
nicklas |
42 |
import="java.util.Map" |
4745 |
10 Feb 09 |
nicklas |
43 |
import="java.util.List" |
4745 |
10 Feb 09 |
nicklas |
44 |
%> |
4745 |
10 Feb 09 |
nicklas |
45 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
4745 |
10 Feb 09 |
nicklas |
46 |
<% |
4745 |
10 Feb 09 |
nicklas |
47 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
4745 |
10 Feb 09 |
nicklas |
48 |
final String ID = sc.getId(); |
4745 |
10 Feb 09 |
nicklas |
49 |
final String cmd = request.getParameter("cmd"); |
4745 |
10 Feb 09 |
nicklas |
50 |
final String root = request.getContextPath()+"/"; |
4745 |
10 Feb 09 |
nicklas |
51 |
|
4745 |
10 Feb 09 |
nicklas |
52 |
String forward = null; |
4745 |
10 Feb 09 |
nicklas |
53 |
String redirect = null; |
4745 |
10 Feb 09 |
nicklas |
54 |
String message = null; |
4745 |
10 Feb 09 |
nicklas |
55 |
DbControl dc = null; |
4745 |
10 Feb 09 |
nicklas |
56 |
try |
4745 |
10 Feb 09 |
nicklas |
57 |
{ |
4745 |
10 Feb 09 |
nicklas |
58 |
if (cmd == null || "Overview".equals(cmd)) |
4745 |
10 Feb 09 |
nicklas |
59 |
{ |
4745 |
10 Feb 09 |
nicklas |
60 |
// Display the overview page |
4745 |
10 Feb 09 |
nicklas |
61 |
final Item itemType = Item.valueOf(request.getParameter("item_type")); |
4745 |
10 Feb 09 |
nicklas |
62 |
final int itemId = Values.getInt(request.getParameter("item_id")); |
5807 |
14 Oct 11 |
nicklas |
63 |
final boolean forceNew = Values.getBoolean(request.getParameter("forceNew")); |
5807 |
14 Oct 11 |
nicklas |
64 |
|
7954 |
12 May 21 |
nicklas |
65 |
dc = sc.newDbControl(":Item overview"); |
4745 |
10 Feb 09 |
nicklas |
66 |
BasicItem item = itemType.getById(dc, itemId); |
4745 |
10 Feb 09 |
nicklas |
67 |
Project project = sc.getActiveProjectId() == 0 ? |
4745 |
10 Feb 09 |
nicklas |
68 |
null : Project.getById(dc, sc.getActiveProjectId()); |
5807 |
14 Oct 11 |
nicklas |
69 |
GenericOverview overview = forceNew ? |
5807 |
14 Oct 11 |
nicklas |
70 |
OverviewUtil.getNewOverview(dc, item, project) : OverviewUtil.getNewOrCurrentOverview(dc, item, project); |
4864 |
30 Mar 09 |
nicklas |
71 |
overview.getNodeValidatorFactory().setDisabled(true); |
4816 |
16 Mar 09 |
martin |
72 |
overview.expand(dc, overview.getRootNode(), false); |
4745 |
10 Feb 09 |
nicklas |
73 |
dc.close(); |
4840 |
24 Mar 09 |
martin |
74 |
redirect = "frameset.jsp?ID="+ID+"&show_failures="+false; |
4745 |
10 Feb 09 |
nicklas |
75 |
} |
4840 |
24 Mar 09 |
martin |
76 |
else if ("Validate".equals(cmd)) |
4745 |
10 Feb 09 |
nicklas |
77 |
{ |
4745 |
10 Feb 09 |
nicklas |
78 |
final Item itemType = Item.valueOf(request.getParameter("item_type")); |
4745 |
10 Feb 09 |
nicklas |
79 |
final int itemId = Values.getInt(request.getParameter("item_id")); |
7954 |
12 May 21 |
nicklas |
80 |
dc = sc.newDbControl(":Item overview validation"); |
4745 |
10 Feb 09 |
nicklas |
81 |
BasicItem item = itemType.getById(dc, itemId); |
4745 |
10 Feb 09 |
nicklas |
82 |
Project project = sc.getActiveProjectId() == 0 ? |
4745 |
10 Feb 09 |
nicklas |
83 |
null : Project.getById(dc, sc.getActiveProjectId()); |
5807 |
14 Oct 11 |
nicklas |
84 |
GenericOverview overview = OverviewUtil.getNewOverview(dc, item, project); |
4823 |
19 Mar 09 |
martin |
85 |
overview.expand(dc, overview.getRootNode(), true); |
4745 |
10 Feb 09 |
nicklas |
86 |
overview.updateFailureCountOnNodes(); |
4745 |
10 Feb 09 |
nicklas |
87 |
dc.close(); |
4840 |
24 Mar 09 |
martin |
88 |
redirect = "frameset.jsp?ID="+ID+"&item_type="+itemType.name()+"&item_id="+itemId+"&show_failures="+true; |
4745 |
10 Feb 09 |
nicklas |
89 |
} |
4745 |
10 Feb 09 |
nicklas |
90 |
else if ("SaveValidationOptions".equals(cmd)) |
4745 |
10 Feb 09 |
nicklas |
91 |
{ |
7954 |
12 May 21 |
nicklas |
92 |
dc = sc.newDbControl(":Item overview save options"); |
4767 |
17 Feb 09 |
nicklas |
93 |
GenericOverview overview = OverviewUtil.getCurrentOverview(sc); |
4745 |
10 Feb 09 |
nicklas |
94 |
ValidationOptions options = overview.getValidationOptions(); |
4745 |
10 Feb 09 |
nicklas |
95 |
Presets presets = OverviewUtil.getValidationPresets(sc); |
6047 |
18 Apr 12 |
nicklas |
96 |
for (Map.Entry<String, List<ValidationRuleAction>> entry : OverviewUtil.getAllRules(dc, overview).entrySet()) |
4745 |
10 Feb 09 |
nicklas |
97 |
{ |
6047 |
18 Apr 12 |
nicklas |
98 |
for (ValidationRuleAction validator : entry.getValue()) |
4745 |
10 Feb 09 |
nicklas |
99 |
{ |
4745 |
10 Feb 09 |
nicklas |
100 |
options.setSeverity(validator, Severity.valueOf(request.getParameter(validator.getId()))); |
4745 |
10 Feb 09 |
nicklas |
101 |
} |
4745 |
10 Feb 09 |
nicklas |
102 |
} |
7603 |
22 Feb 19 |
nicklas |
103 |
options.setOption((ValidationRuleAction)Validator.NONMATCHING_SPOTCOUNT, "threshold", request.getParameter("threshold")); |
4745 |
10 Feb 09 |
nicklas |
104 |
options.saveToPreset(presets.getDefault()); |
4745 |
10 Feb 09 |
nicklas |
105 |
OverviewUtil.saveValidationPresets(sc); |
4745 |
10 Feb 09 |
nicklas |
106 |
overview.updateFailureCountOnNodes(); |
4745 |
10 Feb 09 |
nicklas |
107 |
} |
4745 |
10 Feb 09 |
nicklas |
108 |
else if ("SaveAsPreset".equals(cmd)) |
4745 |
10 Feb 09 |
nicklas |
109 |
{ |
7954 |
12 May 21 |
nicklas |
110 |
dc = sc.newDbControl(":Item overview save preset"); |
6047 |
18 Apr 12 |
nicklas |
111 |
GenericOverview overview = OverviewUtil.getCurrentOverview(sc); |
4745 |
10 Feb 09 |
nicklas |
112 |
Presets presets = OverviewUtil.getValidationPresets(sc); |
4745 |
10 Feb 09 |
nicklas |
113 |
String name = request.getParameter("presetName"); |
4745 |
10 Feb 09 |
nicklas |
114 |
Preset preset = presets.getPreset(name); |
6047 |
18 Apr 12 |
nicklas |
115 |
for (Map.Entry<String, List<ValidationRuleAction>> entry : OverviewUtil.getAllRules(dc, overview).entrySet()) |
4745 |
10 Feb 09 |
nicklas |
116 |
{ |
6047 |
18 Apr 12 |
nicklas |
117 |
for (ValidationRuleAction validator : entry.getValue()) |
4745 |
10 Feb 09 |
nicklas |
118 |
{ |
4745 |
10 Feb 09 |
nicklas |
119 |
preset.setSetting(validator.getId(), request.getParameter(validator.getId())); |
4745 |
10 Feb 09 |
nicklas |
120 |
} |
4745 |
10 Feb 09 |
nicklas |
121 |
} |
5076 |
25 Aug 09 |
nicklas |
122 |
preset.setSetting(Validator.NONMATCHING_SPOTCOUNT.getId() + "+threshold", |
5076 |
25 Aug 09 |
nicklas |
123 |
request.getParameter("threshold")); |
4745 |
10 Feb 09 |
nicklas |
124 |
OverviewUtil.saveValidationPresets(sc); |
4745 |
10 Feb 09 |
nicklas |
125 |
forward = "options.jsp"; |
4745 |
10 Feb 09 |
nicklas |
126 |
} |
4745 |
10 Feb 09 |
nicklas |
127 |
else if ("RemovePreset".equals(cmd)) |
4745 |
10 Feb 09 |
nicklas |
128 |
{ |
4745 |
10 Feb 09 |
nicklas |
129 |
Presets presets = OverviewUtil.getValidationPresets(sc); |
4745 |
10 Feb 09 |
nicklas |
130 |
String name = request.getParameter("presetName"); |
4745 |
10 Feb 09 |
nicklas |
131 |
presets.deletePreset(name); |
4745 |
10 Feb 09 |
nicklas |
132 |
OverviewUtil.saveValidationPresets(sc); |
4745 |
10 Feb 09 |
nicklas |
133 |
redirect = "options.jsp?ID=" + ID; |
4745 |
10 Feb 09 |
nicklas |
134 |
} |
4745 |
10 Feb 09 |
nicklas |
135 |
else |
4745 |
10 Feb 09 |
nicklas |
136 |
{ |
4745 |
10 Feb 09 |
nicklas |
137 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
4745 |
10 Feb 09 |
nicklas |
138 |
} |
4745 |
10 Feb 09 |
nicklas |
139 |
} |
4745 |
10 Feb 09 |
nicklas |
140 |
finally |
4745 |
10 Feb 09 |
nicklas |
141 |
{ |
4745 |
10 Feb 09 |
nicklas |
142 |
if (dc != null) dc.close(); |
4745 |
10 Feb 09 |
nicklas |
143 |
} |
4745 |
10 Feb 09 |
nicklas |
144 |
|
4745 |
10 Feb 09 |
nicklas |
145 |
if (forward != null) |
4745 |
10 Feb 09 |
nicklas |
146 |
{ |
6192 |
31 Oct 12 |
nicklas |
147 |
sc.setSessionSetting("alert-message", message); |
4745 |
10 Feb 09 |
nicklas |
148 |
pageContext.forward(forward); |
4745 |
10 Feb 09 |
nicklas |
149 |
} |
4745 |
10 Feb 09 |
nicklas |
150 |
else if (redirect != null) |
4745 |
10 Feb 09 |
nicklas |
151 |
{ |
6192 |
31 Oct 12 |
nicklas |
152 |
sc.setSessionSetting("alert-message", message); |
4745 |
10 Feb 09 |
nicklas |
153 |
response.sendRedirect(redirect); |
4745 |
10 Feb 09 |
nicklas |
154 |
} |
4745 |
10 Feb 09 |
nicklas |
155 |
else if (message == null) |
4745 |
10 Feb 09 |
nicklas |
156 |
{ |
4745 |
10 Feb 09 |
nicklas |
157 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
4745 |
10 Feb 09 |
nicklas |
158 |
} |
4745 |
10 Feb 09 |
nicklas |
159 |
else |
4745 |
10 Feb 09 |
nicklas |
160 |
{ |
4745 |
10 Feb 09 |
nicklas |
161 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
4745 |
10 Feb 09 |
nicklas |
162 |
} |
4745 |
10 Feb 09 |
nicklas |
163 |
%> |
4745 |
10 Feb 09 |
nicklas |
164 |
|