1 | <%-- $Id: list.jsp 5952 2012-02-10 12:27:27Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2006 Johan Enell, 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.ItemContext" |
---|
31 | import="net.sf.basedb.core.Permission" |
---|
32 | import="net.sf.basedb.core.BioAssaySet" |
---|
33 | import="net.sf.basedb.core.Experiment" |
---|
34 | import="net.sf.basedb.core.RawDataType" |
---|
35 | import="net.sf.basedb.core.ExtendedProperties" |
---|
36 | import="net.sf.basedb.core.ExtendedProperty" |
---|
37 | import="net.sf.basedb.core.DynamicReporterQuery" |
---|
38 | import="net.sf.basedb.core.DynamicResultIterator" |
---|
39 | import="net.sf.basedb.core.VirtualColumn" |
---|
40 | import="net.sf.basedb.core.data.ReporterData" |
---|
41 | import="net.sf.basedb.core.query.Restrictions" |
---|
42 | import="net.sf.basedb.core.query.Expressions" |
---|
43 | import="net.sf.basedb.core.query.Dynamic" |
---|
44 | import="net.sf.basedb.core.query.Orders" |
---|
45 | import="net.sf.basedb.core.query.Selects" |
---|
46 | import="net.sf.basedb.core.query.Aggregations" |
---|
47 | import="net.sf.basedb.core.query.JoinType" |
---|
48 | import="net.sf.basedb.core.query.SqlResult" |
---|
49 | import="net.sf.basedb.clients.web.Base" |
---|
50 | import="net.sf.basedb.clients.web.DynamicUtil" |
---|
51 | import="net.sf.basedb.clients.web.ExperimentExplorer" |
---|
52 | import="net.sf.basedb.clients.web.WebException" |
---|
53 | import="net.sf.basedb.util.Values" |
---|
54 | import="net.sf.basedb.clients.web.util.HTML" |
---|
55 | import="net.sf.basedb.clients.web.taglib.table.TableColumn" |
---|
56 | import="java.util.Date" |
---|
57 | import="java.util.Map" |
---|
58 | import="java.util.HashMap" |
---|
59 | import="java.util.List" |
---|
60 | import="java.util.LinkedList" |
---|
61 | %> |
---|
62 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
63 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
64 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
65 | <%@ taglib prefix="p" uri="/WEB-INF/path.tld" %> |
---|
66 | <%! |
---|
67 | private static final Item itemType = Item.REPORTER; |
---|
68 | %> |
---|
69 | |
---|
70 | <% |
---|
71 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
72 | final String ID = sc.getId(); |
---|
73 | final float scale = Base.getScale(sc); |
---|
74 | final String root = request.getContextPath(); |
---|
75 | |
---|
76 | final int bioAssaySetId = Values.getInt(request.getParameter("bioassayset_id")); |
---|
77 | final DbControl dc = sc.newDbControl(); |
---|
78 | DynamicResultIterator reporters = null; |
---|
79 | long totalReporters = 0; |
---|
80 | try |
---|
81 | { |
---|
82 | String title = null; |
---|
83 | final BioAssaySet bioAssaySet = BioAssaySet.getById(dc, bioAssaySetId); |
---|
84 | final Experiment experiment = bioAssaySet.getExperiment(); |
---|
85 | final RawDataType rawDataType = experiment.getRawDataType(); |
---|
86 | |
---|
87 | final ExperimentExplorer explorer = ExperimentExplorer.getExplorer(bioAssaySet); |
---|
88 | final ItemContext cc = explorer.getAndSetReporterContext(sc, null); |
---|
89 | final String subContext = cc.getSubContext(); |
---|
90 | |
---|
91 | List<TableColumn> allColumns = new LinkedList<TableColumn>(); |
---|
92 | DynamicUtil.addReporterColumns(allColumns, dc, experiment.getVirtualDb().getReporterCloneTemplate(), "", "@", ""); |
---|
93 | |
---|
94 | DynamicUtil.SelectedInfo selected = DynamicUtil.getSelectedColumns(cc, allColumns, false); |
---|
95 | List<TableColumn> selectedColumns = selected.selectedColumns; |
---|
96 | |
---|
97 | try |
---|
98 | { |
---|
99 | DynamicReporterQuery reporterQuery = explorer.getReporterQuery(dc, selected.selectedProperties); |
---|
100 | reporterQuery.setFailSafe(true); |
---|
101 | totalReporters = explorer.getMatchingReporters(dc); |
---|
102 | reporters = reporterQuery.iterate(dc); |
---|
103 | } |
---|
104 | catch (Throwable t) |
---|
105 | { |
---|
106 | cc.setMessage(t.getMessage()); |
---|
107 | t.printStackTrace(); |
---|
108 | } |
---|
109 | int numListed = 0; |
---|
110 | %> |
---|
111 | |
---|
112 | <base:page title="<%=title%>"> |
---|
113 | <base:head scripts="table.js,tabcontrol.js,newjoust.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css,newjoust.css"> |
---|
114 | <script language="JavaScript"> |
---|
115 | var submitPage = 'index.jsp'; |
---|
116 | var formId = 'reporters'; |
---|
117 | function editItem(itemId) |
---|
118 | { |
---|
119 | Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', itemId, true); |
---|
120 | } |
---|
121 | function viewItem(itemId) |
---|
122 | { |
---|
123 | Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', itemId, false); |
---|
124 | } |
---|
125 | function itemOnClick(evt, itemId) |
---|
126 | { |
---|
127 | Table.itemOnClick(formId, evt, itemId, 'DEFAULT', viewItem, editItem, null); |
---|
128 | } |
---|
129 | function configureColumns() |
---|
130 | { |
---|
131 | Table.configureColumns('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>', '<%=subContext%>'); |
---|
132 | } |
---|
133 | function presetOnChange() |
---|
134 | { |
---|
135 | Table.presetOnChange('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>', '<%=subContext%>'); |
---|
136 | } |
---|
137 | function viewReporter(index) |
---|
138 | { |
---|
139 | var url = '../view/index.jsp?ID=<%=ID%>&bioassayset_id=<%=bioAssaySetId%>'; |
---|
140 | if (index >= 0) |
---|
141 | { |
---|
142 | url += '&cmd=SetReporterIndex&reporterIndex='+index; |
---|
143 | } |
---|
144 | location.href = url; |
---|
145 | } |
---|
146 | |
---|
147 | function switchTab(tabControlId, tabId) |
---|
148 | { |
---|
149 | if (tabId == 'view') |
---|
150 | { |
---|
151 | viewReporter(-1); |
---|
152 | } |
---|
153 | else |
---|
154 | { |
---|
155 | TabControl.setActiveTab(tabControlId, tabId); |
---|
156 | } |
---|
157 | } |
---|
158 | function newReporterList() |
---|
159 | { |
---|
160 | Table.submitToPopup(formId, 'CreateReporterList', 600, 400); |
---|
161 | } |
---|
162 | </script> |
---|
163 | </base:head> |
---|
164 | <base:body> |
---|
165 | <p:path><p:pathelement |
---|
166 | title="Experiments" href="<%="../../index.jsp?ID="+ID%>" |
---|
167 | /><p:pathelement title="<%=HTML.encodeTags(experiment.getName())%>" |
---|
168 | href="<%="../../bioassaysets/index.jsp?ID="+ID+"&experiment_id="+experiment.getId()%>" |
---|
169 | /><p:pathelement title="<%=HTML.encodeTags(bioAssaySet.getName())%>" |
---|
170 | href="<%="../../bioassaysets/index.jsp?ID="+ID+"&cmd=ViewItem&item_id="+bioAssaySetId%>" |
---|
171 | /><p:pathelement title="Explorer" /></p:path> |
---|
172 | <t:tabcontrol |
---|
173 | id="explorer" |
---|
174 | subclass="mastertabcontrol content" |
---|
175 | switch="switchTab" remember="false" active="search"> |
---|
176 | <t:tab id="search" title="Reporter search"> |
---|
177 | <tbl:table |
---|
178 | id="reporters" |
---|
179 | columns="<%=cc.getSetting("columns")%>" |
---|
180 | sortby="<%=cc.getSortProperty()%>" |
---|
181 | direction="<%=cc.getSortDirection()%>" |
---|
182 | action="index.jsp" |
---|
183 | sc="<%=sc%>" |
---|
184 | item="<%=itemType%>" |
---|
185 | subcontext="<%=subContext%>" |
---|
186 | subclass="fulltable" |
---|
187 | > |
---|
188 | <tbl:hidden |
---|
189 | name="bioassayset_id" |
---|
190 | value="<%=String.valueOf(bioAssaySetId)%>" |
---|
191 | /> |
---|
192 | <% |
---|
193 | for (TableColumn tc : allColumns) |
---|
194 | { |
---|
195 | %> |
---|
196 | <tbl:columndef |
---|
197 | id="<%=tc.getId()%>" |
---|
198 | clazz="<%="externalId".equals(tc.getId()) ? "uniquecol" : "columnheader"%>" |
---|
199 | property="<%=tc.getProperty()%>" |
---|
200 | datatype="<%=tc.getDatatype().getStringValue()%>" |
---|
201 | title="<%=tc.getTitle()%>" |
---|
202 | sortable="<%=tc.getSortable()%>" |
---|
203 | filterable="<%=tc.getFilterable()%>" |
---|
204 | exportable="<%=tc.getExportable()%>" |
---|
205 | show="<%=tc.getShow()%>" |
---|
206 | formatter="<%=tc.getFormatter()%>" |
---|
207 | /> |
---|
208 | <% |
---|
209 | } |
---|
210 | %> |
---|
211 | <tbl:columndef |
---|
212 | id="reporterList" |
---|
213 | property="£reporterList" |
---|
214 | datatype="int" |
---|
215 | title="Reporter list" |
---|
216 | filterable="true" |
---|
217 | enumeration="<%=Base.getReporterListsEnum(dc)%>" |
---|
218 | multiple="false" |
---|
219 | /> |
---|
220 | |
---|
221 | <div class="panelgroup bottomborder"> |
---|
222 | <tbl:toolbar subclass="bottomborder"> |
---|
223 | <tbl:button |
---|
224 | image="columns.png" |
---|
225 | onclick="configureColumns()" |
---|
226 | title="Columns…" |
---|
227 | tooltip="Show, hide and re-order columns" |
---|
228 | /> |
---|
229 | <tbl:button |
---|
230 | image="add.png" |
---|
231 | onclick="newReporterList()" |
---|
232 | title="New reporter list…" |
---|
233 | tooltip="Create a new reporter list from matching reporters" |
---|
234 | visible="<%=sc.hasPermission(Permission.CREATE, Item.REPORTERLIST)%>" |
---|
235 | /> |
---|
236 | </tbl:toolbar> |
---|
237 | <tbl:panel> |
---|
238 | <tbl:presetselector |
---|
239 | onchange="presetOnChange()" |
---|
240 | /> |
---|
241 | <tbl:navigator |
---|
242 | page="<%=cc.getPage()%>" |
---|
243 | rowsperpage="<%=cc.getRowsPerPage()%>" |
---|
244 | totalrows="<%=totalReporters%>" |
---|
245 | /> |
---|
246 | </tbl:panel> |
---|
247 | </div> |
---|
248 | <tbl:data> |
---|
249 | <tbl:headers> |
---|
250 | <tbl:headerrow> |
---|
251 | <tbl:header clazz="icons"/> |
---|
252 | <tbl:columnheaders /> |
---|
253 | </tbl:headerrow> |
---|
254 | <tbl:headerrow> |
---|
255 | <tbl:header clazz="icons"/> |
---|
256 | <tbl:propertyfilter /> |
---|
257 | </tbl:headerrow> |
---|
258 | </tbl:headers> |
---|
259 | <tbl:rows> |
---|
260 | <% |
---|
261 | if (cc.getMessage() != null) |
---|
262 | { |
---|
263 | %> |
---|
264 | <tbl:panel clazz="messagepanel"> |
---|
265 | <div class="messagecontainer error"><%=cc.getMessage()%></div> |
---|
266 | </tbl:panel> |
---|
267 | <% |
---|
268 | cc.setMessage(null); |
---|
269 | } |
---|
270 | int rowIndex = cc.getPage()*cc.getRowsPerPage(); |
---|
271 | if (reporters != null) |
---|
272 | { |
---|
273 | while (reporters.hasNext()) |
---|
274 | { |
---|
275 | SqlResult item = reporters.next(); |
---|
276 | int itemId = item.getInt(1); |
---|
277 | rowIndex++; |
---|
278 | numListed++; |
---|
279 | %> |
---|
280 | <tbl:row> |
---|
281 | <tbl:header |
---|
282 | clazz="icons" |
---|
283 | ><a href="javascript:viewReporter(<%=rowIndex-1%>)"><%=rowIndex%></a></tbl:header> |
---|
284 | <% |
---|
285 | int colIndex = 2; |
---|
286 | for (TableColumn tc : selectedColumns) |
---|
287 | { |
---|
288 | String name = tc.getId(); |
---|
289 | if ("externalId".equals(name)) |
---|
290 | { |
---|
291 | %> |
---|
292 | <tbl:cell column="externalId"><div class="link" onclick="itemOnClick(event, <%=itemId%>)" |
---|
293 | title="View this item (use CTRL, ALT or SHIFT to edit)"><%=HTML.encodeTags(item.getString(colIndex))%></div></tbl:cell> |
---|
294 | <% |
---|
295 | } |
---|
296 | else |
---|
297 | { |
---|
298 | %> |
---|
299 | <tbl:cell column="<%=name%>"><tbl:cellvalue value="<%=item.getObject(colIndex)%>" /></tbl:cell> |
---|
300 | <% |
---|
301 | } |
---|
302 | colIndex++; |
---|
303 | } |
---|
304 | %> |
---|
305 | </tbl:row> |
---|
306 | <% |
---|
307 | } |
---|
308 | } |
---|
309 | if (numListed == 0) |
---|
310 | { |
---|
311 | %> |
---|
312 | <tbl:panel clazz="messagepanel"> |
---|
313 | <div class="messagecontainer note"> |
---|
314 | <%=totalReporters == 0 ? "No reporters were found" : "No reporters on this page. Please select another page!" %> |
---|
315 | </div> |
---|
316 | </tbl:panel> |
---|
317 | <% |
---|
318 | } |
---|
319 | %> |
---|
320 | </tbl:rows> |
---|
321 | </tbl:data> |
---|
322 | </tbl:table> |
---|
323 | </t:tab> |
---|
324 | |
---|
325 | <t:tab id="view" title="Reporter view" /> |
---|
326 | </t:tabcontrol> |
---|
327 | |
---|
328 | </base:body> |
---|
329 | </base:page> |
---|
330 | <% |
---|
331 | } |
---|
332 | finally |
---|
333 | { |
---|
334 | if (reporters != null) reporters.close(); |
---|
335 | if (dc != null) dc.close(); |
---|
336 | } |
---|
337 | |
---|
338 | %> |
---|