source: trunk/www/views/experiments/overview/failures.jsp @ 3045

Last change on this file since 3045 was 3045, checked in by Nicklas Nordborg, 15 years ago

References #262 and #340. The overview and validation is now complete.
Still missing possibility to save validation options as presets.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 5.8 KB
Line 
1<%-- $Id: failures.jsp 3045 2006-12-20 14:37:29Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) Authors contributing to this file.
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 2
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 this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA  02111-1307, USA.
22  ------------------------------------------------------------------
23
24  @author Nicklas
25  @version 2.0
26--%>
27<%@ page session="false"
28  import="net.sf.basedb.core.SessionControl"
29  import="net.sf.basedb.core.DbControl"
30  import="net.sf.basedb.core.Experiment"
31  import="net.sf.basedb.core.Project"
32  import="net.sf.basedb.core.Item"
33  import="net.sf.basedb.core.BasicItem"
34  import="net.sf.basedb.core.Nameable"
35  import="net.sf.basedb.core.ItemContext"
36  import="net.sf.basedb.core.Permission"
37  import="net.sf.basedb.clients.web.Base"
38  import="net.sf.basedb.clients.web.util.HTML"
39  import="net.sf.basedb.util.Values"
40  import="net.sf.basedb.util.NestedIterator"
41  import="net.sf.basedb.util.overview.ExperimentOverview"
42  import="net.sf.basedb.util.overview.Node"
43  import="net.sf.basedb.util.overview.ValidationOptions"
44  import="net.sf.basedb.util.overview.Validator"
45  import="net.sf.basedb.util.overview.Severity"
46  import="net.sf.basedb.util.overview.Failure"
47  import="java.util.List"
48  import="java.util.LinkedList"
49  import="java.util.Iterator"
50%>
51<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
52<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
53<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
54<%
55final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
56final String ID = sc.getId();
57final float scale = Base.getScale(sc);
58final ItemContext cc = sc.getCurrentContext(Item.EXPERIMENT);
59final int itemId = cc.getId();
60final DbControl dc = sc.newDbControl();
61try
62{
63  Experiment experiment = Experiment.getById(dc, itemId);
64  Project project = sc.getActiveProjectId() == 0 ? null : Project.getById(dc, sc.getActiveProjectId());
65  ExperimentOverview overview = ExperimentOverview.getOverview(experiment, project);
66  ValidationOptions options = overview.getValidationOptions();
67  List<Failure> failures = overview.getFailures();
68  List<Failure> errors = new LinkedList<Failure>();
69  List<Failure> warnings = new LinkedList<Failure>();
70 
71  for (Failure failure : failures)
72  {
73    Validator validator = failure.getValidator();
74    Severity severity = options.getSeverity(validator);
75    if (severity == Severity.ERROR)
76    {
77      errors.add(failure);
78    }
79    else if (severity == Severity.WARNING)
80    {
81      warnings.add(failure);
82    }
83  }
84  %>
85  <base:page title="" type="popup">
86  <base:head scripts="" styles="newjoust.css">
87  <script language="JavaScript">
88  var selectedFailure = null;
89  function failureOnClick(evt, failureId, nodeId, itemType, itemId)
90  {
91    if (itemType && evt && (evt.altKey || evt.ctrlKey || evt.shiftKey))
92    {
93      Main.viewOrEditItem('<%=ID%>', itemType, itemId, true);
94    }
95    else
96    {
97      window.parent.frames['tree'].selectNode(nodeId);
98      if (selectedFailure) Main.removeClass(selectedFailure, 'selected');
99      selectedFailure = document.getElementById(failureId);
100      Main.addClass(selectedFailure, 'selected');
101    }
102  }
103  function itemOnClick(evt, itemType, itemId)
104  {
105    Table.itemOnClick(formId, evt, itemId, 'default', viewItem, editItem, returnSelected);
106  }
107  </script>
108  </base:head>
109
110    <base:body>
111      <div style="border-bottom: 1px solid #999999; padding-bottom: 2px;">
112        <b>
113        <%=errors.size() %> error(s),
114        <%=warnings.size()%> warning(s)
115        </b>
116      </div>
117     
118      <div class="joust">
119      <table border="0" cellspacing="0" cellpadding="0" width="100%">
120      <%
121      Iterator<Failure> all = new NestedIterator<Failure>(errors, warnings);
122      while (all.hasNext())
123      {
124        Failure failure = all.next();
125        Validator validator = failure.getValidator();
126        Severity severity = options.getSeverity(validator);
127        if (severity != Severity.IGNORE)
128        {
129          String failureId = "F" + failure.hashCode();
130          Node node = failure.getNode();
131          BasicItem item = node.getItem();
132          String onClick = "";
133          String tooltip = "";
134          if (item == null)
135          {
136            tooltip = "Get more information about this failure";
137            onClick = "failureOnClick(event, '"+failureId+"', '" + node.getId() + "')";
138          }
139          else
140          {
141            tooltip = "Get more information about this failure (use CTRL, ALT or SHIFT to edit the item)";
142            onClick = "failureOnClick(event, '"+failureId+"', '" + node.getId() + 
143              "', '" + item.getType().name() + "', " + item.getId() + ")";
144          }
145          %>
146          <tr id="<%=failureId%>" class="menuitem" 
147            onclick="<%=onClick%>" 
148            onmouseover="Main.addClass(this, 'hover')" 
149            onmouseout="Main.removeClass(this, 'hover')"
150            title="<%=tooltip%>"
151            >
152            <td width="20px" style="border-bottom: 1px dotted #999999"
153              ><base:icon image="<%=severity == Severity.ERROR ? 
154            "error.gif" : "warning.gif"%>" /></td>
155            <td class="text" style="border-bottom: 1px dotted #999999; padding: 2px;"
156              ><%=HTML.encodeTags(failure.getMessage()) %>
157            </td>
158            <td class="text" style="border-bottom: 1px dotted #999999; padding: 2px;"
159              ><%=HTML.encodeTags(node.getTitle()) %>
160            </td>
161          </tr>
162          <%
163        }
164      }
165      %>
166      </table>
167      </div>
168
169    </base:body>
170  </base:page>
171  <%
172}
173finally
174{
175  if (dc != null) dc.close();
176}
177%>
Note: See TracBrowser for help on using the repository browser.