1 | <%-- $Id: list_spotdata.jsp 5951 2012-02-09 14:19:17Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg |
---|
4 | Copyright (C) 2007 Johan Enell |
---|
5 | |
---|
6 | This file is part of BASE - BioArray Software Environment. |
---|
7 | Available at http://base.thep.lu.se/ |
---|
8 | |
---|
9 | BASE is free software; you can redistribute it and/or |
---|
10 | modify it under the terms of the GNU General Public License |
---|
11 | as published by the Free Software Foundation; either version 3 |
---|
12 | of the License, or (at your option) any later version. |
---|
13 | |
---|
14 | BASE is distributed in the hope that it will be useful, |
---|
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | GNU General Public License for more details. |
---|
18 | |
---|
19 | You should have received a copy of the GNU General Public License |
---|
20 | along with BASE. If not, see <http://www.gnu.org/licenses/>. |
---|
21 | ------------------------------------------------------------------ |
---|
22 | |
---|
23 | @author Nicklas |
---|
24 | @version 2.0 |
---|
25 | --%> |
---|
26 | <%@ page pageEncoding="UTF-8" session="false" |
---|
27 | import="net.sf.basedb.core.SessionControl" |
---|
28 | import="net.sf.basedb.core.DbControl" |
---|
29 | import="net.sf.basedb.core.Item" |
---|
30 | import="net.sf.basedb.core.Type" |
---|
31 | import="net.sf.basedb.core.ItemContext" |
---|
32 | import="net.sf.basedb.core.Permission" |
---|
33 | import="net.sf.basedb.core.Experiment" |
---|
34 | import="net.sf.basedb.core.BioAssaySet" |
---|
35 | import="net.sf.basedb.core.BioAssay" |
---|
36 | import="net.sf.basedb.core.RawDataType" |
---|
37 | import="net.sf.basedb.core.BaseException" |
---|
38 | import="net.sf.basedb.core.DynamicSpotQuery" |
---|
39 | import="net.sf.basedb.core.DynamicResultIterator" |
---|
40 | import="net.sf.basedb.core.PluginDefinition" |
---|
41 | import="net.sf.basedb.core.Formula" |
---|
42 | import="net.sf.basedb.core.IntensityTransform" |
---|
43 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
44 | import="net.sf.basedb.core.plugin.Plugin" |
---|
45 | import="net.sf.basedb.core.query.SqlResult" |
---|
46 | import="net.sf.basedb.util.Enumeration" |
---|
47 | import="net.sf.basedb.util.ColorGenerator" |
---|
48 | import="net.sf.basedb.util.formatter.LookupFormatter" |
---|
49 | import="net.sf.basedb.clients.web.Base" |
---|
50 | import="net.sf.basedb.clients.web.ModeInfo" |
---|
51 | import="net.sf.basedb.clients.web.DynamicUtil" |
---|
52 | import="net.sf.basedb.clients.web.WebException" |
---|
53 | import="net.sf.basedb.clients.web.util.HTML" |
---|
54 | import="net.sf.basedb.util.Values" |
---|
55 | import="net.sf.basedb.clients.web.taglib.table.TableColumn" |
---|
56 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
57 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
58 | import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer" |
---|
59 | import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil" |
---|
60 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
61 | import="java.util.Map" |
---|
62 | import="java.util.HashMap" |
---|
63 | import="java.util.List" |
---|
64 | import="java.util.LinkedList" |
---|
65 | import="java.util.ArrayList" |
---|
66 | import="java.util.Set" |
---|
67 | import="java.util.HashSet" |
---|
68 | import="java.util.Arrays" |
---|
69 | import="java.awt.Color" |
---|
70 | %> |
---|
71 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
72 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
73 | <%@ taglib prefix="p" uri="/WEB-INF/path.tld" %> |
---|
74 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
75 | <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
---|
76 | <%! |
---|
77 | private static final Item itemType = Item.SPOTDATA; |
---|
78 | private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST); |
---|
79 | %> |
---|
80 | <% |
---|
81 | final int bioAssayId = Values.getInt(request.getParameter("bioassay_id")); |
---|
82 | final int bioAssaySetId = Values.getInt(request.getParameter("bioassayset_id")); |
---|
83 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
84 | final String ID = sc.getId(); |
---|
85 | |
---|
86 | final ModeInfo mode = ModeInfo.get(request.getParameter("mode")); |
---|
87 | final String callback = request.getParameter("callback"); |
---|
88 | final String title = mode.generateTitle("spot data", "spot data"); |
---|
89 | final DbControl dc = sc.newDbControl(); |
---|
90 | DynamicResultIterator spotData = null; |
---|
91 | try |
---|
92 | { |
---|
93 | final BioAssay bioAssay = bioAssayId == 0 ? null : BioAssay.getById(dc, bioAssayId); |
---|
94 | final BioAssaySet bioAssaySet = bioAssay != null ? bioAssay.getBioAssaySet() : BioAssaySet.getById(dc, bioAssaySetId); |
---|
95 | final Experiment experiment = bioAssaySet.getExperiment(); |
---|
96 | final int experimentId = experiment.getId(); |
---|
97 | final RawDataType rawDataType = bioAssaySet.getRawDataType(); |
---|
98 | final IntensityTransform transform = bioAssaySet.getIntensityTransform(); |
---|
99 | |
---|
100 | final String subContext = rawDataType.getId(); |
---|
101 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, subContext, null, null); |
---|
102 | Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); |
---|
103 | |
---|
104 | List<TableColumn> columns = new LinkedList<TableColumn>(); |
---|
105 | DynamicUtil.addSpotColumns(columns, dc, rawDataType.getChannels(), transform); |
---|
106 | DynamicUtil.addFormulaColumns(columns, dc, rawDataType, Formula.Type.COLUMN_EXPRESSION, |
---|
107 | transform, "frm.", "[Formula] ", true); |
---|
108 | DynamicUtil.addExtraColumns(columns, dc, bioAssaySet, "ev", "#", "[Xtra] "); |
---|
109 | DynamicUtil.addRawDataColumns(columns, dc, rawDataType, "raw.", "$", "[Raw] "); |
---|
110 | DynamicUtil.addReporterColumns(columns, dc, experiment.getVirtualDb().getReporterCloneTemplate(), "rep.", "@", "[Rep] "); |
---|
111 | DynamicUtil.SelectedInfo selected = DynamicUtil.getSelectedColumns(cc, columns, false); |
---|
112 | if (bioAssay == null && cc.getSetting("columns").indexOf("COLUMN") >= 0) |
---|
113 | { |
---|
114 | selected.selectedIds.add("COLUMN"); |
---|
115 | selected.selectedProperties.add("COLUMN"); |
---|
116 | } |
---|
117 | try |
---|
118 | { |
---|
119 | final DynamicSpotQuery query = bioAssay != null ? bioAssay.getSpotData() : bioAssaySet.getSpotData(); |
---|
120 | cc.configureQuery(dc, query, selected.selectedProperties); |
---|
121 | query.setFailSafe(true); |
---|
122 | spotData = query.iterate(dc); |
---|
123 | } |
---|
124 | catch (Throwable t) |
---|
125 | { |
---|
126 | cc.setMessage(t.getMessage()); |
---|
127 | t.printStackTrace(); |
---|
128 | } |
---|
129 | |
---|
130 | int numListed = 0; |
---|
131 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, |
---|
132 | guiContext, bioAssay == null ? bioAssaySet : bioAssay); |
---|
133 | ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext); |
---|
134 | ExtensionsInvoker overviewPlotInvoker = bioAssay != null ? |
---|
135 | null : ExtensionsControl.useExtensions(jspContext, "net.sf.basedb.clients.web.bioassayset.overviewplots"); |
---|
136 | %> |
---|
137 | <base:page title="<%=title%>"> |
---|
138 | <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css"> |
---|
139 | <ext:scripts context="<%=jspContext%>" /> |
---|
140 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
141 | <script language="JavaScript"> |
---|
142 | var submitPage = 'index.jsp'; |
---|
143 | var formId = 'spotdata'; |
---|
144 | function configureColumns() |
---|
145 | { |
---|
146 | Table.configureColumns('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>', '<%=subContext%>'); |
---|
147 | } |
---|
148 | function presetOnChange() |
---|
149 | { |
---|
150 | Table.presetOnChange('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>', '<%=subContext%>'); |
---|
151 | } |
---|
152 | function runPlugin(cmd) |
---|
153 | { |
---|
154 | Table.submitToPopup(formId, cmd, 750, 500); |
---|
155 | } |
---|
156 | function switchTab(tabControlId, tabId) |
---|
157 | { |
---|
158 | if (tabId == 'properties.bioassay') |
---|
159 | { |
---|
160 | location.href = '../bioassays/index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=bioAssayId%>&tab=properties'; |
---|
161 | } |
---|
162 | else if (tabId == 'annotations.bioassay') |
---|
163 | { |
---|
164 | location.href = '../bioassays/index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=bioAssayId%>&tab=annotations'; |
---|
165 | } |
---|
166 | else if (tabId == 'properties.bioassayset') |
---|
167 | { |
---|
168 | location.href = '../bioassaysets/index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=bioAssaySetId%>&tab=properties'; |
---|
169 | } |
---|
170 | else if (tabId == 'annotations.bioassayset') |
---|
171 | { |
---|
172 | location.href = '../bioassaysets/index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=bioAssaySetId%>&tab=annotations'; |
---|
173 | } |
---|
174 | else if (tabId == 'overviewplots') |
---|
175 | { |
---|
176 | location.href = '../bioassaysets/index.jsp?ID=<%=ID%>&cmd=ViewItem&experiment_id=<%=experimentId%>&item_id=<%=bioAssaySetId%>&tab='+tabId; |
---|
177 | } |
---|
178 | else if (tabId == 'bioassays') |
---|
179 | { |
---|
180 | location.href = '../bioassays/index.jsp?ID=<%=ID%>&experiment_id=<%=experimentId%>&bioassayset_id=<%=bioAssaySetId%>&tab='+tabId; |
---|
181 | } |
---|
182 | else |
---|
183 | { |
---|
184 | TabControl.setActiveTab(tabControlId, tabId); |
---|
185 | } |
---|
186 | } |
---|
187 | function newReporterList() |
---|
188 | { |
---|
189 | Table.submitToPopup(formId, 'CreateReporterList', 540, 400); |
---|
190 | } |
---|
191 | </script> |
---|
192 | </base:head> |
---|
193 | <base:body> |
---|
194 | <p> |
---|
195 | <p:path> |
---|
196 | <p:pathelement title="Experiments" href="<%="../index.jsp?ID="+ID%>" /> |
---|
197 | <p:pathelement title="<%=HTML.encodeTags(experiment.getName())%>" |
---|
198 | href="<%="../bioassaysets/index.jsp?ID="+ID+"&experiment_id="+experiment.getId()%>" /> |
---|
199 | |
---|
200 | <% |
---|
201 | if (bioAssay == null) |
---|
202 | { |
---|
203 | %> |
---|
204 | <p:pathelement title="<%=HTML.encodeTags(bioAssaySet.getName())%>" /> |
---|
205 | <% |
---|
206 | } |
---|
207 | else |
---|
208 | { |
---|
209 | %> |
---|
210 | <p:pathelement title="<%=HTML.encodeTags(bioAssaySet.getName())%>" |
---|
211 | href="<%="../bioassays/index.jsp?ID="+ID+"&bioassayset_id="+bioAssaySet.getId()%>" /> |
---|
212 | <p:pathelement title="<%=HTML.encodeTags(bioAssay.getName())%>" /> |
---|
213 | <% |
---|
214 | } |
---|
215 | %> |
---|
216 | </p:path> |
---|
217 | |
---|
218 | <t:tabcontrol id="main" active="spotdata" switch="switchTab"> |
---|
219 | <t:tab id="properties.bioassay" title="Properties" visible="<%=bioAssay != null%>"/> |
---|
220 | <t:tab id="properties.bioassayset" title="Properties" visible="<%=bioAssay == null%>"/> |
---|
221 | |
---|
222 | <t:tab id="annotations.bioassay" title="Annotations" |
---|
223 | tooltip="View annotation values" visible="<%=bioAssay != null%>" /> |
---|
224 | <t:tab id="annotations.bioassayset" title="Annotations" |
---|
225 | tooltip="View annotation values" visible="<%=bioAssay == null%>" /> |
---|
226 | |
---|
227 | <t:tab id="bioassays" visible="<%=bioAssay == null%>" title="BioAssays" /> |
---|
228 | <t:tab id="spotdata" title="Spot data" > |
---|
229 | <% |
---|
230 | if (cc.getMessage() != null) |
---|
231 | { |
---|
232 | %> |
---|
233 | <div class="error"><%=cc.getMessage()%></div> |
---|
234 | <% |
---|
235 | cc.setMessage(null); |
---|
236 | } |
---|
237 | %> |
---|
238 | <tbl:table |
---|
239 | id="spotdata" |
---|
240 | |
---|
241 | columns="<%=cc.getSetting("columns")%>" |
---|
242 | sortby="<%=cc.getSortProperty()%>" |
---|
243 | direction="<%=cc.getSortDirection()%>" |
---|
244 | title="<%=title%>" |
---|
245 | action="index.jsp" |
---|
246 | sc="<%=sc%>" |
---|
247 | item="<%=itemType%>" |
---|
248 | subcontext="<%=subContext%>" |
---|
249 | > |
---|
250 | <tbl:hidden |
---|
251 | name="mode" |
---|
252 | value="<%=mode.getName()%>" |
---|
253 | /> |
---|
254 | <tbl:hidden |
---|
255 | name="bioassayset_id" |
---|
256 | value="<%=String.valueOf(bioAssaySetId)%>" |
---|
257 | /> |
---|
258 | <tbl:hidden |
---|
259 | name="bioassay_id" |
---|
260 | value="<%=String.valueOf(bioAssayId)%>" |
---|
261 | /> |
---|
262 | <tbl:hidden |
---|
263 | name="callback" |
---|
264 | value="<%=callback%>" |
---|
265 | skip="<%=callback == null%>" |
---|
266 | /> |
---|
267 | |
---|
268 | <% |
---|
269 | for (TableColumn tc : columns) |
---|
270 | { |
---|
271 | %> |
---|
272 | <tbl:columndef |
---|
273 | id="<%=tc.getId()%>" |
---|
274 | property="<%=tc.getProperty()%>" |
---|
275 | tooltip="<%=tc.getDescription()%>" |
---|
276 | datatype="<%=tc.getDatatype().getStringValue()%>" |
---|
277 | title="<%=HTML.encodeTags(tc.getTitle())%>" |
---|
278 | sortable="<%=tc.getSortable()%>" |
---|
279 | filterable="<%=tc.getFilterable()%>" |
---|
280 | exportable="<%=tc.getExportable()%>" |
---|
281 | show="<%=tc.getShow()%>" |
---|
282 | formatter="<%=tc.getFormatter()%>" |
---|
283 | /> |
---|
284 | <% |
---|
285 | } |
---|
286 | %> |
---|
287 | <% |
---|
288 | if (bioAssay == null) |
---|
289 | { |
---|
290 | Map<Number, String> bioAssayMap = new HashMap<Number, String>(); |
---|
291 | Enumeration<String, String> bioAssayEnum = new Enumeration<String, String>(); |
---|
292 | for (BioAssay ba : bioAssaySet.getBioAssays().list(dc)) |
---|
293 | { |
---|
294 | short columnNo = ba.getDataCubeColumnNo(); |
---|
295 | String linkedBioAssay = Base.getLinkedName(ID, ba, false, true); |
---|
296 | // Safety measure, since JDBC driver seems to return 'short' as 'int' |
---|
297 | bioAssayMap.put(columnNo, linkedBioAssay); |
---|
298 | bioAssayMap.put((int)columnNo, linkedBioAssay); |
---|
299 | bioAssayEnum.add(String.valueOf(columnNo), HTML.encodeTags(ba.getName())); |
---|
300 | } |
---|
301 | %> |
---|
302 | <tbl:columndef |
---|
303 | id="COLUMN" |
---|
304 | property="COLUMN" |
---|
305 | datatype="int" |
---|
306 | title="Bioassay" |
---|
307 | sortable="true" |
---|
308 | filterable="true" |
---|
309 | exportable="true" |
---|
310 | enumeration="<%=bioAssayEnum%>" |
---|
311 | formatter="<%=new LookupFormatter<Number>(bioAssayMap)%>" |
---|
312 | /> |
---|
313 | <% |
---|
314 | } |
---|
315 | %> |
---|
316 | <tbl:columndef |
---|
317 | id="reporterList" |
---|
318 | property="£reporterList" |
---|
319 | datatype="int" |
---|
320 | title="Reporter list" |
---|
321 | filterable="true" |
---|
322 | enumeration="<%=Base.getReporterListsEnum(dc)%>" |
---|
323 | multiple="false" |
---|
324 | /> |
---|
325 | <tbl:toolbar |
---|
326 | visible="<%=mode.hasToolbar()%>" |
---|
327 | > |
---|
328 | <tbl:button |
---|
329 | image="columns.png" |
---|
330 | onclick="configureColumns()" |
---|
331 | title="Columns…" |
---|
332 | tooltip="Show, hide and re-order columns" |
---|
333 | /> |
---|
334 | <tbl:button |
---|
335 | image="add.png" |
---|
336 | onclick="newReporterList()" |
---|
337 | title="New reporter list…" |
---|
338 | tooltip="Create a new reporter list from matching spots" |
---|
339 | visible="<%=sc.hasPermission(Permission.CREATE, Item.REPORTERLIST)%>" |
---|
340 | /> |
---|
341 | <tbl:button |
---|
342 | image="export.png" |
---|
343 | onclick="runPlugin('ExportItems')" |
---|
344 | title="Export…" |
---|
345 | tooltip="Export data" |
---|
346 | visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>" |
---|
347 | /> |
---|
348 | <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" |
---|
349 | wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/> |
---|
350 | </tbl:toolbar> |
---|
351 | <tbl:presetselector |
---|
352 | clazz="columnheader" |
---|
353 | onchange="presetOnChange()" |
---|
354 | /> |
---|
355 | <tbl:navigator |
---|
356 | page="<%=cc.getPage()%>" |
---|
357 | rowsperpage="<%=cc.getRowsPerPage()%>" |
---|
358 | totalrows="<%=spotData == null ? 0 : spotData.getTotalCount()%>" |
---|
359 | visible="<%=mode.hasNavigator()%>" |
---|
360 | /> |
---|
361 | <tbl:data> |
---|
362 | <tbl:headers> |
---|
363 | <tbl:headerrow> |
---|
364 | <tbl:header |
---|
365 | clazz="index" |
---|
366 | colspan="2" |
---|
367 | /> |
---|
368 | <tbl:columnheaders /> |
---|
369 | </tbl:headerrow> |
---|
370 | <tbl:headerrow> |
---|
371 | <tbl:header |
---|
372 | clazz="index" |
---|
373 | colspan="2" |
---|
374 | /> |
---|
375 | <tbl:propertyfilter /> |
---|
376 | </tbl:headerrow> |
---|
377 | </tbl:headers> |
---|
378 | <tbl:rows> |
---|
379 | <% |
---|
380 | int index = cc.getPage()*cc.getRowsPerPage(); |
---|
381 | int selectedItemId = cc.getId(); |
---|
382 | if (spotData != null) |
---|
383 | { |
---|
384 | while (spotData.hasNext()) |
---|
385 | { |
---|
386 | SqlResult item = spotData.next(); |
---|
387 | index++; |
---|
388 | numListed++; |
---|
389 | %> |
---|
390 | <tbl:row> |
---|
391 | <tbl:header |
---|
392 | clazz="index" |
---|
393 | ><%=index%></tbl:header> |
---|
394 | <tbl:header |
---|
395 | clazz="icons" |
---|
396 | visible="<%=mode.hasIcons()%>" |
---|
397 | > </tbl:header> |
---|
398 | <% |
---|
399 | int i = 1; |
---|
400 | for (String columnId : selected.selectedIds) |
---|
401 | { |
---|
402 | %> |
---|
403 | <tbl:cell column="<%=columnId%>" value="<%=item.getObject(i++)%>" /> |
---|
404 | <% |
---|
405 | } |
---|
406 | %> |
---|
407 | </tbl:row> |
---|
408 | <% |
---|
409 | } |
---|
410 | } |
---|
411 | %> |
---|
412 | </tbl:rows> |
---|
413 | </tbl:data> |
---|
414 | <% |
---|
415 | if (numListed == 0) |
---|
416 | { |
---|
417 | %> |
---|
418 | <tbl:panel><%=spotData == null || spotData.getTotalCount() == 0 ? "No spot data were found" : "No spot data on this page. Please select another page!" %></tbl:panel> |
---|
419 | <% |
---|
420 | } |
---|
421 | else |
---|
422 | { |
---|
423 | %> |
---|
424 | <tbl:navigator |
---|
425 | page="<%=cc.getPage()%>" |
---|
426 | rowsperpage="<%=cc.getRowsPerPage()%>" |
---|
427 | totalrows="<%=spotData == null ? 0 : spotData.getTotalCount()%>" |
---|
428 | visible="<%=mode.hasNavigator()%>" |
---|
429 | locked="true" |
---|
430 | /> |
---|
431 | <% |
---|
432 | } |
---|
433 | %> |
---|
434 | </tbl:table> |
---|
435 | <base:buttongroup> |
---|
436 | <base:button onclick="returnSelected();" title="Ok" visible="<%=mode.hasOkButton()%>" /> |
---|
437 | <base:button onclick="window.close();" title="Cancel" visible="<%=mode.hasCancelButton()%>" /> |
---|
438 | <base:button onclick="window.close();" title="Close" visible="<%=mode.hasCloseButton()%>" /> |
---|
439 | </base:buttongroup> |
---|
440 | </t:tab> |
---|
441 | |
---|
442 | <t:tab id="overviewplots" title="Overview plots" |
---|
443 | visible="<%=overviewPlotInvoker != null && overviewPlotInvoker.getNumExtensions() > 0%>" |
---|
444 | /> |
---|
445 | </t:tabcontrol> |
---|
446 | |
---|
447 | </base:body> |
---|
448 | </base:page> |
---|
449 | <% |
---|
450 | } |
---|
451 | finally |
---|
452 | { |
---|
453 | if (dc != null) dc.close(); |
---|
454 | } |
---|
455 | %> |
---|