1 | <%-- $Id: view_well.jsp 5942 2012-02-01 14:12:59Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2006 Johan Enell, Jari Häkkinen, Nicklas Nordborg |
---|
4 | Copyright (C) 2007 Nicklas Nordborg |
---|
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.SystemItems" |
---|
30 | import="net.sf.basedb.core.Item" |
---|
31 | import="net.sf.basedb.core.ItemContext" |
---|
32 | import="net.sf.basedb.core.Permission" |
---|
33 | import="net.sf.basedb.core.Plate" |
---|
34 | import="net.sf.basedb.core.Well" |
---|
35 | import="net.sf.basedb.core.Reporter" |
---|
36 | import="net.sf.basedb.core.ReporterType" |
---|
37 | import="net.sf.basedb.core.ExtendedProperties" |
---|
38 | import="net.sf.basedb.core.ExtendedProperty" |
---|
39 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
40 | import="net.sf.basedb.core.PluginDefinition" |
---|
41 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
42 | import="net.sf.basedb.core.plugin.Plugin" |
---|
43 | import="net.sf.basedb.core.data.ReporterData" |
---|
44 | import="net.sf.basedb.clients.web.Base" |
---|
45 | import="net.sf.basedb.clients.web.util.HTML" |
---|
46 | import="net.sf.basedb.util.Values" |
---|
47 | import="net.sf.basedb.util.formatter.Formatter" |
---|
48 | import="net.sf.basedb.util.formatter.WellCoordinateFormatter" |
---|
49 | import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
---|
50 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
51 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
52 | import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer" |
---|
53 | import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil" |
---|
54 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
55 | import="java.util.Date" |
---|
56 | import="java.util.Map" |
---|
57 | import="java.util.Set" |
---|
58 | import="java.util.List" |
---|
59 | %> |
---|
60 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
61 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
62 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
63 | <%@ taglib prefix="p" uri="/WEB-INF/path.tld" %> |
---|
64 | <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
---|
65 | <%! |
---|
66 | private static final Item itemType = Item.WELL; |
---|
67 | private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM); |
---|
68 | %> |
---|
69 | <% |
---|
70 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
71 | final String ID = sc.getId(); |
---|
72 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
73 | final int itemId = cc.getId(); |
---|
74 | final float scale = Base.getScale(sc); |
---|
75 | final DbControl dc = sc.newDbControl(); |
---|
76 | try |
---|
77 | { |
---|
78 | Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
---|
79 | Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc); |
---|
80 | WellCoordinateFormatter rowFormatter = new WellCoordinateFormatter(true); |
---|
81 | WellCoordinateFormatter columnFormatter = new WellCoordinateFormatter(false); |
---|
82 | Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); |
---|
83 | |
---|
84 | String title = null; |
---|
85 | final Well well = Well.getById(dc, itemId); |
---|
86 | final Plate plate = well.getPlate(); |
---|
87 | ReporterData reporter = well.getReporter(); |
---|
88 | final int plateId = plate.getId(); |
---|
89 | |
---|
90 | Well parentWell = null; |
---|
91 | boolean readParentWell = true; |
---|
92 | Plate parentWellPlate = null; |
---|
93 | boolean readParentWellPlate = true; |
---|
94 | try |
---|
95 | { |
---|
96 | parentWell = well.getParent(); |
---|
97 | } |
---|
98 | catch (PermissionDeniedException ex) |
---|
99 | { |
---|
100 | readParentWell = false; |
---|
101 | readParentWellPlate = false; |
---|
102 | } |
---|
103 | if (parentWell != null) |
---|
104 | { |
---|
105 | try |
---|
106 | { |
---|
107 | parentWellPlate = parentWell.getPlate(); |
---|
108 | } |
---|
109 | catch (PermissionDeniedException ex) |
---|
110 | { |
---|
111 | readParentWellPlate = false; |
---|
112 | } |
---|
113 | } |
---|
114 | |
---|
115 | boolean readCurrentReporterType = true; |
---|
116 | ReporterType currentReporterType = null; |
---|
117 | if (reporter != null) |
---|
118 | { |
---|
119 | reporter = Reporter.getById(dc, reporter.getId()); |
---|
120 | try |
---|
121 | { |
---|
122 | currentReporterType = Reporter.getReporterType(dc, reporter); |
---|
123 | } |
---|
124 | catch (PermissionDeniedException ex) |
---|
125 | { |
---|
126 | readCurrentReporterType = false; |
---|
127 | } |
---|
128 | } |
---|
129 | |
---|
130 | final boolean writePermission = well.hasPermission(Permission.WRITE); |
---|
131 | final boolean deletePermission = well.hasPermission(Permission.DELETE); |
---|
132 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, well); |
---|
133 | ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext); |
---|
134 | %> |
---|
135 | <base:page title="<%=title%>"> |
---|
136 | <base:head scripts="table.js,tabcontrol.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css"> |
---|
137 | <ext:scripts context="<%=jspContext%>" /> |
---|
138 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
139 | <script language="JavaScript"> |
---|
140 | function editItem() |
---|
141 | { |
---|
142 | Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true); |
---|
143 | } |
---|
144 | function runPlugin(cmd) |
---|
145 | { |
---|
146 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&plate_id=<%=plateId%>&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500); |
---|
147 | } |
---|
148 | </script> |
---|
149 | </base:head> |
---|
150 | <base:body> |
---|
151 | <p> |
---|
152 | <p:path> |
---|
153 | <p:pathelement title="Plates" href="<%="../index.jsp?ID="+ID%>" /> |
---|
154 | <p:pathelement |
---|
155 | title="<%=HTML.encodeTags(plate.getName())%>" |
---|
156 | href="<%="index.jsp?ID="+ID+"&plate_id="+plateId%>" /> |
---|
157 | <p:pathelement title="<%="Well: "+rowFormatter.format(well.getRow())+columnFormatter.format(well.getColumn())%>" /> |
---|
158 | </p:path> |
---|
159 | |
---|
160 | <t:tabcontrol id="main" active="properties"> |
---|
161 | <t:tab id="properties" title="Properties"> |
---|
162 | |
---|
163 | <tbl:toolbar |
---|
164 | > |
---|
165 | <tbl:button |
---|
166 | disabled="<%=!writePermission%>" |
---|
167 | image="edit.gif" |
---|
168 | onclick="editItem()" |
---|
169 | title="Edit…" |
---|
170 | tooltip="<%=writePermission ? "Edit this event type" : "You do not have permission to edit this event type"%>" |
---|
171 | /> |
---|
172 | <tbl:button |
---|
173 | image="import.gif" |
---|
174 | onclick="runPlugin('ImportItem')" |
---|
175 | title="Import…" |
---|
176 | tooltip="Import data" |
---|
177 | visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>" |
---|
178 | /> |
---|
179 | <tbl:button |
---|
180 | image="export.gif" |
---|
181 | onclick="runPlugin('ExportItem')" |
---|
182 | title="Export…" |
---|
183 | tooltip="Export data" |
---|
184 | visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>" |
---|
185 | /> |
---|
186 | <tbl:button |
---|
187 | image="runplugin.gif" |
---|
188 | onclick="runPlugin('RunPlugin')" |
---|
189 | title="Run plugin…" |
---|
190 | tooltip="Run a plugin" |
---|
191 | visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>" |
---|
192 | /> |
---|
193 | <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" |
---|
194 | wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/> |
---|
195 | <tbl:button |
---|
196 | image="help.png" |
---|
197 | onclick="<%="Main.openHelp('" + ID +"', 'well.view.properties')"%>" |
---|
198 | title="Help…" |
---|
199 | tooltip="Get help about this page" |
---|
200 | /> |
---|
201 | </tbl:toolbar> |
---|
202 | |
---|
203 | <div class="boxedbottom"> |
---|
204 | <table class="form" cellspacing=0> |
---|
205 | <tr> |
---|
206 | <td class="prompt">Row</td> |
---|
207 | <td><%=rowFormatter.format(well.getRow())%></td> |
---|
208 | </tr> |
---|
209 | <tr> |
---|
210 | <td class="prompt">Column</td> |
---|
211 | <td><%=columnFormatter.format(well.getColumn())%></td> |
---|
212 | </tr> |
---|
213 | <tr> |
---|
214 | <td class="prompt">Parent plate/well</td> |
---|
215 | <td> |
---|
216 | <% |
---|
217 | if (!readParentWell) |
---|
218 | { |
---|
219 | %> |
---|
220 | <i>- denied -</i> |
---|
221 | <% |
---|
222 | } |
---|
223 | else if (parentWell == null) |
---|
224 | { |
---|
225 | %> |
---|
226 | <i>- none -</i> |
---|
227 | <% |
---|
228 | } |
---|
229 | else |
---|
230 | { |
---|
231 | %> |
---|
232 | <%=Base.getLink(ID, parentWellPlate.getName() + " [" + parentWell.getRow() + ", " + parentWell.getColumn() + "]", |
---|
233 | Item.WELL, parentWell.getId(), true) %> |
---|
234 | <% |
---|
235 | } |
---|
236 | %> |
---|
237 | </td> |
---|
238 | </tr> |
---|
239 | </table> |
---|
240 | |
---|
241 | <h4>Reporter</h4> |
---|
242 | <% |
---|
243 | if (reporter == null) |
---|
244 | { |
---|
245 | %> |
---|
246 | <i>- none -</i> |
---|
247 | <% |
---|
248 | } |
---|
249 | else |
---|
250 | { |
---|
251 | %> |
---|
252 | <table border="0" cellspacing="0" cellpadding="0"> |
---|
253 | <tr > |
---|
254 | <td> |
---|
255 | <table class="form" cellspacing=0> |
---|
256 | <tr> |
---|
257 | <td class="prompt">Name</td> |
---|
258 | <td><%=Base.getLink(ID, reporter.getName(), Item.REPORTER, reporter.getId(), true) %></td> |
---|
259 | </tr> |
---|
260 | <tr> |
---|
261 | <td class="prompt">Registered</td> |
---|
262 | <td><%=dateFormatter.format(reporter.getEntryDate())%></td> |
---|
263 | </tr> |
---|
264 | <tr> |
---|
265 | <td class="prompt">Last update</td> |
---|
266 | <td><%=dateTimeFormatter.format(reporter.getLastUpdate())%></td> |
---|
267 | </tr> |
---|
268 | <tr> |
---|
269 | <td class="prompt">External ID</td> |
---|
270 | <td><%=HTML.encodeTags(reporter.getExternalId())%></td> |
---|
271 | </tr> |
---|
272 | <tr> |
---|
273 | <td class="prompt">Type</td> |
---|
274 | <td><%=Base.getEncodedName(currentReporterType, !readCurrentReporterType)%></td> |
---|
275 | </tr> |
---|
276 | <tr> |
---|
277 | <td class="prompt">Gene symbol</td> |
---|
278 | <td><%=HTML.encodeTags(reporter.getSymbol())%></td> |
---|
279 | </tr> |
---|
280 | <tr > |
---|
281 | <td class="prompt">Description</td> |
---|
282 | <td><%=HTML.niceFormat(reporter.getDescription())%></td> |
---|
283 | </tr> |
---|
284 | </table> |
---|
285 | </td> |
---|
286 | <td> </td> |
---|
287 | <td> |
---|
288 | <table class="form" cellspacing=0> |
---|
289 | <% |
---|
290 | List<ExtendedProperty> reporterProperties = ExtendedProperties.getProperties("ReporterData"); |
---|
291 | if (reporterProperties != null) |
---|
292 | { |
---|
293 | boolean needsTr = true; |
---|
294 | for (ExtendedProperty ep : reporterProperties) |
---|
295 | { |
---|
296 | String name = ep.getName(); |
---|
297 | Formatter f = FormatterFactory.getExtendedPropertyFormatter(sc, ep); |
---|
298 | String value = f.format(reporter.getExtended(name)); |
---|
299 | %> |
---|
300 | <%=needsTr ? "<tr>" : "" %> |
---|
301 | <td class="prompt"><%=HTML.encodeTags(ep.getTitle())%></td> |
---|
302 | <td><%=value%></td> |
---|
303 | <td> </td> |
---|
304 | <%=needsTr ? "" : "</tr>"%> |
---|
305 | <% |
---|
306 | needsTr = !needsTr; |
---|
307 | } |
---|
308 | %> |
---|
309 | <%=needsTr ? "" : "</tr>"%> |
---|
310 | <% |
---|
311 | } |
---|
312 | %> |
---|
313 | </table> |
---|
314 | </td> |
---|
315 | </tr> |
---|
316 | </table> |
---|
317 | <% |
---|
318 | } |
---|
319 | %> |
---|
320 | <jsp:include page="../../../common/anytoany/list_anytoany.jsp"> |
---|
321 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
322 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
323 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
324 | <jsp:param name="title" value="Other items related to this well" /> |
---|
325 | </jsp:include> |
---|
326 | </div> |
---|
327 | </t:tab> |
---|
328 | |
---|
329 | <t:tab id="annotations" title="Annotations" |
---|
330 | tooltip="View annotation values" clazz="white"> |
---|
331 | <jsp:include page="../../../common/annotations/list_annotations.jsp"> |
---|
332 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
333 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
334 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
335 | </jsp:include> |
---|
336 | </t:tab> |
---|
337 | |
---|
338 | </t:tabcontrol> |
---|
339 | |
---|
340 | </base:body> |
---|
341 | </base:page> |
---|
342 | <% |
---|
343 | } |
---|
344 | finally |
---|
345 | { |
---|
346 | if (dc != null) dc.close(); |
---|
347 | } |
---|
348 | |
---|
349 | %> |
---|