source: trunk/www/common/overview/ajax.jsp @ 4816

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

References #1240 The item-overview tree is now using lazy loading. The other parts of the ticket (eg. validation and buttons) are not yet covered and probably not fully functional at the moment.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.9 KB
Line 
1<%-- $Id: ajax.jsp 4816 2009-03-16 14:15:37Z martin $
2  ------------------------------------------------------------------
3  Copyright (C) 2009 Martin Svensson
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--%>
23<%@ page session="false"
24  import="net.sf.basedb.core.SessionControl"
25  import="net.sf.basedb.core.DbControl"
26  import="net.sf.basedb.core.Item"
27  import="net.sf.basedb.util.overview.GenericOverview"
28  import="net.sf.basedb.util.overview.Node"
29  import="net.sf.basedb.util.overview.OverviewUtil"
30  import="net.sf.basedb.clients.web.Base"
31  import="net.sf.basedb.clients.web.WebException"
32%>
33<%
34final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
35final String ID = sc.getId();
36final String cmd = request.getParameter("cmd");
37final String root = request.getContextPath()+"/";
38final String nodeId = request.getParameter("node_id");
39DbControl dc = null;
40out.clear();
41try
42{
43  if ("GetSubNodes".equals(cmd))
44  {
45    dc = sc.newDbControl();
46    GenericOverview overview = OverviewUtil.getCurrentOverview(sc);
47    Node parent = overview.getNode("N"+nodeId);
48    overview.expand(dc, parent, false);
49    if (parent != null && parent.numChildren() > 0)
50    {
51      for (Node n : parent.getChildren())
52      {     
53        int errors = n.getNumErrors();
54        int warnings = n.getNumWarnings();
55        int childErrors = n.getChildErrors();
56        int childWarnings = n.getChildWarnings();
57       
58        String folderIcon = n.getNodeType() == Node.Type.FOLDER ? "Folder" : "Item";
59        if (n.getItemType() == Item.ANNOTATIONTYPE && parent.getItemType() == Item.PROTOCOL)
60        {
61          folderIcon = "ProtocolParameter";
62        }
63        else if (n.getItemType() == Item.ANNOTATION)
64        {
65          folderIcon = "Annotation";
66        }
67        if (errors > 0)
68        {
69          folderIcon += "Error";
70        }
71        else if (warnings > 0)
72        {
73          folderIcon += "Warning";
74        }
75        else if(childErrors > 0)
76        {
77          folderIcon += "ChildError";
78        }
79        else if (childWarnings > 0)
80        {
81          folderIcon += "ChildWarning";
82        }
83        String tooltip = "";
84        if (warnings > 0 && errors > 0)
85        {
86          tooltip += errors + " error(s); " + warnings + " warning(s) on this item";
87        }
88        else if (errors > 0)
89        {
90          tooltip += errors + " error(s) on this item";
91        }
92        else if (warnings > 0)
93        {
94          tooltip += warnings + " warning(s) on this item";
95        }
96        if (childErrors > 0 && childWarnings > 0)
97        {
98          if (tooltip.length() > 0) tooltip += "; ";
99          tooltip += childErrors + " error(s); " + childWarnings + " warning(s) on child items";
100        }
101        else if (childErrors > 0)
102        {
103          if (tooltip.length() > 0) tooltip += "; ";
104          tooltip += childErrors + " error(s) on child items";
105        }
106        else if (childWarnings > 0)
107        {
108          if (tooltip.length() > 0) tooltip += "; ";
109          tooltip += childWarnings + " warning(s) on child items";
110        }
111        int numChildren = n.getChildren() == null ? 
112          0 : n.getChildren().size();
113        %>begin
114id  <%=n.getId()%>
115title <%=n.getTitle() + (n.getNodeType() == Node.Type.FOLDER ? " (" + numChildren + ")" : "")%>
116hashCode  <%=n.hashCode()%>
117folderIcon  <%=folderIcon %>
118tooltip <%=tooltip%>
119end
120<%
121      }
122      dc.commit();
123    }
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//out.flush();
135//out.close();
136%>
Note: See TracBrowser for help on using the repository browser.