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 | <% |
---|
36 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
37 | final String ID = sc.getId(); |
---|
38 | final String cmd = request.getParameter("cmd"); |
---|
39 | final String root = request.getContextPath()+"/"; |
---|
40 | final String nodeId = request.getParameter("node_id"); |
---|
41 | DbControl dc = null; |
---|
42 | out.clear(); |
---|
43 | try |
---|
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 |
---|
87 | id <%=n.getId()%> |
---|
88 | title <%=n.getTitle() + (n.getNodeType() == Node.Type.FOLDER ? " (" + numChildren + ")" : "")%> |
---|
89 | folderIcon <%=folderIcon %> |
---|
90 | numChildren <%=numChildren %> |
---|
91 | end |
---|
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 | } |
---|
102 | finally |
---|
103 | { |
---|
104 | if (dc != null) dc.close(); |
---|
105 | } |
---|
106 | //out.flush(); |
---|
107 | //out.close(); |
---|
108 | %> |
---|