1 | <%-- $Id: view_configuration.jsp 6592 2014-11-12 12:58:23Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson |
---|
4 | Copyright (C) 2007 Martin Svensson |
---|
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.Group" |
---|
31 | import="net.sf.basedb.core.Item" |
---|
32 | import="net.sf.basedb.core.ItemContext" |
---|
33 | import="net.sf.basedb.core.ItemResultIterator" |
---|
34 | import="net.sf.basedb.core.Permission" |
---|
35 | import="net.sf.basedb.core.PluginDefinition" |
---|
36 | import="net.sf.basedb.core.PluginConfiguration" |
---|
37 | import="net.sf.basedb.core.ParameterInfo" |
---|
38 | import="net.sf.basedb.core.User" |
---|
39 | import="net.sf.basedb.core.BasicItem" |
---|
40 | import="net.sf.basedb.core.File" |
---|
41 | import="net.sf.basedb.core.MultiPermissions" |
---|
42 | import="net.sf.basedb.core.Nameable" |
---|
43 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
44 | import="net.sf.basedb.core.PluginDefinition" |
---|
45 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
46 | import="net.sf.basedb.core.plugin.Plugin" |
---|
47 | import="net.sf.basedb.core.Project" |
---|
48 | import="net.sf.basedb.core.Type" |
---|
49 | import="net.sf.basedb.util.JarClassLoader" |
---|
50 | import="net.sf.basedb.util.ToStringComparator" |
---|
51 | import="net.sf.basedb.clients.web.Base" |
---|
52 | import="net.sf.basedb.clients.web.ChangeHistoryUtil" |
---|
53 | import="net.sf.basedb.clients.web.PermissionUtil" |
---|
54 | import="net.sf.basedb.clients.web.util.HTML" |
---|
55 | import="net.sf.basedb.util.Values" |
---|
56 | import="net.sf.basedb.util.formatter.Formatter" |
---|
57 | import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
---|
58 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
59 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
60 | import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer" |
---|
61 | import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil" |
---|
62 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
63 | import="java.util.Map" |
---|
64 | import="java.util.Set" |
---|
65 | import="java.util.TreeSet" |
---|
66 | import="java.util.List" |
---|
67 | import="java.util.Collections" |
---|
68 | import="java.util.Date" |
---|
69 | %> |
---|
70 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
71 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
72 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
73 | <%@ taglib prefix="p" uri="/WEB-INF/path.tld" %> |
---|
74 | <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
---|
75 | <%! |
---|
76 | private static final Item itemType = Item.PLUGINCONFIGURATION; |
---|
77 | private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM); |
---|
78 | %> |
---|
79 | <% |
---|
80 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
81 | final String ID = sc.getId(); |
---|
82 | final String root = request.getContextPath() + "/"; |
---|
83 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
84 | final int itemId = cc.getId(); |
---|
85 | final String tab = Values.getString(request.getParameter("tab")); |
---|
86 | final float scale = Base.getScale(sc); |
---|
87 | final DbControl dc = sc.newDbControl(); |
---|
88 | try |
---|
89 | { |
---|
90 | Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); |
---|
91 | Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
---|
92 | Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc); |
---|
93 | |
---|
94 | String title = null; |
---|
95 | PluginConfiguration configuration = PluginConfiguration.getById(dc, itemId); |
---|
96 | |
---|
97 | final boolean createPermission = sc.hasPermission(Permission.CREATE, itemType); |
---|
98 | final boolean writePermission = configuration.hasPermission(Permission.WRITE); |
---|
99 | final boolean deletePermission = configuration.hasPermission(Permission.DELETE); |
---|
100 | final boolean sharePermission = configuration.hasPermission(Permission.SET_PERMISSION); |
---|
101 | final boolean setOwnerPermission = configuration.hasPermission(Permission.SET_OWNER); |
---|
102 | final boolean isRemoved = configuration.isRemoved(); |
---|
103 | final boolean isUsed = isRemoved && configuration.isUsed(); |
---|
104 | final boolean deletePermanentlyPermission = deletePermission && !isUsed; |
---|
105 | final boolean isOwner = configuration.isOwner(); |
---|
106 | |
---|
107 | final Set<GuiContext> contexts = new TreeSet<GuiContext>(new ToStringComparator<GuiContext>(false)); |
---|
108 | PluginDefinition plugin = null; |
---|
109 | Nameable nameableProxy = null; |
---|
110 | boolean readPlugin = true; |
---|
111 | boolean configurable = false; |
---|
112 | try |
---|
113 | { |
---|
114 | plugin = configuration.getPluginDefinition(); |
---|
115 | contexts.addAll(plugin.getGuiContexts()); |
---|
116 | configurable = plugin.isInteractive() && plugin.supportsConfigurations(); |
---|
117 | } |
---|
118 | catch (PermissionDeniedException ex) |
---|
119 | { |
---|
120 | readPlugin = false; |
---|
121 | } |
---|
122 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, configuration); |
---|
123 | ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext); |
---|
124 | %> |
---|
125 | <base:page title="<%=title%>" id="view-page"> |
---|
126 | <base:head scripts="table.js,tabcontrol-2.js,~configurations.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css"> |
---|
127 | <ext:scripts context="<%=jspContext%>" /> |
---|
128 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
129 | </base:head> |
---|
130 | <base:body> |
---|
131 | <p:path><p:pathelement |
---|
132 | title="Plugin configurations" href="<%="index.jsp?ID="+ID%>" |
---|
133 | /><p:pathelement title="<%=HTML.encodeTags(configuration.getName())%>" |
---|
134 | /></p:path> |
---|
135 | <div id="page-data" data-item-id="<%=itemId%>"></div> |
---|
136 | |
---|
137 | <t:tabcontrol |
---|
138 | id="main" |
---|
139 | subclass="content mastertabcontrol" |
---|
140 | active="<%=tab%>"> |
---|
141 | <t:tab id="properties" title="Properties"> |
---|
142 | <div> |
---|
143 | <table class="fullform bottomborder"> |
---|
144 | <tr> |
---|
145 | <th class="itemstatus"> |
---|
146 | <base:icon |
---|
147 | image="shared.png" |
---|
148 | visible="<%=configuration.isShared()%>" |
---|
149 | tooltip="This item is shared to other users, groups and/or projects" |
---|
150 | /> |
---|
151 | <base:icon |
---|
152 | id="btnDeletePermanently" |
---|
153 | image="deleted.png" |
---|
154 | tooltip="This item has been flagged for deletion. Click to delete it now." |
---|
155 | enabled="<%=deletePermanentlyPermission %>" |
---|
156 | visible="<%=isRemoved%>" |
---|
157 | /> |
---|
158 | <base:icon |
---|
159 | id="btnUsingItems" |
---|
160 | image="used.png" |
---|
161 | tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one" |
---|
162 | visible="<%=isRemoved && isUsed%>" /> |
---|
163 | </th> |
---|
164 | <td style="padding: 0px;"> |
---|
165 | <tbl:toolbar subclass="bottomborder"> |
---|
166 | <tbl:button |
---|
167 | id="btnEdit" |
---|
168 | disabled="<%=!writePermission%>" |
---|
169 | image="edit.png" |
---|
170 | title="Edit…" |
---|
171 | tooltip="<%=writePermission ? "Edit this plugin configuration" : "You do not have permission to edit this plugin configuration"%>" |
---|
172 | /> |
---|
173 | <tbl:button |
---|
174 | id="btnCopy" |
---|
175 | disabled="<%=!createPermission%>" |
---|
176 | image="copy.png" |
---|
177 | title="Copy…" |
---|
178 | tooltip="<%=createPermission ? "Create a copy of this configuration" : "You do not have permission to create new configurations"%>" |
---|
179 | /> |
---|
180 | <tbl:button |
---|
181 | id="btnDelete" |
---|
182 | disabled="<%=!deletePermission%>" |
---|
183 | image="delete.png" |
---|
184 | title="Delete" |
---|
185 | visible="<%=!configuration.isRemoved()%>" |
---|
186 | tooltip="<%=deletePermission ? "Delete this plugin configuration" : "You do not have permission to delete this plugin configuration"%>" |
---|
187 | /> |
---|
188 | <tbl:button |
---|
189 | id="btnRestore" |
---|
190 | disabled="<%=!writePermission%>" |
---|
191 | image="restore.png" |
---|
192 | title="Restore" |
---|
193 | visible="<%=configuration.isRemoved()%>" |
---|
194 | tooltip="<%=writePermission ? "Restore this plugin configuration" : "You do not have permission to restore this plugin configuration"%>" |
---|
195 | /> |
---|
196 | <tbl:button |
---|
197 | id="btnShare" |
---|
198 | disabled="<%=!sharePermission%>" |
---|
199 | image="share.png" |
---|
200 | title="Share…" |
---|
201 | tooltip="<%=sharePermission ? "Share this plugin configuration to other user, groups and projects" : "You do not have permission to share this plugin configuration"%>" |
---|
202 | /> |
---|
203 | <tbl:button |
---|
204 | id="btnSetOwner" |
---|
205 | disabled="<%=!setOwnerPermission%>" |
---|
206 | image="take_ownership.png" |
---|
207 | title="Set owner…" |
---|
208 | tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>" |
---|
209 | /> |
---|
210 | <tbl:button |
---|
211 | id="btnImport" |
---|
212 | image="import.png" |
---|
213 | data-plugin-type="IMPORT" |
---|
214 | title="Import…" |
---|
215 | tooltip="Import data" |
---|
216 | visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>" |
---|
217 | /> |
---|
218 | <tbl:button |
---|
219 | id="btnExport" |
---|
220 | image="export.png" |
---|
221 | data-plugin-type="EXPORT" |
---|
222 | title="Export…" |
---|
223 | tooltip="Export data" |
---|
224 | visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>" |
---|
225 | /> |
---|
226 | <tbl:button |
---|
227 | id="btnRunPlugin" |
---|
228 | image="runplugin.png" |
---|
229 | data-plugin-type="OTHER" |
---|
230 | title="Run plugin…" |
---|
231 | tooltip="Run a plugin" |
---|
232 | visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>" |
---|
233 | /> |
---|
234 | <tbl:button |
---|
235 | id="btnConfigure" |
---|
236 | image="runplugin.png" |
---|
237 | title="Configure…" |
---|
238 | tooltip="Configure this plugin" |
---|
239 | visible="<%=configurable && writePermission%>" |
---|
240 | /> |
---|
241 | <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" |
---|
242 | wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/> |
---|
243 | <tbl:button |
---|
244 | image="help.png" |
---|
245 | subclass="auto-init" |
---|
246 | data-auto-init="help" |
---|
247 | data-help-id="pluginconfiguration.view.properties" |
---|
248 | title="Help…" |
---|
249 | tooltip="Get help about this page" |
---|
250 | /> |
---|
251 | </tbl:toolbar> |
---|
252 | </td> |
---|
253 | </tr> |
---|
254 | <tr> |
---|
255 | <th>Name</th> |
---|
256 | <td><%=HTML.encodeTags(configuration.getName())%></td> |
---|
257 | </tr> |
---|
258 | <tr> |
---|
259 | <th>Registered</th> |
---|
260 | <td><%=dateFormatter.format(configuration.getEntryDate())%></td> |
---|
261 | </tr> |
---|
262 | <tr> |
---|
263 | <th>Plugin</th> |
---|
264 | <td><%=Base.getLinkedName(ID, plugin, plugin == null, true)%></td> |
---|
265 | </tr> |
---|
266 | <tr> |
---|
267 | <th>Type</th> |
---|
268 | <td><%=plugin == null ? "<i>- denied -</i>" : plugin.getMainType().toString()%></td> |
---|
269 | </tr> |
---|
270 | <tr> |
---|
271 | <th>Owner</th> |
---|
272 | <td><base:propertyvalue item="<%=configuration%>" property="owner" /></td> |
---|
273 | </tr> |
---|
274 | <tr> |
---|
275 | <th>Permissions</th> |
---|
276 | <td><%=PermissionUtil.getFullPermissionNames(configuration)%></td> |
---|
277 | </tr> |
---|
278 | <tr > |
---|
279 | <th>Description</th> |
---|
280 | <td><%=HTML.niceFormat(configuration.getDescription())%></td> |
---|
281 | </tr> |
---|
282 | </table> |
---|
283 | </div> |
---|
284 | |
---|
285 | <% |
---|
286 | if (plugin != null) |
---|
287 | { |
---|
288 | List<String> names = new java.util.ArrayList<String>(configuration.getParameterNames()); |
---|
289 | %> |
---|
290 | <base:section |
---|
291 | id="parameters" |
---|
292 | title="Configuration parameters" |
---|
293 | context="<%=cc %>" |
---|
294 | > |
---|
295 | <% |
---|
296 | if (names == null || names.size() == 0) |
---|
297 | { |
---|
298 | %> |
---|
299 | <div class="messagecontainer note"> |
---|
300 | No parameters has been specified. |
---|
301 | </div> |
---|
302 | <% |
---|
303 | } |
---|
304 | else |
---|
305 | { |
---|
306 | Collections.sort(names); |
---|
307 | %> |
---|
308 | <table class="fullform fullborder"> |
---|
309 | <% |
---|
310 | for (String name : names) |
---|
311 | { |
---|
312 | StringBuilder sb = new StringBuilder(); |
---|
313 | String displayValue = ""; |
---|
314 | String description = ""; |
---|
315 | try |
---|
316 | { |
---|
317 | ParameterInfo pi = configuration.getParameterInfo(name); |
---|
318 | if (pi.getLabel() != null) name = HTML.encodeTags(pi.getLabel()); |
---|
319 | description = HTML.encodeTags(pi.getDescription()); |
---|
320 | List<?> values = pi.getValues(); |
---|
321 | int i = 0; |
---|
322 | for (Object value : values) |
---|
323 | { |
---|
324 | if (value != null) |
---|
325 | { |
---|
326 | if (i > 0) sb.append(", "); |
---|
327 | i++; |
---|
328 | if (value instanceof BasicItem) |
---|
329 | { |
---|
330 | BasicItem item = (BasicItem)value; |
---|
331 | String itemName = ""; |
---|
332 | if (item instanceof File) |
---|
333 | { |
---|
334 | sb.append(Base.getLinkedFile(ID, (File)item, false, true, true, root)); |
---|
335 | } |
---|
336 | else |
---|
337 | { |
---|
338 | if (item instanceof Nameable) |
---|
339 | { |
---|
340 | itemName = ((Nameable)item).getName(); |
---|
341 | } |
---|
342 | else |
---|
343 | { |
---|
344 | itemName = item.toString(); |
---|
345 | } |
---|
346 | sb.append(Base.getLink(ID, HTML.encodeTags(itemName), |
---|
347 | item.getType(), item.getId(), item.hasPermission(Permission.WRITE))); |
---|
348 | } |
---|
349 | } |
---|
350 | else if (value instanceof Date) |
---|
351 | { |
---|
352 | if (pi.getValueType() == Type.TIMESTAMP) |
---|
353 | { |
---|
354 | sb.append(dateTimeFormatter.format((Date)value)); |
---|
355 | } |
---|
356 | else |
---|
357 | { |
---|
358 | sb.append(dateFormatter.format((Date)value)); |
---|
359 | } |
---|
360 | } |
---|
361 | else |
---|
362 | { |
---|
363 | sb.append(HTML.encodeTags(value.toString())); |
---|
364 | } |
---|
365 | } |
---|
366 | } |
---|
367 | displayValue = sb.toString(); |
---|
368 | } |
---|
369 | catch (Throwable ex) |
---|
370 | { |
---|
371 | displayValue = "<i>ERROR: "+ex.getMessage()+"</i>"; |
---|
372 | } |
---|
373 | %> |
---|
374 | <tr> |
---|
375 | <th><span title="<%=description%>"><%=name%></span></th> |
---|
376 | <td><%=displayValue%></td> |
---|
377 | </tr> |
---|
378 | <% |
---|
379 | } |
---|
380 | %> |
---|
381 | </table> |
---|
382 | <% |
---|
383 | } |
---|
384 | %> |
---|
385 | </base:section> |
---|
386 | <% |
---|
387 | } |
---|
388 | %> |
---|
389 | |
---|
390 | <jsp:include page="../../common/anytoany/list_anytoany.jsp"> |
---|
391 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
392 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
393 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
394 | <jsp:param name="title" value="Other items related to this plugin configuration" /> |
---|
395 | </jsp:include> |
---|
396 | <jsp:include page="../../common/share/list_share.jsp"> |
---|
397 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
398 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
399 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
400 | <jsp:param name="title" value="Shared to" /> |
---|
401 | </jsp:include> |
---|
402 | </t:tab> |
---|
403 | |
---|
404 | <t:tab id="annotations" title="Annotations" |
---|
405 | tooltip="View annotation values" clazz="white" |
---|
406 | visible="<%=plugin != null && plugin.supports("net.sf.basedb.core.plugin.AnnotationSetterPlugin") %>"> |
---|
407 | <jsp:include page="../../common/annotations/list_frameset.jsp"> |
---|
408 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
409 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
410 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
411 | </jsp:include> |
---|
412 | </t:tab> |
---|
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 | <jsp:include page="../../common/history/frameset.jsp"> |
---|
417 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
418 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
419 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
420 | </jsp:include> |
---|
421 | </t:tab> |
---|
422 | </t:tabcontrol> |
---|
423 | |
---|
424 | </base:body> |
---|
425 | </base:page> |
---|
426 | <% |
---|
427 | } |
---|
428 | finally |
---|
429 | { |
---|
430 | if (dc != null) dc.close(); |
---|
431 | } |
---|
432 | |
---|
433 | %> |
---|