1 | <%-- $Id: view_bioassay.jsp 6909 2015-05-18 06:48:30Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2006 Jari Häkkinen, 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 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 | @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.Experiment" |
---|
33 | import="net.sf.basedb.core.RawBioAssay" |
---|
34 | import="net.sf.basedb.core.RootRawBioAssay" |
---|
35 | import="net.sf.basedb.core.Type" |
---|
36 | import="net.sf.basedb.core.Unit" |
---|
37 | import="net.sf.basedb.core.Annotatable" |
---|
38 | import="net.sf.basedb.core.AnnotationSet" |
---|
39 | import="net.sf.basedb.core.AnnotationType" |
---|
40 | import="net.sf.basedb.core.Annotation" |
---|
41 | import="net.sf.basedb.core.ItemQuery" |
---|
42 | import="net.sf.basedb.core.ItemResultList" |
---|
43 | import="net.sf.basedb.core.Include" |
---|
44 | import="net.sf.basedb.core.BaseException" |
---|
45 | import="net.sf.basedb.core.PluginDefinition" |
---|
46 | import="net.sf.basedb.core.ItemSubtype" |
---|
47 | import="net.sf.basedb.core.Subtypable" |
---|
48 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
49 | import="net.sf.basedb.core.Nameable" |
---|
50 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
51 | import="net.sf.basedb.core.plugin.Plugin" |
---|
52 | import="net.sf.basedb.core.query.Orders" |
---|
53 | import="net.sf.basedb.core.query.Hql" |
---|
54 | import="net.sf.basedb.core.snapshot.AnnotationSetSnapshot" |
---|
55 | import="net.sf.basedb.core.snapshot.AnnotationTypeFilter" |
---|
56 | import="net.sf.basedb.core.snapshot.SnapshotManager" |
---|
57 | import="net.sf.basedb.core.snapshot.AnnotationSnapshot" |
---|
58 | import="net.sf.basedb.util.formatter.Formatter" |
---|
59 | import="net.sf.basedb.util.units.UnitConverter" |
---|
60 | import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
---|
61 | import="net.sf.basedb.clients.web.Base" |
---|
62 | import="net.sf.basedb.clients.web.PermissionUtil" |
---|
63 | import="net.sf.basedb.clients.web.util.HTML" |
---|
64 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
65 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
66 | import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer" |
---|
67 | import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil" |
---|
68 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
69 | import="net.sf.basedb.util.Values" |
---|
70 | import="java.util.Map" |
---|
71 | import="java.util.List" |
---|
72 | import="java.util.HashMap" |
---|
73 | import="java.util.LinkedList" |
---|
74 | import="java.util.Date" |
---|
75 | %> |
---|
76 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
77 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
78 | <%@ taglib prefix="p" uri="/WEB-INF/path.tld" %> |
---|
79 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
80 | <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
---|
81 | <%! |
---|
82 | private static final Item itemType = Item.ROOTRAWBIOASSAY; |
---|
83 | private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM); |
---|
84 | %> |
---|
85 | <% |
---|
86 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
87 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
88 | final int itemId = cc.getId(); |
---|
89 | final String ID = sc.getId(); |
---|
90 | final float scale = Base.getScale(sc); |
---|
91 | final String tabId = Values.getString(request.getParameter("tab"), "properties"); |
---|
92 | final DbControl dc = sc.newDbControl(); |
---|
93 | try |
---|
94 | { |
---|
95 | RootRawBioAssay bioAssay = RootRawBioAssay.getById(dc, itemId); |
---|
96 | Experiment experiment = bioAssay.getExperiment(); |
---|
97 | String title = null; |
---|
98 | |
---|
99 | ItemQuery<AnnotationType> efQuery = experiment.getExperimentalFactors(); |
---|
100 | efQuery.include(Include.ALL); |
---|
101 | efQuery.order(Orders.asc(Hql.property("name"))); |
---|
102 | ItemResultList<AnnotationType> experimentalFactors = efQuery.list(dc); |
---|
103 | SnapshotManager manager = new SnapshotManager(); |
---|
104 | AnnotationSetSnapshot snapshot = bioAssay.isAnnotated() ? |
---|
105 | manager.getSnapshot(dc, bioAssay.getAnnotationSet().getId()) : null; |
---|
106 | |
---|
107 | Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc); |
---|
108 | final boolean writePermission = bioAssay.hasPermission(Permission.WRITE); |
---|
109 | Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); |
---|
110 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, bioAssay); |
---|
111 | ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext); |
---|
112 | %> |
---|
113 | <base:page title="<%=title%>" id="view-page"> |
---|
114 | <base:head scripts="table.js,tabcontrol-2.js,~bioassays.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css"> |
---|
115 | <ext:scripts context="<%=jspContext%>" /> |
---|
116 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
117 | <style> |
---|
118 | .edit-experimental-factor |
---|
119 | { |
---|
120 | float: right; |
---|
121 | } |
---|
122 | </style> |
---|
123 | </base:head> |
---|
124 | <base:body> |
---|
125 | <p:path><p:pathelement |
---|
126 | title="Experiments" href="<%="../index.jsp?ID="+ID%>" |
---|
127 | /><p:pathelement title="<%=HTML.encodeTags(experiment.getName())%>" |
---|
128 | href="<%="../index.jsp?ID="+ID+"&cmd=ViewItem&item_id="+experiment.getId()%>" |
---|
129 | /><p:pathelement title="<%=HTML.encodeTags(bioAssay.getName())%>" |
---|
130 | /></p:path> |
---|
131 | <div id="page-data" data-item-id="<%=itemId%>"></div> |
---|
132 | |
---|
133 | <t:tabcontrol |
---|
134 | id="main" |
---|
135 | subclass="content mastertabcontrol" |
---|
136 | active="<%=tabId%>"> |
---|
137 | <t:tab id="properties" title="Properties"> |
---|
138 | <div> |
---|
139 | <table class="fullform bottomborder"> |
---|
140 | <tr> |
---|
141 | <th class="itemstatus"> |
---|
142 | </th> |
---|
143 | <td style="padding: 0px;"> |
---|
144 | <tbl:toolbar subclass="bottomborder bg-filled-50"> |
---|
145 | <tbl:button |
---|
146 | id="btnEdit" |
---|
147 | disabled="<%=!writePermission%>" |
---|
148 | image="edit.png" |
---|
149 | title="Edit…" |
---|
150 | tooltip="<%=writePermission ? "Edit this bioassay" : "You do not have permission to edit this bioassay"%>" |
---|
151 | /> |
---|
152 | <tbl:button |
---|
153 | id="btnImport" |
---|
154 | image="import.png" |
---|
155 | data-plugin-type="IMPORT" |
---|
156 | title="Import…" |
---|
157 | tooltip="Import data" |
---|
158 | visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>" |
---|
159 | /> |
---|
160 | <tbl:button |
---|
161 | id="btnExport" |
---|
162 | image="export.png" |
---|
163 | data-plugin-type="EXPORT" |
---|
164 | title="Export…" |
---|
165 | tooltip="Export data" |
---|
166 | visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>" |
---|
167 | /> |
---|
168 | <tbl:button |
---|
169 | id="btnRunPlugin" |
---|
170 | image="runplugin.png" |
---|
171 | data-plugin-type="OTHER" |
---|
172 | title="Run plugin…" |
---|
173 | tooltip="Run a plugin" |
---|
174 | visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>" |
---|
175 | /> |
---|
176 | <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" |
---|
177 | wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/> |
---|
178 | <tbl:button |
---|
179 | image="help.png" |
---|
180 | subclass="auto-init" |
---|
181 | data-auto-init="help" |
---|
182 | data-help-id="rootrawbioassay.view.properties" |
---|
183 | title="Help…" |
---|
184 | tooltip="Get help about this page" |
---|
185 | /> |
---|
186 | </tbl:toolbar> |
---|
187 | </td> |
---|
188 | </tr> |
---|
189 | <tr> |
---|
190 | <th>Name</th> |
---|
191 | <td><%=HTML.encodeTags(bioAssay.getName())%></td> |
---|
192 | </tr> |
---|
193 | <tr> |
---|
194 | <th>Parent raw bioassay</th> |
---|
195 | <td><base:propertyvalue item="<%=bioAssay%>" property="rawBioAssay" /> |
---|
196 | <tr> |
---|
197 | <th>Description</th> |
---|
198 | <td><%=HTML.encodeTags(bioAssay.getDescription())%></td> |
---|
199 | </tr> |
---|
200 | </table> |
---|
201 | </div> |
---|
202 | |
---|
203 | <base:section |
---|
204 | id="experimentalFactors" |
---|
205 | title="<%="Experimental factors (" + experimentalFactors.size() +")"%>" |
---|
206 | context="<%=cc%>" |
---|
207 | > |
---|
208 | <% |
---|
209 | if (experimentalFactors.size() == 0) |
---|
210 | { |
---|
211 | %> |
---|
212 | <div class="messagecontainer note"> |
---|
213 | No experimental factors has been added to this experiment |
---|
214 | (or, you don't have permission to view them). |
---|
215 | </div> |
---|
216 | <% |
---|
217 | } |
---|
218 | else |
---|
219 | { |
---|
220 | %> |
---|
221 | <div style="width: 100%; max-width: 1000px;"> |
---|
222 | <tbl:table |
---|
223 | id="tbl.experimentalFactors" |
---|
224 | columns="all" |
---|
225 | action="index.jsp" |
---|
226 | > |
---|
227 | <tbl:hidden name="item_id" value="<%=Integer.toString(itemId)%>" /> |
---|
228 | <tbl:columndef |
---|
229 | id="name" |
---|
230 | title="Name" |
---|
231 | /> |
---|
232 | <tbl:columndef |
---|
233 | id="type" |
---|
234 | title="Value type" |
---|
235 | /> |
---|
236 | <tbl:columndef |
---|
237 | id="values" |
---|
238 | title="Values" |
---|
239 | /> |
---|
240 | <tbl:columndef |
---|
241 | id="item" |
---|
242 | title="Parent item" |
---|
243 | /> |
---|
244 | <tbl:columndef |
---|
245 | id="note" |
---|
246 | title="Note" |
---|
247 | /> |
---|
248 | <tbl:columndef |
---|
249 | id="lastModified" |
---|
250 | title="Last modified" |
---|
251 | formatter="<%=dateTimeFormatter %>" |
---|
252 | /> |
---|
253 | <tbl:columndef |
---|
254 | id="description" |
---|
255 | title="Description" |
---|
256 | /> |
---|
257 | <tbl:data> |
---|
258 | <tbl:headers> |
---|
259 | <tbl:headerrow> |
---|
260 | <tbl:columnheaders /> |
---|
261 | </tbl:headerrow> |
---|
262 | </tbl:headers> |
---|
263 | <tbl:rows> |
---|
264 | <% |
---|
265 | AnnotationTypeFilter annotationTypeFilter = new AnnotationTypeFilter(); |
---|
266 | for (AnnotationType at : experimentalFactors) |
---|
267 | { |
---|
268 | Type valueType = at.getValueType(); |
---|
269 | annotationTypeFilter.setAnnotationType(at); |
---|
270 | List<AnnotationSnapshot> all = snapshot == null ? |
---|
271 | null : manager.findAnnotations(dc, snapshot, annotationTypeFilter, true); |
---|
272 | |
---|
273 | List<?> values = null; |
---|
274 | Formatter formatter = FormatterFactory.getTypeFormatter(sc, valueType); |
---|
275 | Nameable parentItem = null; |
---|
276 | String parentType = ""; |
---|
277 | if (all != null && all.size() > 0) |
---|
278 | { |
---|
279 | for (AnnotationSnapshot a : all) |
---|
280 | { |
---|
281 | boolean annotatePermission = a.hasPermission(dc, Permission.WRITE); |
---|
282 | Unit unit = a.getActualUnit(dc); |
---|
283 | UnitConverter converter = null; |
---|
284 | if (unit != null) |
---|
285 | { |
---|
286 | converter = unit.getUnitConverter(at.getDefaultUnit()); |
---|
287 | formatter = unit.getFormatter(formatter); |
---|
288 | } |
---|
289 | values = a.getActualValues(converter, valueType); |
---|
290 | |
---|
291 | Date lastModified = a.getThisLastUpdate(); |
---|
292 | boolean isUpToDate = a.isUpToDate(); |
---|
293 | AnnotationSnapshot inherited = a.getInheritedFrom(); |
---|
294 | if (inherited != null) |
---|
295 | { |
---|
296 | parentType = inherited.getItemType().toString(); |
---|
297 | if (lastModified == null) |
---|
298 | { |
---|
299 | lastModified = inherited.getThisLastUpdate(); |
---|
300 | } |
---|
301 | try |
---|
302 | { |
---|
303 | parentItem = (Nameable)inherited.getThisItem(dc); |
---|
304 | if (parentItem instanceof Subtypable) |
---|
305 | { |
---|
306 | ItemSubtype subtype = ((Subtypable)parentItem).getItemSubtype(); |
---|
307 | if (subtype != null) parentType = subtype.getName(); |
---|
308 | } |
---|
309 | } |
---|
310 | catch (PermissionDeniedException ex) |
---|
311 | {} |
---|
312 | } |
---|
313 | %> |
---|
314 | <tbl:row> |
---|
315 | <tbl:cell column="name"><base:icon |
---|
316 | image="deleted.png" |
---|
317 | tooltip="This item has been scheduled for deletion" |
---|
318 | visible="<%=at.isRemoved()%>" |
---|
319 | /><%=Base.getLinkedName(ID, at, false, true)%></tbl:cell> |
---|
320 | <tbl:cell column="description"><%=HTML.encodeTags(at.getDescription())%></tbl:cell> |
---|
321 | <tbl:cell column="type"> |
---|
322 | <%=valueType%> |
---|
323 | <%=at.isEnumeration() ? "(enumeration)" : ""%> |
---|
324 | </tbl:cell> |
---|
325 | <tbl:cell column="values"> |
---|
326 | <%=Values.getString(values, ", ", true, formatter)%> |
---|
327 | <base:icon id="<%=Integer.toString(a.getThisAnnotationId())%>" |
---|
328 | image="<%=isUpToDate ? "edit.png" : "edit-outofsync.png"%>" |
---|
329 | subclass="edit-experimental-factor auto-init" |
---|
330 | data-auto-init="edit-experimental-factor" |
---|
331 | data-item-type="ROOTRAWBIOASSAY" |
---|
332 | data-item-id="<%=itemId%>" |
---|
333 | data-annotation-type-id="<%=at.getId()%>" |
---|
334 | data-annotation-id="<%=a.getThisAnnotationId()%>" |
---|
335 | tooltip="Edit this annotation" |
---|
336 | visible="<%=annotatePermission %>"/> |
---|
337 | </tbl:cell> |
---|
338 | <tbl:cell column="item"> |
---|
339 | <% |
---|
340 | if (parentItem != null) |
---|
341 | { |
---|
342 | %> |
---|
343 | <%=Base.getLinkedName(ID, parentItem, false, true)%> |
---|
344 | <span class="itemsubtype">(<%=parentType%>)</span> |
---|
345 | <% |
---|
346 | } |
---|
347 | else if (a.getSource() == Annotation.Source.CLONED) |
---|
348 | { |
---|
349 | %> |
---|
350 | <i>- missing -</i> |
---|
351 | <% |
---|
352 | } |
---|
353 | %> |
---|
354 | </tbl:cell> |
---|
355 | <tbl:cell column="note"><%=a.getSource() == Annotation.Source.CLONED ? "Cloned" + (isUpToDate ? "; up-to-date" : "; modified") : "" %></tbl:cell> |
---|
356 | <tbl:cell column="lastModified" value="<%=lastModified %>" /> |
---|
357 | </tbl:row> |
---|
358 | <% |
---|
359 | } |
---|
360 | } |
---|
361 | else |
---|
362 | { |
---|
363 | %> |
---|
364 | <tbl:row> |
---|
365 | <tbl:cell column="name"><base:icon |
---|
366 | image="deleted.png" |
---|
367 | tooltip="This item has been scheduled for deletion" |
---|
368 | visible="<%=at.isRemoved()%>" |
---|
369 | /><%=Base.getLinkedName(ID, at, false, true)%></tbl:cell> |
---|
370 | <tbl:cell column="description"><%=HTML.encodeTags(at.getDescription())%></tbl:cell> |
---|
371 | <tbl:cell column="type"> |
---|
372 | <%=valueType%> |
---|
373 | <%=at.isEnumeration() ? "(enumeration)" : ""%> |
---|
374 | </tbl:cell> |
---|
375 | </tbl:row> |
---|
376 | <% |
---|
377 | } |
---|
378 | } |
---|
379 | %> |
---|
380 | </tbl:rows> |
---|
381 | </tbl:data> |
---|
382 | </tbl:table> |
---|
383 | <div id="warning.missing" style="display: none; text-align: right;"> |
---|
384 | <base:icon image="warning.png" /> = Some raw bioassays are missing this factor value |
---|
385 | </div> |
---|
386 | </div> |
---|
387 | <% |
---|
388 | } |
---|
389 | %> |
---|
390 | </base:section> |
---|
391 | |
---|
392 | </t:tab> |
---|
393 | |
---|
394 | <t:tab id="annotations" title="Annotations" |
---|
395 | tooltip="View annotation values" clazz="white"> |
---|
396 | <jsp:include page="../../../common/annotations/list_frameset.jsp"> |
---|
397 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
398 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
399 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
400 | </jsp:include> |
---|
401 | </t:tab> |
---|
402 | |
---|
403 | </t:tabcontrol> |
---|
404 | |
---|
405 | </base:body> |
---|
406 | </base:page> |
---|
407 | <% |
---|
408 | } |
---|
409 | finally |
---|
410 | { |
---|
411 | if (dc != null) dc.close(); |
---|
412 | } |
---|
413 | %> |
---|