1 | <%-- $Id: view_subtype.jsp 5713 2011-09-02 13:01:58Z 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 | @author Nicklas |
---|
23 | @since 2.0 |
---|
24 | --%> |
---|
25 | <%@ page pageEncoding="UTF-8" session="false" |
---|
26 | import="net.sf.basedb.core.SessionControl" |
---|
27 | import="net.sf.basedb.core.DbControl" |
---|
28 | import="net.sf.basedb.core.SystemItems" |
---|
29 | import="net.sf.basedb.core.Include" |
---|
30 | import="net.sf.basedb.core.Item" |
---|
31 | import="net.sf.basedb.core.ItemContext" |
---|
32 | import="net.sf.basedb.core.ItemQuery" |
---|
33 | import="net.sf.basedb.core.ItemResultList" |
---|
34 | import="net.sf.basedb.core.Permission" |
---|
35 | import="net.sf.basedb.core.ItemSubtype" |
---|
36 | import="net.sf.basedb.core.DataFileType" |
---|
37 | import="net.sf.basedb.core.ItemSubtypeFileType" |
---|
38 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
39 | import="net.sf.basedb.core.PluginDefinition" |
---|
40 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
41 | import="net.sf.basedb.core.plugin.Plugin" |
---|
42 | import="net.sf.basedb.core.query.Orders" |
---|
43 | import="net.sf.basedb.core.query.Hql" |
---|
44 | import="net.sf.basedb.clients.web.Base" |
---|
45 | import="net.sf.basedb.clients.web.PermissionUtil" |
---|
46 | import="net.sf.basedb.clients.web.util.HTML" |
---|
47 | import="net.sf.basedb.util.Values" |
---|
48 | import="net.sf.basedb.util.formatter.Formatter" |
---|
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 | %> |
---|
58 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
59 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
60 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
61 | <%@ taglib prefix="p" uri="/WEB-INF/path.tld" %> |
---|
62 | <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
---|
63 | <%! |
---|
64 | private static final Item itemType = Item.ITEMSUBTYPE; |
---|
65 | private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM); |
---|
66 | %> |
---|
67 | <% |
---|
68 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
69 | final String ID = sc.getId(); |
---|
70 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
71 | final int itemId = cc.getId(); |
---|
72 | final float scale = Base.getScale(sc); |
---|
73 | final DbControl dc = sc.newDbControl(); |
---|
74 | try |
---|
75 | { |
---|
76 | Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
---|
77 | Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); |
---|
78 | |
---|
79 | String title = null; |
---|
80 | ItemSubtype subtype = ItemSubtype.getById(dc, itemId); |
---|
81 | |
---|
82 | final boolean usePermission = subtype.hasPermission(Permission.USE); |
---|
83 | final boolean writePermission = subtype.hasPermission(Permission.WRITE); |
---|
84 | final boolean deletePermission = subtype.hasPermission(Permission.DELETE); |
---|
85 | final boolean isRemoved = subtype.isRemoved(); |
---|
86 | final boolean isUsed = isRemoved && subtype.isUsed(); |
---|
87 | final boolean deletePermanentlyPermission = deletePermission && !isUsed; |
---|
88 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, subtype); |
---|
89 | ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext); |
---|
90 | %> |
---|
91 | <base:page title="<%=title%>"> |
---|
92 | <base:head scripts="tabcontrol.js,table.js" styles="toolbar.css,headertabcontrol.css,path.css,table.css"> |
---|
93 | <ext:scripts context="<%=jspContext%>" /> |
---|
94 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
95 | <script language="JavaScript"> |
---|
96 | function editItem() |
---|
97 | { |
---|
98 | Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true); |
---|
99 | } |
---|
100 | function deleteItem() |
---|
101 | { |
---|
102 | location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>'); |
---|
103 | } |
---|
104 | function restoreItem() |
---|
105 | { |
---|
106 | location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>'); |
---|
107 | } |
---|
108 | function deleteItemPermanently() |
---|
109 | { |
---|
110 | Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted'); |
---|
111 | } |
---|
112 | function itemDeleted() |
---|
113 | { |
---|
114 | Main.listItems('<%=ID%>', '<%=itemType.name()%>'); |
---|
115 | } |
---|
116 | function showUsingItems() |
---|
117 | { |
---|
118 | Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>); |
---|
119 | } |
---|
120 | function runPlugin(cmd) |
---|
121 | { |
---|
122 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540); |
---|
123 | } |
---|
124 | </script> |
---|
125 | </base:head> |
---|
126 | <base:body> |
---|
127 | <p> |
---|
128 | <p:path> |
---|
129 | <p:pathelement title="Item subtypes" href="<%="index.jsp?ID="+ID%>" /> |
---|
130 | <p:pathelement title="<%=HTML.encodeTags(subtype.getName())%>" /> |
---|
131 | </p:path> |
---|
132 | |
---|
133 | <t:tabcontrol id="main" active="properties"> |
---|
134 | <t:tab id="properties" title="Properties"> |
---|
135 | |
---|
136 | <tbl:toolbar |
---|
137 | > |
---|
138 | <tbl:button |
---|
139 | disabled="<%=writePermission ? false : true%>" |
---|
140 | image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" |
---|
141 | onclick="editItem()" |
---|
142 | title="Edit…" |
---|
143 | tooltip="<%=writePermission ? "Edit this item subtype" : "You do not have permission to edit this item subtype"%>" |
---|
144 | /> |
---|
145 | <tbl:button |
---|
146 | disabled="<%=deletePermission ? false : true%>" |
---|
147 | image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" |
---|
148 | onclick="deleteItem()" |
---|
149 | title="Delete" |
---|
150 | visible="<%=!subtype.isRemoved()%>" |
---|
151 | tooltip="<%=deletePermission ? "Delete this item subtype" : "You do not have permission to delete this item subtype"%>" |
---|
152 | /> |
---|
153 | <tbl:button |
---|
154 | disabled="<%=writePermission ? false : true%>" |
---|
155 | image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" |
---|
156 | onclick="restoreItem()" |
---|
157 | title="Restore" |
---|
158 | visible="<%=subtype.isRemoved()%>" |
---|
159 | tooltip="<%=writePermission ? "Restore this item subtype" : "You do not have permission to restore this item subtype"%>" |
---|
160 | /> |
---|
161 | <tbl:button |
---|
162 | image="export.gif" |
---|
163 | onclick="runPlugin('ExportItem')" |
---|
164 | title="Export…" |
---|
165 | tooltip="Export data" |
---|
166 | visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>" |
---|
167 | /> |
---|
168 | <tbl:button |
---|
169 | image="runplugin.gif" |
---|
170 | onclick="runPlugin('RunPlugin')" |
---|
171 | title="Run plugin…" |
---|
172 | tooltip="Run a plugin" |
---|
173 | visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>" |
---|
174 | /> |
---|
175 | <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" |
---|
176 | wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/> |
---|
177 | <tbl:button |
---|
178 | image="help.gif" |
---|
179 | onclick="<%="Main.openHelp('" + ID +"', 'itemsubtype.view.properties')"%>" |
---|
180 | title="Help…" |
---|
181 | tooltip="Get help about this page" |
---|
182 | /> |
---|
183 | </tbl:toolbar> |
---|
184 | <div class="boxedbottom"> |
---|
185 | <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(subtype)%></i></div> |
---|
186 | <% |
---|
187 | if (subtype.isRemoved()) |
---|
188 | { |
---|
189 | %> |
---|
190 | <div class="itemstatus"> |
---|
191 | <base:icon |
---|
192 | image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>" |
---|
193 | onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>" |
---|
194 | tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>" |
---|
195 | visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon> |
---|
196 | <base:icon image="used.gif" |
---|
197 | onclick="showUsingItems()" |
---|
198 | tooltip="Show the items that are using this one" |
---|
199 | visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon> |
---|
200 | </div> |
---|
201 | <% |
---|
202 | } |
---|
203 | %> |
---|
204 | <table class="form" cellspacing=0> |
---|
205 | <tr> |
---|
206 | <td class="prompt">Name</td> |
---|
207 | <td><%=HTML.encodeTags(subtype.getName())%></td> |
---|
208 | </tr> |
---|
209 | <tr> |
---|
210 | <td class="prompt">Main item type</td> |
---|
211 | <td><%=subtype.getMainItemType()%></td> |
---|
212 | </tr> |
---|
213 | <tr> |
---|
214 | <td class="prompt">Registered</td> |
---|
215 | <td><%=dateFormatter.format(subtype.getEntryDate())%></td> |
---|
216 | </tr> |
---|
217 | <tr> |
---|
218 | <td class="prompt">System ID</td> |
---|
219 | <td><%=HTML.encodeTags(subtype.getSystemId())%></td> |
---|
220 | </tr> |
---|
221 | <tr> |
---|
222 | <td class="prompt">Description</td> |
---|
223 | <td><%=HTML.niceFormat(subtype.getDescription())%></td> |
---|
224 | </tr> |
---|
225 | <tr> |
---|
226 | <td class="prompt">Related subtypes</td> |
---|
227 | <td></td> |
---|
228 | </tr> |
---|
229 | <% |
---|
230 | for (Item relatedItem : ItemSubtype.getRelatedItems(subtype.getMainItemType())) |
---|
231 | { |
---|
232 | ItemSubtype related = null; |
---|
233 | boolean deniedRelated = false; |
---|
234 | try |
---|
235 | { |
---|
236 | related = subtype.getRelatedSubtype(relatedItem); |
---|
237 | } |
---|
238 | catch (PermissionDeniedException ex) |
---|
239 | { |
---|
240 | deniedRelated = true; |
---|
241 | } |
---|
242 | %> |
---|
243 | <tr> |
---|
244 | <td class="subprompt"><%=relatedItem%></td> |
---|
245 | <td><%=Base.getLinkedName(ID, related, deniedRelated, true)%></td> |
---|
246 | </tr> |
---|
247 | <% |
---|
248 | } |
---|
249 | %> |
---|
250 | </table> |
---|
251 | |
---|
252 | <% |
---|
253 | ItemQuery<ItemSubtype> parentQuery = subtype.getParentSubtypes(); |
---|
254 | parentQuery.include(Include.ALL); |
---|
255 | parentQuery.order(Orders.asc(Hql.property("name"))); |
---|
256 | ItemResultList<ItemSubtype> parents = parentQuery.list(dc); |
---|
257 | if (parents.size() == 0) |
---|
258 | { |
---|
259 | %> |
---|
260 | <h4>Subtypes with relation to this subtype</h4> |
---|
261 | There are no subtypes (or, you don't have permission to view them). |
---|
262 | <% |
---|
263 | } |
---|
264 | else |
---|
265 | { |
---|
266 | %> |
---|
267 | <base:section |
---|
268 | id="parents" |
---|
269 | title="<%="Subtypes with relation to this subtype (" + parents.size() + ")"%>" |
---|
270 | context="<%=cc%>" |
---|
271 | > |
---|
272 | <tbl:table |
---|
273 | id="parents" |
---|
274 | clazz="itemlist" |
---|
275 | columns="all" |
---|
276 | > |
---|
277 | <tbl:columndef |
---|
278 | id="name" |
---|
279 | title="Name" |
---|
280 | /> |
---|
281 | <tbl:columndef |
---|
282 | id="mainType" |
---|
283 | title="Main item type" |
---|
284 | /> |
---|
285 | <tbl:columndef |
---|
286 | id="description" |
---|
287 | title="Description" |
---|
288 | /> |
---|
289 | <tbl:data> |
---|
290 | <tbl:columns> |
---|
291 | </tbl:columns> |
---|
292 | <tbl:rows> |
---|
293 | <% |
---|
294 | for (ItemSubtype parent : parents) |
---|
295 | { |
---|
296 | %> |
---|
297 | <tbl:row> |
---|
298 | <tbl:cell column="name"><base:icon |
---|
299 | image="deleted.gif" |
---|
300 | tooltip="This item has been scheduled for deletion" |
---|
301 | visible="<%=parent.isRemoved()%>" |
---|
302 | /><%=Base.getLinkedName(ID, parent, false, true)%></tbl:cell> |
---|
303 | <tbl:cell column="mainType"><%=parent.getMainItemType() %></tbl:cell> |
---|
304 | <tbl:cell column="description"><%=HTML.encodeTags(parent.getDescription())%></tbl:cell> |
---|
305 | </tbl:row> |
---|
306 | <% |
---|
307 | } |
---|
308 | %> |
---|
309 | </tbl:rows> |
---|
310 | </tbl:data> |
---|
311 | </tbl:table> |
---|
312 | </base:section> |
---|
313 | <% |
---|
314 | } |
---|
315 | %> |
---|
316 | |
---|
317 | <% |
---|
318 | ItemQuery<ItemSubtypeFileType> fileTypeQuery = subtype.getDataFileTypes(); |
---|
319 | fileTypeQuery.include(Include.ALL); |
---|
320 | fileTypeQuery.order(Orders.asc(Hql.property("itemSubtype.name"))); |
---|
321 | ItemResultList<ItemSubtypeFileType> fileTypes = fileTypeQuery.list(dc); |
---|
322 | if (fileTypes.size() == 0) |
---|
323 | { |
---|
324 | %> |
---|
325 | <h4>File types associated with this subtype</h4> |
---|
326 | There are no file types (or, you don't have permission to view them). |
---|
327 | <% |
---|
328 | } |
---|
329 | else |
---|
330 | { |
---|
331 | %> |
---|
332 | <base:section |
---|
333 | id="fileTypes" |
---|
334 | title="<%="File types associated with this subtype (" + fileTypes.size() + ")"%>" |
---|
335 | context="<%=cc%>" |
---|
336 | > |
---|
337 | <tbl:table |
---|
338 | id="fileTypes" |
---|
339 | clazz="itemlist" |
---|
340 | columns="all" |
---|
341 | > |
---|
342 | <tbl:columndef |
---|
343 | id="name" |
---|
344 | title="Name" |
---|
345 | /> |
---|
346 | <tbl:columndef |
---|
347 | id="extension" |
---|
348 | title="File extension" |
---|
349 | /> |
---|
350 | <tbl:columndef |
---|
351 | id="required" |
---|
352 | title="Required" |
---|
353 | /> |
---|
354 | <tbl:columndef |
---|
355 | id="multiple" |
---|
356 | title="Multiple files" |
---|
357 | /> |
---|
358 | <tbl:columndef |
---|
359 | id="genericType" |
---|
360 | title="Generic type" |
---|
361 | /> |
---|
362 | <tbl:columndef |
---|
363 | id="description" |
---|
364 | title="Description" |
---|
365 | /> |
---|
366 | <tbl:data> |
---|
367 | <tbl:columns> |
---|
368 | </tbl:columns> |
---|
369 | <tbl:rows> |
---|
370 | <% |
---|
371 | for (ItemSubtypeFileType fileType : fileTypes) |
---|
372 | { |
---|
373 | DataFileType dft = fileType.getDataFileType(); |
---|
374 | %> |
---|
375 | <tbl:row> |
---|
376 | <tbl:cell column="name"><base:icon |
---|
377 | image="deleted.gif" |
---|
378 | tooltip="This item has been scheduled for deletion" |
---|
379 | visible="<%=dft.isRemoved()%>" |
---|
380 | /><%=Base.getLinkedName(ID, dft, false, true)%></tbl:cell> |
---|
381 | <tbl:cell column="extension"><%=HTML.encodeTags(dft.getExtension()) %></tbl:cell> |
---|
382 | <tbl:cell column="required"><%=fileType.isRequired() ? "yes" : "no"%></tbl:cell> |
---|
383 | <tbl:cell column="multiple"><%=fileType.getAllowMultiple() ? "yes" : "no"%></tbl:cell> |
---|
384 | <tbl:cell column="genericType"><base:propertyvalue item="<%=dft%>" property="genericType" /></tbl:cell> |
---|
385 | <tbl:cell column="description"><%=HTML.encodeTags(dft.getDescription())%></tbl:cell> |
---|
386 | </tbl:row> |
---|
387 | <% |
---|
388 | } |
---|
389 | %> |
---|
390 | </tbl:rows> |
---|
391 | </tbl:data> |
---|
392 | </tbl:table> |
---|
393 | </base:section> |
---|
394 | <% |
---|
395 | } |
---|
396 | %> |
---|
397 | |
---|
398 | |
---|
399 | <jsp:include page="../../common/anytoany/list_anytoany.jsp"> |
---|
400 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
401 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
402 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
403 | <jsp:param name="title" value="Other items related to this item subtype" /> |
---|
404 | </jsp:include> |
---|
405 | |
---|
406 | </div> |
---|
407 | </t:tab> |
---|
408 | </t:tabcontrol> |
---|
409 | |
---|
410 | </base:body> |
---|
411 | </base:page> |
---|
412 | <% |
---|
413 | } |
---|
414 | finally |
---|
415 | { |
---|
416 | if (dc != null) dc.close(); |
---|
417 | } |
---|
418 | |
---|
419 | %> |
---|