source: trunk/www/common/overview/index.jsp @ 5076

Last change on this file since 5076 was 5076, checked in by Nicklas Nordborg, 14 years ago

Fixes #1362: Validate the number of raw data spots against the number of array design features

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 5.4 KB
Line 
1<%-- $Id: index.jsp 5076 2009-08-25 09:15:41Z 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<%
46final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
47final String ID = sc.getId();
48final String cmd = request.getParameter("cmd");
49final String root = request.getContextPath()+"/";
50
51String forward = null;
52String redirect = null;
53String message = null;
54DbControl dc = null;
55try
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.setOption(Validator.NONMATCHING_SPOTCOUNT, "threshold", request.getParameter("threshold"));
99    options.saveToPreset(presets.getDefault());
100    OverviewUtil.saveValidationPresets(sc);
101    overview.updateFailureCountOnNodes();
102  }
103  else if ("SaveAsPreset".equals(cmd))
104  {
105    Presets presets = OverviewUtil.getValidationPresets(sc);
106    String name = request.getParameter("presetName");
107    Preset preset = presets.getPreset(name);
108    for (Map.Entry<String, List<Validator>> entry : OverviewUtil.getValidators().entrySet())
109    {
110      for (Validator validator : entry.getValue())
111      {
112        preset.setSetting(validator.getId(), request.getParameter(validator.getId()));
113      }
114    }
115    preset.setSetting(Validator.NONMATCHING_SPOTCOUNT.getId() + "+threshold", 
116        request.getParameter("threshold"));
117    OverviewUtil.saveValidationPresets(sc);
118    forward = "options.jsp";
119  }
120  else if ("RemovePreset".equals(cmd))
121  {
122    Presets presets = OverviewUtil.getValidationPresets(sc);
123    String name = request.getParameter("presetName");
124    presets.deletePreset(name);
125    OverviewUtil.saveValidationPresets(sc);
126    redirect = "options.jsp?ID=" + ID;
127  }
128  else
129  {
130    throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd);
131  }
132}
133finally
134{
135  if (dc != null) dc.close();
136}
137
138if (forward != null)
139{
140  pageContext.forward(forward);
141}
142else if (redirect != null)
143{
144  response.sendRedirect(redirect);
145}
146else if (message == null)
147{
148  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0");
149}
150else
151{
152  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message));
153}
154%>
155
Note: See TracBrowser for help on using the repository browser.