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

Last change on this file since 4823 was 4823, checked in by Martin Svensson, 14 years ago

References #1240. The node-icons are getting updated when expanding the item-tree and an error or warning appears.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 5.2 KB
Line 
1<%-- $Id: index.jsp 4823 2009-03-19 15:08:24Z martin $
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.expand(dc, overview.getRootNode(), false);
68    overview.updateFailureCountOnNodes();
69    dc.close();
70    redirect = "frameset.jsp?ID="+ID;
71  }
72  else if ("Revalidate".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;
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}
130finally
131{
132  if (dc != null) dc.close();
133}
134
135if (forward != null)
136{
137  pageContext.forward(forward);
138}
139else if (redirect != null)
140{
141  response.sendRedirect(redirect);
142}
143else if (message == null)
144{
145  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0");
146}
147else
148{
149  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message));
150}
151%>
152
Note: See TracBrowser for help on using the repository browser.