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

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

Merged pre-2.11 changes to the trunk.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.7 KB
Line 
1<%-- $Id: ajax.jsp 4864 2009-03-30 07:18:50Z nicklas $
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(nodeId);
48    overview.expand(dc, parent, false);
49    overview.updateFailureCountOnNodes();
50    if (parent != null && parent.numChildren() > 0)
51    {
52      for (Node n : parent.getChildren())
53      {
54        String title;
55        String folderIcon = n.getNodeType() == Node.Type.FOLDER ? "Folder" : "Item";
56        if (n.getItemType() == Item.ANNOTATIONTYPE && parent.getItemType() == Item.PROTOCOL)
57        {
58          folderIcon = "ProtocolParameter";
59        }
60        else if (n.getItemType() == Item.ANNOTATION)
61        {
62          folderIcon = "Annotation";
63        }       
64        int numChildren = n.numChildren();
65        %>begin
66id  <%=n.getId()%>
67title <%=n.getTitle() + (n.getNodeType() == Node.Type.FOLDER ? " (" + numChildren + ")" : "")%>
68folderIcon  <%=folderIcon %>
69numChildren <%=numChildren %>
70end
71<%
72      }
73      dc.commit();
74    }
75  }
76  else
77  {
78    throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd);
79  }
80}
81finally
82{
83  if (dc != null) dc.close();
84}
85//out.flush();
86//out.close();
87%>
Note: See TracBrowser for help on using the repository browser.