1 | <%-- $Id: view_bioassay.jsp 4057 2007-12-13 12:45:00Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2006 Jari Hakkinen, Nicklas Nordborg, 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 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 | |
---|
25 | @author Nicklas |
---|
26 | @version 2.0 |
---|
27 | --%> |
---|
28 | <%@ page session="false" |
---|
29 | import="net.sf.basedb.core.SessionControl" |
---|
30 | import="net.sf.basedb.core.DbControl" |
---|
31 | import="net.sf.basedb.core.Item" |
---|
32 | import="net.sf.basedb.core.ItemContext" |
---|
33 | import="net.sf.basedb.core.Permission" |
---|
34 | import="net.sf.basedb.core.Experiment" |
---|
35 | import="net.sf.basedb.core.BioAssaySet" |
---|
36 | import="net.sf.basedb.core.BioAssay" |
---|
37 | import="net.sf.basedb.core.RawBioAssay" |
---|
38 | import="net.sf.basedb.core.Annotatable" |
---|
39 | import="net.sf.basedb.core.AnnotationSet" |
---|
40 | import="net.sf.basedb.core.AnnotationType" |
---|
41 | import="net.sf.basedb.core.Annotation" |
---|
42 | import="net.sf.basedb.core.ItemQuery" |
---|
43 | import="net.sf.basedb.core.ItemResultList" |
---|
44 | import="net.sf.basedb.core.Include" |
---|
45 | import="net.sf.basedb.core.BaseException" |
---|
46 | import="net.sf.basedb.core.PluginDefinition" |
---|
47 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
48 | import="net.sf.basedb.core.plugin.Plugin" |
---|
49 | import="net.sf.basedb.core.query.Orders" |
---|
50 | import="net.sf.basedb.core.query.Hql" |
---|
51 | import="net.sf.basedb.util.formatter.Formatter" |
---|
52 | import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
---|
53 | import="net.sf.basedb.clients.web.Base" |
---|
54 | import="net.sf.basedb.clients.web.PermissionUtil" |
---|
55 | import="net.sf.basedb.clients.web.util.HTML" |
---|
56 | import="net.sf.basedb.util.Values" |
---|
57 | import="java.util.Map" |
---|
58 | import="java.util.List" |
---|
59 | import="java.util.HashMap" |
---|
60 | import="java.util.LinkedList" |
---|
61 | %> |
---|
62 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
63 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
64 | <%@ taglib prefix="p" uri="/WEB-INF/path.tld" %> |
---|
65 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
66 | <%! |
---|
67 | private static final Item itemType = Item.BIOASSAY; |
---|
68 | private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM); |
---|
69 | %> |
---|
70 | <% |
---|
71 | final Item itemType = Item.BIOASSAY; |
---|
72 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
73 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
74 | final int itemId = cc.getId(); |
---|
75 | final String ID = sc.getId(); |
---|
76 | final float scale = Base.getScale(sc); |
---|
77 | final String tabId = Values.getString(request.getParameter("tab"), "properties"); |
---|
78 | final DbControl dc = sc.newDbControl(); |
---|
79 | try |
---|
80 | { |
---|
81 | BioAssay bioAssay = BioAssay.getById(dc, itemId); |
---|
82 | BioAssaySet bioAssaySet = bioAssay.getBioAssaySet(); |
---|
83 | Experiment experiment = bioAssay.getExperiment(); |
---|
84 | String title = null; |
---|
85 | final boolean writePermission = bioAssay.hasPermission(Permission.WRITE); |
---|
86 | Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); |
---|
87 | %> |
---|
88 | |
---|
89 | <base:page title="<%=title%>"> |
---|
90 | <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css"> |
---|
91 | <script language="JavaScript"> |
---|
92 | function editItem() |
---|
93 | { |
---|
94 | Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true); |
---|
95 | } |
---|
96 | function runPlugin(cmd) |
---|
97 | { |
---|
98 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540); |
---|
99 | } |
---|
100 | function switchTab(tabControlId, tabId) |
---|
101 | { |
---|
102 | if (tabId == 'spotdata') |
---|
103 | { |
---|
104 | location.href = "../spotdata/index.jsp?ID=<%=ID%>&bioassay_id=<%=itemId%>"; |
---|
105 | } |
---|
106 | else |
---|
107 | { |
---|
108 | TabControl.setActiveTab(tabControlId, tabId); |
---|
109 | } |
---|
110 | } |
---|
111 | function openPlotTool() |
---|
112 | { |
---|
113 | Main.openPopup('../plotter/index.jsp?ID=<%=ID%>&bioassay_id=<%=itemId%>', 'Plotter', 1000, 700); |
---|
114 | } |
---|
115 | </script> |
---|
116 | </base:head> |
---|
117 | <base:body> |
---|
118 | <p> |
---|
119 | <p:path> |
---|
120 | <p:pathelement title="Experiments" href="<%="../index.jsp?ID="+ID%>" /> |
---|
121 | <p:pathelement title="<%=HTML.encodeTags(experiment.getName())%>" |
---|
122 | href="<%="../bioassaysets/index.jsp?ID="+ID+"&experiment_id="+experiment.getId()%>" /> |
---|
123 | <p:pathelement title="<%=HTML.encodeTags(bioAssaySet.getName())%>" |
---|
124 | href="<%="index.jsp?ID="+ID+"&bioassayset_id="+bioAssaySet.getId()%>" /> |
---|
125 | <p:pathelement title="<%=HTML.encodeTags(bioAssay.getName())%>" /> |
---|
126 | </p:path> |
---|
127 | |
---|
128 | <t:tabcontrol id="main" active="<%=tabId%>" switch="switchTab"> |
---|
129 | <t:tab id="properties" title="Properties"> |
---|
130 | <tbl:toolbar |
---|
131 | > |
---|
132 | <tbl:button |
---|
133 | disabled="<%=writePermission ? false : true%>" |
---|
134 | image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" |
---|
135 | onclick="editItem()" |
---|
136 | title="Edit…" |
---|
137 | tooltip="<%=writePermission ? "Edit this bioassay" : "You do not have permission to edit this bioassay"%>" |
---|
138 | /> |
---|
139 | <tbl:button |
---|
140 | image="import.gif" |
---|
141 | onclick="runPlugin('ImportItem')" |
---|
142 | title="Import…" |
---|
143 | tooltip="Import data" |
---|
144 | visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>" |
---|
145 | /> |
---|
146 | <tbl:button |
---|
147 | image="export.gif" |
---|
148 | onclick="runPlugin('ExportItem')" |
---|
149 | title="Export…" |
---|
150 | tooltip="Export data" |
---|
151 | visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>" |
---|
152 | /> |
---|
153 | <tbl:button |
---|
154 | image="runplugin.gif" |
---|
155 | onclick="runPlugin('RunPlugin')" |
---|
156 | title="Run plugin…" |
---|
157 | tooltip="Run a plugin" |
---|
158 | visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>" |
---|
159 | /> |
---|
160 | <tbl:button |
---|
161 | image="plotter.gif" |
---|
162 | onclick="openPlotTool()" |
---|
163 | title="Plot tool…" |
---|
164 | tooltip="A simple tool for generating plots" |
---|
165 | /> |
---|
166 | <tbl:button |
---|
167 | image="help.gif" |
---|
168 | onclick="<%="Main.openHelp('" + ID +"', 'bioassay.view.properties')"%>" |
---|
169 | title="Help…" |
---|
170 | tooltip="Get help about this page" |
---|
171 | /> |
---|
172 | </tbl:toolbar> |
---|
173 | |
---|
174 | <div class="boxedbottom"> |
---|
175 | <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(bioAssay)%></i></div> |
---|
176 | <table class="form" cellspacing=0> |
---|
177 | <tr> |
---|
178 | <td class="prompt">Name</td> |
---|
179 | <td><%=HTML.encodeTags(bioAssay.getName())%></td> |
---|
180 | </tr> |
---|
181 | <tr> |
---|
182 | <td class="prompt">Spots</td> |
---|
183 | <td><%=bioAssay.getNumSpots()%></td> |
---|
184 | </tr> |
---|
185 | <tr valign=top> |
---|
186 | <td class="prompt">Description</td> |
---|
187 | <td><%=HTML.encodeTags(bioAssay.getDescription())%></td> |
---|
188 | </tr> |
---|
189 | </table> |
---|
190 | |
---|
191 | <% |
---|
192 | ItemQuery<RawBioAssay> rawQuery = bioAssay.getRawBioAssays(); |
---|
193 | rawQuery.include(Include.MINE, Include.SHARED, Include.OTHERS, Include.IN_PROJECT); |
---|
194 | rawQuery.order(Orders.asc(Hql.property("name"))); |
---|
195 | ItemResultList<RawBioAssay> rawBioAssays = rawQuery.list(dc); |
---|
196 | if (rawBioAssays.size() == 0) |
---|
197 | { |
---|
198 | %> |
---|
199 | <h4>Raw bioassays</h4> |
---|
200 | No raw bioassays are linked to this bioassay |
---|
201 | (or, you don't have permission to view them). |
---|
202 | <% |
---|
203 | } |
---|
204 | else |
---|
205 | { |
---|
206 | %> |
---|
207 | <h4 class="docked">Raw bioassays</h4> |
---|
208 | <tbl:table |
---|
209 | id="rawBioAssays" |
---|
210 | clazz="itemlist" |
---|
211 | columns="all" |
---|
212 | > |
---|
213 | <tbl:columndef |
---|
214 | id="name" |
---|
215 | title="Name" |
---|
216 | /> |
---|
217 | <tbl:columndef |
---|
218 | id="spots" |
---|
219 | title="Spots" |
---|
220 | /> |
---|
221 | <tbl:columndef |
---|
222 | id="description" |
---|
223 | title="Description" |
---|
224 | /> |
---|
225 | <% |
---|
226 | ItemQuery<AnnotationType> efQuery = experiment.getExperimentalFactors(); |
---|
227 | efQuery.include(Include.ALL); |
---|
228 | efQuery.order(Orders.asc(Hql.property("name"))); |
---|
229 | ItemResultList<AnnotationType> experimentalFactors = efQuery.list(dc); |
---|
230 | for (AnnotationType at : experimentalFactors) |
---|
231 | { |
---|
232 | Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType()); |
---|
233 | %> |
---|
234 | <tbl:columndef |
---|
235 | id="<%="at"+at.getId()%>" |
---|
236 | title="<%=HTML.encodeTags(at.getName())%>" |
---|
237 | formatter="<%=formatter%>" |
---|
238 | /> |
---|
239 | <% |
---|
240 | } |
---|
241 | %> |
---|
242 | <tbl:data> |
---|
243 | <tbl:columns> |
---|
244 | </tbl:columns> |
---|
245 | <tbl:rows> |
---|
246 | <% |
---|
247 | for (RawBioAssay item : rawBioAssays) |
---|
248 | { |
---|
249 | %> |
---|
250 | <tbl:row> |
---|
251 | <tbl:cell column="name"><%=Base.getLinkedName(ID, item, false, true)%></tbl:cell> |
---|
252 | <tbl:cell column="spots"><%=item.getSpots()%></tbl:cell> |
---|
253 | <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell> |
---|
254 | <% |
---|
255 | AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null; |
---|
256 | for (AnnotationType at : experimentalFactors) |
---|
257 | { |
---|
258 | String value = "<i>- none -</i>"; |
---|
259 | List<Annotation> all = as == null ? null : as.findAnnotations(dc, at, true); |
---|
260 | Map<Annotatable, List> factorValues = new HashMap<Annotatable, List>(); |
---|
261 | if (all != null && all.size() > 0) |
---|
262 | { |
---|
263 | for (Annotation a : all) |
---|
264 | { |
---|
265 | List values = a.getValues(); |
---|
266 | Annotatable aItem = null; |
---|
267 | try |
---|
268 | { |
---|
269 | aItem = a.getAnnotationSet().getItem(); |
---|
270 | } |
---|
271 | catch (Throwable t) |
---|
272 | {} |
---|
273 | List toAdd = factorValues.get(aItem); |
---|
274 | if (toAdd == null) |
---|
275 | { |
---|
276 | toAdd = new LinkedList(); |
---|
277 | factorValues.put(aItem, toAdd); |
---|
278 | } |
---|
279 | toAdd.addAll(values); |
---|
280 | } |
---|
281 | } |
---|
282 | %> |
---|
283 | <tbl:cell column="<%="at"+at.getId()%>" |
---|
284 | > |
---|
285 | <% |
---|
286 | for (Map.Entry<Annotatable, List> entry : factorValues.entrySet()) |
---|
287 | { |
---|
288 | Annotatable aItem = entry.getKey(); |
---|
289 | List values = entry.getValue(); |
---|
290 | %> |
---|
291 | <tbl:cellvalue list="<%=values%>" /> |
---|
292 | <% |
---|
293 | if (aItem != null && aItem.hasPermission(Permission.WRITE)) |
---|
294 | { |
---|
295 | %>: <base:icon image="edit.gif" |
---|
296 | onclick="<%="editInheritedAnnotation('"+aItem.getType().name()+"',"+aItem.getId()+","+at.getId()+")"%>" |
---|
297 | tooltip="Modify the values of this experimental factor" /> |
---|
298 | <% |
---|
299 | } |
---|
300 | } |
---|
301 | %> |
---|
302 | </tbl:cell> |
---|
303 | <% |
---|
304 | } |
---|
305 | %> |
---|
306 | </tbl:row> |
---|
307 | <% |
---|
308 | } |
---|
309 | %> |
---|
310 | </tbl:rows> |
---|
311 | </tbl:data> |
---|
312 | </tbl:table> |
---|
313 | <% |
---|
314 | } |
---|
315 | %> |
---|
316 | </div> |
---|
317 | </t:tab> |
---|
318 | |
---|
319 | <t:tab id="annotations" title="Annotations" |
---|
320 | tooltip="View annotation values"> |
---|
321 | <div class="boxed"> |
---|
322 | <jsp:include page="../../../common/annotations/list_annotations.jsp"> |
---|
323 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
324 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
325 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
326 | </jsp:include> |
---|
327 | </div> |
---|
328 | </t:tab> |
---|
329 | |
---|
330 | <t:tab id="spotdata" title="Spot data" /> |
---|
331 | |
---|
332 | </t:tabcontrol> |
---|
333 | |
---|
334 | |
---|
335 | </base:body> |
---|
336 | </base:page> |
---|
337 | <% |
---|
338 | } |
---|
339 | finally |
---|
340 | { |
---|
341 | if (dc != null) dc.close(); |
---|
342 | } |
---|
343 | %> |
---|