1 | <%-- $Id: list_reporters.jsp 5952 2012-02-10 12:27:27Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2011 Nicklas Nordborg |
---|
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 pageEncoding="UTF-8" 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.core.Type" |
---|
28 | import="net.sf.basedb.core.ItemContext" |
---|
29 | import="net.sf.basedb.core.Permission" |
---|
30 | import="net.sf.basedb.core.Experiment" |
---|
31 | import="net.sf.basedb.core.VirtualDb" |
---|
32 | import="net.sf.basedb.core.BaseException" |
---|
33 | import="net.sf.basedb.core.DynamicReporterQuery" |
---|
34 | import="net.sf.basedb.core.Reporter" |
---|
35 | import="net.sf.basedb.core.DynamicResultIterator" |
---|
36 | import="net.sf.basedb.core.PluginDefinition" |
---|
37 | import="net.sf.basedb.core.Formula" |
---|
38 | import="net.sf.basedb.core.IntensityTransform" |
---|
39 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
40 | import="net.sf.basedb.core.plugin.Plugin" |
---|
41 | import="net.sf.basedb.core.query.Expressions" |
---|
42 | import="net.sf.basedb.core.query.Restrictions" |
---|
43 | import="net.sf.basedb.core.query.Selects" |
---|
44 | import="net.sf.basedb.core.query.Dynamic" |
---|
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.ChangeHistoryUtil" |
---|
51 | import="net.sf.basedb.clients.web.ModeInfo" |
---|
52 | import="net.sf.basedb.clients.web.DynamicUtil" |
---|
53 | import="net.sf.basedb.clients.web.WebException" |
---|
54 | import="net.sf.basedb.clients.web.util.HTML" |
---|
55 | import="net.sf.basedb.util.Values" |
---|
56 | import="net.sf.basedb.clients.web.taglib.table.TableColumn" |
---|
57 | import="java.util.Map" |
---|
58 | import="java.util.HashMap" |
---|
59 | import="java.util.List" |
---|
60 | import="java.util.LinkedList" |
---|
61 | import="java.util.ArrayList" |
---|
62 | import="java.util.Set" |
---|
63 | import="java.util.HashSet" |
---|
64 | import="java.util.Arrays" |
---|
65 | %> |
---|
66 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
67 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
68 | <%@ taglib prefix="p" uri="/WEB-INF/path.tld" %> |
---|
69 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
70 | <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
---|
71 | <%! |
---|
72 | private static final Item itemType = Item.REPORTER; |
---|
73 | private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST); |
---|
74 | %> |
---|
75 | <% |
---|
76 | final int experimentId = Values.getInt(request.getParameter("experiment_id")); |
---|
77 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
78 | final String ID = sc.getId(); |
---|
79 | |
---|
80 | final ModeInfo mode = ModeInfo.get(request.getParameter("mode")); |
---|
81 | final String callback = request.getParameter("callback"); |
---|
82 | final String title = mode.generateTitle("spot data", "spot data"); |
---|
83 | final DbControl dc = sc.newDbControl(); |
---|
84 | DynamicResultIterator reporters = null; |
---|
85 | try |
---|
86 | { |
---|
87 | final Experiment experiment = Experiment.getById(dc, experimentId); |
---|
88 | final String subContext = "clonedreporters." + experimentId; |
---|
89 | final boolean writePermission = experiment.hasPermission(Permission.WRITE); |
---|
90 | VirtualDb virtualDb = experiment.getVirtualDb(); |
---|
91 | if (!virtualDb.hasClonedReporters()) |
---|
92 | { |
---|
93 | response.sendRedirect("../index.jsp?ID="+ID + "&cmd=ViewItem&item_id="+experimentId); |
---|
94 | return; |
---|
95 | } |
---|
96 | |
---|
97 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, subContext, null, null); |
---|
98 | Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); |
---|
99 | |
---|
100 | List<TableColumn> columns = new LinkedList<TableColumn>(); |
---|
101 | DynamicUtil.addReporterColumns(columns, dc, experiment.getVirtualDb().getReporterCloneTemplate(), "cln.", "@", "[Cln] "); |
---|
102 | DynamicUtil.addReporterColumns(columns, dc, "mst.", "@@", "[Mst] "); |
---|
103 | DynamicUtil.SelectedInfo selected = DynamicUtil.getSelectedColumns(cc, columns, false); |
---|
104 | final boolean hasUpToDateColumn = true; |
---|
105 | try |
---|
106 | { |
---|
107 | final DynamicReporterQuery query = Reporter.getDynamicQuery(experiment); |
---|
108 | query.select(Selects.expression(Dynamic.reporter("id"), "id", true)); |
---|
109 | if (hasUpToDateColumn) |
---|
110 | { |
---|
111 | query.select( |
---|
112 | Selects.expression( |
---|
113 | Expressions.bool(Restrictions.eq(Dynamic.reporter("version", true), Dynamic.reporter("version", false))), |
---|
114 | "upToDate" |
---|
115 | )); |
---|
116 | } |
---|
117 | cc.configureQuery(dc, query, selected.selectedProperties); |
---|
118 | query.setFailSafe(true); |
---|
119 | reporters = query.iterate(dc); |
---|
120 | } |
---|
121 | catch (Throwable t) |
---|
122 | { |
---|
123 | cc.setMessage(t.getMessage()); |
---|
124 | t.printStackTrace(); |
---|
125 | } |
---|
126 | int numListed = 0; |
---|
127 | %> |
---|
128 | <base:page title="<%=title%>"> |
---|
129 | <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css"> |
---|
130 | <script language="JavaScript"> |
---|
131 | var submitPage = 'index.jsp'; |
---|
132 | var formId = 'reporters'; |
---|
133 | function editItem(itemId) |
---|
134 | { |
---|
135 | Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', itemId, true); |
---|
136 | } |
---|
137 | function viewItem(itemId) |
---|
138 | { |
---|
139 | Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', itemId, false); |
---|
140 | } |
---|
141 | function itemOnClick(evt, itemId) |
---|
142 | { |
---|
143 | Table.itemOnClick(formId, evt, itemId, 'DEFAULT', viewItem, editItem, null); |
---|
144 | } |
---|
145 | function configureColumns() |
---|
146 | { |
---|
147 | Table.configureColumns('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>', '<%=subContext%>'); |
---|
148 | } |
---|
149 | function presetOnChange() |
---|
150 | { |
---|
151 | Table.presetOnChange('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>', '<%=subContext%>'); |
---|
152 | } |
---|
153 | function runPlugin(cmd) |
---|
154 | { |
---|
155 | Table.submitToPopup(formId, cmd, 750, 500); |
---|
156 | } |
---|
157 | function switchTab(tabControlId, tabId) |
---|
158 | { |
---|
159 | if (tabId == 'properties' || tabId == 'overview' || tabId == 'history') |
---|
160 | { |
---|
161 | location.href = '../index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=experimentId%>&tab='+tabId; |
---|
162 | } |
---|
163 | else if (tabId == 'bioassaysets') |
---|
164 | { |
---|
165 | viewBioAssaySets(); |
---|
166 | } |
---|
167 | else |
---|
168 | { |
---|
169 | TabControl.setActiveTab(tabControlId, tabId); |
---|
170 | } |
---|
171 | } |
---|
172 | function viewBioAssaySets() |
---|
173 | { |
---|
174 | location.href = '../bioassaysets/index.jsp?ID=<%=ID%>&experiment_id=<%=experimentId%>'; |
---|
175 | } |
---|
176 | function newReporterList() |
---|
177 | { |
---|
178 | Table.submitToPopup(formId, 'CreateReporterList', 600, 400); |
---|
179 | } |
---|
180 | function removeClonedReporters() |
---|
181 | { |
---|
182 | if (confirm('Are you sure that you want to remove all cloned reporter annotations?\nThis action can\'t be undone.')) |
---|
183 | { |
---|
184 | Main.openPopup('../index.jsp?ID=<%=ID%>&cmd=RemoveClonedReporters&item_id=<%=experimentId%>', 'RemoveClonedReporters', 450, 300); |
---|
185 | } |
---|
186 | } |
---|
187 | function updateClonedReporters() |
---|
188 | { |
---|
189 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd=UpdateClonedReporters&experiment_id=<%=experimentId%>', 'UpdateClonedReporters', 600, 400); |
---|
190 | } |
---|
191 | </script> |
---|
192 | </base:head> |
---|
193 | <base:body> |
---|
194 | <p:path><p:pathelement |
---|
195 | title="Experiments" href="<%="../index.jsp?ID="+ID%>" |
---|
196 | /><p:pathelement title="<%=HTML.encodeTags(experiment.getName())%>" |
---|
197 | /></p:path> |
---|
198 | |
---|
199 | <t:tabcontrol |
---|
200 | id="main" |
---|
201 | subclass="mastertabcontrol content" |
---|
202 | active="clonedreporters" switch="switchTab"> |
---|
203 | <t:tab id="properties" title="Properties" /> |
---|
204 | <t:tab id="bioassaysets" title="Bioassay sets" /> |
---|
205 | |
---|
206 | <t:tab id="clonedreporters" title="Cloned reporters" > |
---|
207 | <tbl:table |
---|
208 | id="reporters" |
---|
209 | columns="<%=cc.getSetting("columns")%>" |
---|
210 | sortby="<%=cc.getSortProperty()%>" |
---|
211 | direction="<%=cc.getSortDirection()%>" |
---|
212 | action="index.jsp" |
---|
213 | sc="<%=sc%>" |
---|
214 | item="<%=itemType%>" |
---|
215 | subcontext="<%=subContext%>" |
---|
216 | subclass="fulltable" |
---|
217 | > |
---|
218 | <tbl:hidden |
---|
219 | name="mode" |
---|
220 | value="<%=mode.getName()%>" |
---|
221 | /> |
---|
222 | <tbl:hidden |
---|
223 | name="experiment_id" |
---|
224 | value="<%=String.valueOf(experimentId)%>" |
---|
225 | /> |
---|
226 | <tbl:hidden |
---|
227 | name="callback" |
---|
228 | value="<%=callback%>" |
---|
229 | skip="<%=callback == null%>" |
---|
230 | /> |
---|
231 | <% |
---|
232 | for (TableColumn tc : columns) |
---|
233 | { |
---|
234 | %> |
---|
235 | <tbl:columndef |
---|
236 | id="<%=tc.getId()%>" |
---|
237 | property="<%=tc.getProperty()%>" |
---|
238 | tooltip="<%=tc.getDescription()%>" |
---|
239 | datatype="<%=tc.getDatatype().getStringValue()%>" |
---|
240 | title="<%=HTML.encodeTags(tc.getTitle())%>" |
---|
241 | sortable="<%=tc.getSortable()%>" |
---|
242 | filterable="<%=tc.getFilterable()%>" |
---|
243 | exportable="<%=tc.getExportable()%>" |
---|
244 | show="<%="cln.externalId".equals(tc.getId()) ? "always" : tc.getShow()%>" |
---|
245 | formatter="<%=tc.getFormatter()%>" |
---|
246 | /> |
---|
247 | <% |
---|
248 | } |
---|
249 | %> |
---|
250 | <tbl:columndef |
---|
251 | id="upToDate" |
---|
252 | property="upToDate" |
---|
253 | filterproperty="=rep('version') == mrep('version')" |
---|
254 | exportproperty="=rep('version') == mrep('version')" |
---|
255 | datatype="boolean" |
---|
256 | title="Up to date" |
---|
257 | filterable="true" |
---|
258 | exportable="true" |
---|
259 | /> |
---|
260 | <tbl:columndef |
---|
261 | id="reporterList" |
---|
262 | property="£reporterList" |
---|
263 | datatype="int" |
---|
264 | title="Reporter list" |
---|
265 | filterable="true" |
---|
266 | enumeration="<%=Base.getReporterListsEnum(dc)%>" |
---|
267 | multiple="false" |
---|
268 | /> |
---|
269 | <div class="panelgroup bottomborder"> |
---|
270 | <tbl:toolbar |
---|
271 | subclass="bottomborder" |
---|
272 | visible="<%=mode.hasToolbar()%>" |
---|
273 | > |
---|
274 | <tbl:button |
---|
275 | image="columns.png" |
---|
276 | onclick="configureColumns()" |
---|
277 | title="Columns…" |
---|
278 | tooltip="Show, hide and re-order columns" |
---|
279 | /> |
---|
280 | <tbl:button |
---|
281 | image="add.png" |
---|
282 | onclick="newReporterList()" |
---|
283 | title="New reporter list…" |
---|
284 | tooltip="Create a new reporter list from matching spots" |
---|
285 | visible="<%=sc.hasPermission(Permission.CREATE, Item.REPORTERLIST)%>" |
---|
286 | /> |
---|
287 | <tbl:button |
---|
288 | visible="<%=writePermission%>" |
---|
289 | image="refresh.png" |
---|
290 | onclick="updateClonedReporters()" |
---|
291 | title="Update cloned reporters…" |
---|
292 | tooltip="Update all cloned reporter annotations with information from the master table" |
---|
293 | /> |
---|
294 | <tbl:button |
---|
295 | visible="<%=writePermission%>" |
---|
296 | image="delete_permanently.png" |
---|
297 | onclick="removeClonedReporters()" |
---|
298 | title="Remove cloned reporters…" |
---|
299 | tooltip="Remove all cloned reporter annotations" |
---|
300 | /> |
---|
301 | <tbl:button |
---|
302 | image="export.png" |
---|
303 | onclick="runPlugin('ExportItems')" |
---|
304 | title="Export…" |
---|
305 | tooltip="Export data" |
---|
306 | visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>" |
---|
307 | /> |
---|
308 | </tbl:toolbar> |
---|
309 | <tbl:panel> |
---|
310 | <tbl:presetselector |
---|
311 | onchange="presetOnChange()" |
---|
312 | /> |
---|
313 | <tbl:navigator |
---|
314 | page="<%=cc.getPage()%>" |
---|
315 | rowsperpage="<%=cc.getRowsPerPage()%>" |
---|
316 | totalrows="<%=reporters == null ? 0 : reporters.getTotalCount()%>" |
---|
317 | visible="<%=mode.hasNavigator()%>" |
---|
318 | /> |
---|
319 | </tbl:panel> |
---|
320 | </div> |
---|
321 | <tbl:data> |
---|
322 | <tbl:headers> |
---|
323 | <tbl:headerrow> |
---|
324 | <tbl:header |
---|
325 | clazz="index" |
---|
326 | colspan="2" |
---|
327 | /> |
---|
328 | <tbl:columnheaders /> |
---|
329 | </tbl:headerrow> |
---|
330 | <tbl:headerrow> |
---|
331 | <tbl:header |
---|
332 | clazz="index" |
---|
333 | colspan="2" |
---|
334 | /> |
---|
335 | <tbl:propertyfilter /> |
---|
336 | </tbl:headerrow> |
---|
337 | </tbl:headers> |
---|
338 | <tbl:rows> |
---|
339 | <% |
---|
340 | if (cc.getMessage() != null) |
---|
341 | { |
---|
342 | %> |
---|
343 | <tbl:panel clazz="messagepanel"> |
---|
344 | <div class="messagecontainer error"><%=cc.getMessage()%></div> |
---|
345 | </tbl:panel> |
---|
346 | <% |
---|
347 | cc.setMessage(null); |
---|
348 | } |
---|
349 | int index = cc.getPage()*cc.getRowsPerPage(); |
---|
350 | int selectedItemId = cc.getId(); |
---|
351 | if (reporters != null) |
---|
352 | { |
---|
353 | while (reporters.hasNext()) |
---|
354 | { |
---|
355 | SqlResult item = reporters.next(); |
---|
356 | int itemId = item.getInt(1); |
---|
357 | index++; |
---|
358 | numListed++; |
---|
359 | %> |
---|
360 | <tbl:row> |
---|
361 | <tbl:header |
---|
362 | clazz="index" |
---|
363 | ><%=index%></tbl:header> |
---|
364 | <tbl:header |
---|
365 | clazz="icons" |
---|
366 | visible="<%=mode.hasIcons()%>" |
---|
367 | > </tbl:header> |
---|
368 | <tbl:cell column="upToDate" visible="<%=hasUpToDateColumn %>"> |
---|
369 | <%=item.getObject(2) %> |
---|
370 | </tbl:cell> |
---|
371 | <% |
---|
372 | int colIndex = hasUpToDateColumn ? 3 : 2; |
---|
373 | for (String columnId : selected.selectedIds) |
---|
374 | { |
---|
375 | if ("cln.externalId".equals(columnId)) |
---|
376 | { |
---|
377 | %> |
---|
378 | <tbl:cell column="cln.externalId"><div class="link" onclick="itemOnClick(event, <%=itemId%>)" |
---|
379 | title="View this item (use CTRL, ALT or SHIFT to edit)"><%=HTML.encodeTags(item.getString(colIndex))%></div></tbl:cell> |
---|
380 | <% |
---|
381 | } |
---|
382 | else |
---|
383 | { |
---|
384 | %> |
---|
385 | <tbl:cell column="<%=columnId%>" value="<%=item.getObject(colIndex)%>" /> |
---|
386 | <% |
---|
387 | } |
---|
388 | ++colIndex; |
---|
389 | } |
---|
390 | %> |
---|
391 | </tbl:row> |
---|
392 | <% |
---|
393 | } |
---|
394 | } |
---|
395 | if (numListed == 0) |
---|
396 | { |
---|
397 | %> |
---|
398 | <tbl:panel clazz="messagepanel"> |
---|
399 | <div class="messagecontainer note"> |
---|
400 | <%=reporters == null || reporters.getTotalCount() == 0 ? "No reporters were found" : "No reporters on this page. Please select another page!" %> |
---|
401 | </div> |
---|
402 | </tbl:panel> |
---|
403 | <% |
---|
404 | } |
---|
405 | %> |
---|
406 | </tbl:rows> |
---|
407 | </tbl:data> |
---|
408 | </tbl:table> |
---|
409 | </t:tab> |
---|
410 | |
---|
411 | <t:tab id="overview" title="Overview" |
---|
412 | tooltip="Display a tree overview of related items" /> |
---|
413 | <t:tab id="history" title="Change history" |
---|
414 | tooltip="Displays a log of all modifications made to this item" |
---|
415 | visible="<%=ChangeHistoryUtil.showChangeHistoryTab(sc)%>" /> |
---|
416 | </t:tabcontrol> |
---|
417 | |
---|
418 | <base:buttongroup> |
---|
419 | <base:button onclick="returnSelected();" title="Ok" visible="<%=mode.hasOkButton()%>" /> |
---|
420 | <base:button onclick="window.close();" title="Cancel" visible="<%=mode.hasCancelButton()%>" /> |
---|
421 | <base:button onclick="window.close();" title="Close" visible="<%=mode.hasCloseButton()%>" /> |
---|
422 | </base:buttongroup> |
---|
423 | |
---|
424 | </base:body> |
---|
425 | </base:page> |
---|
426 | <% |
---|
427 | } |
---|
428 | finally |
---|
429 | { |
---|
430 | if (dc != null) dc.close(); |
---|
431 | } |
---|
432 | %> |
---|