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

Last change on this file since 5145 was 5145, checked in by Nicklas Nordborg, 13 years ago

Fixes #1404: Use cached annotations in "item overview"

The tests in #1406 were successful. Also fixed an issue with icons in the outline for protocol parameters.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.1 KB
Line 
1<%-- $Id: ajax.jsp 5145 2009-10-20 06:50:49Z 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.Annotation"
27  import="net.sf.basedb.core.AnnotationType"
28  import="net.sf.basedb.core.Item"
29  import="net.sf.basedb.util.overview.GenericOverview"
30  import="net.sf.basedb.util.overview.Node"
31  import="net.sf.basedb.util.overview.OverviewUtil" 
32  import="net.sf.basedb.clients.web.Base"
33  import="net.sf.basedb.clients.web.WebException"
34%>
35<%
36final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
37final String ID = sc.getId();
38final String cmd = request.getParameter("cmd");
39final String root = request.getContextPath()+"/";
40final String nodeId = request.getParameter("node_id");
41DbControl dc = null;
42out.clear();
43try
44{
45  if ("GetSubNodes".equals(cmd))
46  {
47    dc = sc.newDbControl();
48    GenericOverview overview = OverviewUtil.getCurrentOverview(sc);
49    Node parent = overview.getNode(nodeId);
50    overview.expand(dc, parent, false);
51    overview.updateFailureCountOnNodes();
52    if (parent != null && parent.numChildren() > 0)
53    {
54      for (Node n : parent.getChildren())
55      {
56        String folderIcon = n.getNodeType() == Node.Type.FOLDER ? "Folder" : "Item";
57        if (n.getItemType() == Item.ANNOTATIONTYPE)
58        {
59          if (parent.getItemType() == Item.PROTOCOL)
60          {
61            folderIcon = "ProtocolParameter";
62          }
63          else
64          {
65            try
66            {
67              AnnotationType at = (AnnotationType)n.getItem(dc);
68              if (at.isProtocolParameter()) folderIcon = "ProtocolParameter";
69            }
70            catch (Throwable t)
71            {}
72          }
73        }
74        else if (n.getItemType() == Item.ANNOTATION)
75        {
76          folderIcon = "Annotation";
77          try
78          {
79            AnnotationType at = ((Annotation)n.getItem(dc)).getAnnotationType();
80            if (at.isProtocolParameter()) folderIcon = "ProtocolParameter";
81          }
82          catch (Throwable t)
83          {}
84        }       
85        int numChildren = n.numChildren();
86        %>begin
87id  <%=n.getId()%>
88title <%=n.getTitle() + (n.getNodeType() == Node.Type.FOLDER ? " (" + numChildren + ")" : "")%>
89folderIcon  <%=folderIcon %>
90numChildren <%=numChildren %>
91end
92<%
93      }
94      dc.commit();
95    }
96  }
97  else
98  {
99    throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd);
100  }
101}
102finally
103{
104  if (dc != null) dc.close();
105}
106//out.flush();
107//out.close();
108%>
Note: See TracBrowser for help on using the repository browser.