1 | <%-- $Id: view_subtype.jsp 5941 2012-02-01 13:26:23Z 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, 750, 500); |
---|
123 | } |
---|
124 | </script> |
---|
125 | </base:head> |
---|
126 | <base:body> |
---|
127 | <p:path><p:pathelement |
---|
128 | title="Item subtypes" href="<%="index.jsp?ID="+ID%>" |
---|
129 | /><p:pathelement title="<%=HTML.encodeTags(subtype.getName())%>" |
---|
130 | /></p:path> |
---|
131 | |
---|
132 | <t:tabcontrol |
---|
133 | id="main" |
---|
134 | subclass="content mastertabcontrol" |
---|
135 | active="properties"> |
---|
136 | <t:tab id="properties" title="Properties"> |
---|
137 | <div> |
---|
138 | <table class="fullform bottomborder"> |
---|
139 | <tr> |
---|
140 | <th class="itemstatus"> |
---|
141 | <base:icon |
---|
142 | image="deleted.gif" |
---|
143 | onclick="deleteItemPermanently()" |
---|
144 | tooltip="This item has been flagged for deletion. Click to delete it now." |
---|
145 | enabled="<%=deletePermanentlyPermission %>" |
---|
146 | visible="<%=isRemoved%>" |
---|
147 | /> |
---|
148 | <base:icon image="used.gif" |
---|
149 | onclick="showUsingItems()" |
---|
150 | tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one" |
---|
151 | visible="<%=isRemoved && isUsed%>" /> |
---|
152 | </th> |
---|
153 | <td style="padding: 0px;"> |
---|
154 | <tbl:toolbar subclass="bottomborder"> |
---|
155 | <tbl:button |
---|
156 | disabled="<%=writePermission ? false : true%>" |
---|
157 | image="edit.gif" |
---|
158 | onclick="editItem()" |
---|
159 | title="Edit…" |
---|
160 | tooltip="<%=writePermission ? "Edit this item subtype" : "You do not have permission to edit this item subtype"%>" |
---|
161 | /> |
---|
162 | <tbl:button |
---|
163 | disabled="<%=deletePermission ? false : true%>" |
---|
164 | image="delete.gif" |
---|
165 | onclick="deleteItem()" |
---|
166 | title="Delete" |
---|
167 | visible="<%=!subtype.isRemoved()%>" |
---|
168 | tooltip="<%=deletePermission ? "Delete this item subtype" : "You do not have permission to delete this item subtype"%>" |
---|
169 | /> |
---|
170 | <tbl:button |
---|
171 | disabled="<%=writePermission ? false : true%>" |
---|
172 | image="restore.gif" |
---|
173 | onclick="restoreItem()" |
---|
174 | title="Restore" |
---|
175 | visible="<%=subtype.isRemoved()%>" |
---|
176 | tooltip="<%=writePermission ? "Restore this item subtype" : "You do not have permission to restore this item subtype"%>" |
---|
177 | /> |
---|
178 | <tbl:button |
---|
179 | image="export.gif" |
---|
180 | onclick="runPlugin('ExportItem')" |
---|
181 | title="Export…" |
---|
182 | tooltip="Export data" |
---|
183 | visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>" |
---|
184 | /> |
---|
185 | <tbl:button |
---|
186 | image="runplugin.gif" |
---|
187 | onclick="runPlugin('RunPlugin')" |
---|
188 | title="Run plugin…" |
---|
189 | tooltip="Run a plugin" |
---|
190 | visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>" |
---|
191 | /> |
---|
192 | <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" |
---|
193 | wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/> |
---|
194 | <tbl:button |
---|
195 | image="help.png" |
---|
196 | onclick="<%="Main.openHelp('" + ID +"', 'itemsubtype.view.properties')"%>" |
---|
197 | title="Help…" |
---|
198 | tooltip="Get help about this page" |
---|
199 | /> |
---|
200 | </tbl:toolbar> |
---|
201 | </td> |
---|
202 | </tr> |
---|
203 | <tr> |
---|
204 | <th>Name</th> |
---|
205 | <td><%=HTML.encodeTags(subtype.getName())%></td> |
---|
206 | </tr> |
---|
207 | <tr> |
---|
208 | <th>Main item type</th> |
---|
209 | <td><%=subtype.getMainItemType()%></td> |
---|
210 | </tr> |
---|
211 | <tr> |
---|
212 | <th>Registered</th> |
---|
213 | <td><%=dateFormatter.format(subtype.getEntryDate())%></td> |
---|
214 | </tr> |
---|
215 | <tr> |
---|
216 | <th>System ID</th> |
---|
217 | <td><%=HTML.encodeTags(subtype.getSystemId())%></td> |
---|
218 | </tr> |
---|
219 | <tr> |
---|
220 | <th>Permissions</th> |
---|
221 | <td><%=PermissionUtil.getFullPermissionNames(subtype)%></td> |
---|
222 | </tr> |
---|
223 | <tr> |
---|
224 | <th>Description</th> |
---|
225 | <td><%=HTML.niceFormat(subtype.getDescription())%></td> |
---|
226 | </tr> |
---|
227 | <tr> |
---|
228 | <th>Related subtypes</th> |
---|
229 | <td></td> |
---|
230 | </tr> |
---|
231 | <% |
---|
232 | for (Item relatedItem : ItemSubtype.getRelatedItems(subtype.getMainItemType())) |
---|
233 | { |
---|
234 | ItemSubtype related = null; |
---|
235 | boolean deniedRelated = false; |
---|
236 | try |
---|
237 | { |
---|
238 | related = subtype.getRelatedSubtype(relatedItem); |
---|
239 | } |
---|
240 | catch (PermissionDeniedException ex) |
---|
241 | { |
---|
242 | deniedRelated = true; |
---|
243 | } |
---|
244 | %> |
---|
245 | <tr> |
---|
246 | <th class="subprompt">- <%=relatedItem%></th> |
---|
247 | <td><%=Base.getLinkedName(ID, related, deniedRelated, true)%></td> |
---|
248 | </tr> |
---|
249 | <% |
---|
250 | } |
---|
251 | %> |
---|
252 | </table> |
---|
253 | </div> |
---|
254 | |
---|
255 | <% |
---|
256 | ItemQuery<ItemSubtype> parentQuery = subtype.getParentSubtypes(); |
---|
257 | parentQuery.include(Include.ALL); |
---|
258 | parentQuery.order(Orders.asc(Hql.property("name"))); |
---|
259 | ItemResultList<ItemSubtype> parents = parentQuery.list(dc); |
---|
260 | %> |
---|
261 | <base:section |
---|
262 | id="parents" |
---|
263 | title="<%="Subtypes with relation to this subtype (" + parents.size() + ")"%>" |
---|
264 | context="<%=cc%>" |
---|
265 | > |
---|
266 | <% |
---|
267 | if (parents.size() == 0) |
---|
268 | { |
---|
269 | %> |
---|
270 | <div class="messagecontainer note"> |
---|
271 | There are no subtypes (or, you don't have permission to view them). |
---|
272 | </div> |
---|
273 | <% |
---|
274 | } |
---|
275 | else |
---|
276 | { |
---|
277 | %> |
---|
278 | <tbl:table |
---|
279 | id="parents" |
---|
280 | columns="all" |
---|
281 | > |
---|
282 | <tbl:columndef |
---|
283 | id="name" |
---|
284 | title="Name" |
---|
285 | /> |
---|
286 | <tbl:columndef |
---|
287 | id="mainType" |
---|
288 | title="Main item type" |
---|
289 | /> |
---|
290 | <tbl:columndef |
---|
291 | id="description" |
---|
292 | title="Description" |
---|
293 | /> |
---|
294 | <tbl:data> |
---|
295 | <tbl:headers> |
---|
296 | <tbl:headerrow> |
---|
297 | <tbl:columnheaders /> |
---|
298 | </tbl:headerrow> |
---|
299 | </tbl:headers> |
---|
300 | <tbl:rows> |
---|
301 | <% |
---|
302 | for (ItemSubtype parent : parents) |
---|
303 | { |
---|
304 | %> |
---|
305 | <tbl:row> |
---|
306 | <tbl:cell column="name"><base:icon |
---|
307 | image="deleted.gif" |
---|
308 | tooltip="This item has been scheduled for deletion" |
---|
309 | visible="<%=parent.isRemoved()%>" |
---|
310 | /><%=Base.getLinkedName(ID, parent, false, true)%></tbl:cell> |
---|
311 | <tbl:cell column="mainType"><%=parent.getMainItemType() %></tbl:cell> |
---|
312 | <tbl:cell column="description"><%=HTML.encodeTags(parent.getDescription())%></tbl:cell> |
---|
313 | </tbl:row> |
---|
314 | <% |
---|
315 | } |
---|
316 | %> |
---|
317 | </tbl:rows> |
---|
318 | </tbl:data> |
---|
319 | </tbl:table> |
---|
320 | <% |
---|
321 | } |
---|
322 | %> |
---|
323 | </base:section> |
---|
324 | |
---|
325 | <% |
---|
326 | ItemQuery<ItemSubtypeFileType> fileTypeQuery = subtype.getDataFileTypes(); |
---|
327 | fileTypeQuery.include(Include.ALL); |
---|
328 | fileTypeQuery.order(Orders.asc(Hql.property("itemSubtype.name"))); |
---|
329 | ItemResultList<ItemSubtypeFileType> fileTypes = fileTypeQuery.list(dc); |
---|
330 | %> |
---|
331 | <base:section |
---|
332 | id="fileTypes" |
---|
333 | title="<%="File types associated with this subtype (" + fileTypes.size() + ")"%>" |
---|
334 | context="<%=cc%>" |
---|
335 | > |
---|
336 | <% |
---|
337 | if (fileTypes.size() == 0) |
---|
338 | { |
---|
339 | %> |
---|
340 | <div class="messagecontainer note"> |
---|
341 | There are no file types (or, you don't have permission to view them). |
---|
342 | </div> |
---|
343 | <% |
---|
344 | } |
---|
345 | else |
---|
346 | { |
---|
347 | %> |
---|
348 | <tbl:table |
---|
349 | id="fileTypes" |
---|
350 | columns="all" |
---|
351 | > |
---|
352 | <tbl:columndef |
---|
353 | id="name" |
---|
354 | title="Name" |
---|
355 | /> |
---|
356 | <tbl:columndef |
---|
357 | id="extension" |
---|
358 | title="File extension" |
---|
359 | /> |
---|
360 | <tbl:columndef |
---|
361 | id="required" |
---|
362 | title="Required" |
---|
363 | /> |
---|
364 | <tbl:columndef |
---|
365 | id="multiple" |
---|
366 | title="Multiple files" |
---|
367 | /> |
---|
368 | <tbl:columndef |
---|
369 | id="genericType" |
---|
370 | title="Generic type" |
---|
371 | /> |
---|
372 | <tbl:columndef |
---|
373 | id="description" |
---|
374 | title="Description" |
---|
375 | /> |
---|
376 | <tbl:data> |
---|
377 | <tbl:headers> |
---|
378 | <tbl:headerrow> |
---|
379 | <tbl:columnheaders /> |
---|
380 | </tbl:headerrow> |
---|
381 | </tbl:headers> |
---|
382 | <tbl:rows> |
---|
383 | <% |
---|
384 | for (ItemSubtypeFileType fileType : fileTypes) |
---|
385 | { |
---|
386 | DataFileType dft = fileType.getDataFileType(); |
---|
387 | %> |
---|
388 | <tbl:row> |
---|
389 | <tbl:cell column="name"><base:icon |
---|
390 | image="deleted.gif" |
---|
391 | tooltip="This item has been scheduled for deletion" |
---|
392 | visible="<%=dft.isRemoved()%>" |
---|
393 | /><%=Base.getLinkedName(ID, dft, false, true)%></tbl:cell> |
---|
394 | <tbl:cell column="extension"><%=HTML.encodeTags(dft.getExtension()) %></tbl:cell> |
---|
395 | <tbl:cell column="required"><%=fileType.isRequired() ? "yes" : "no"%></tbl:cell> |
---|
396 | <tbl:cell column="multiple"><%=fileType.getAllowMultiple() ? "yes" : "no"%></tbl:cell> |
---|
397 | <tbl:cell column="genericType"><base:propertyvalue item="<%=dft%>" property="genericType" /></tbl:cell> |
---|
398 | <tbl:cell column="description"><%=HTML.encodeTags(dft.getDescription())%></tbl:cell> |
---|
399 | </tbl:row> |
---|
400 | <% |
---|
401 | } |
---|
402 | %> |
---|
403 | </tbl:rows> |
---|
404 | </tbl:data> |
---|
405 | </tbl:table> |
---|
406 | <% |
---|
407 | } |
---|
408 | %> |
---|
409 | </base:section> |
---|
410 | <jsp:include page="../../common/anytoany/list_anytoany.jsp"> |
---|
411 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
412 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
413 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
414 | <jsp:param name="title" value="Other items related to this item subtype" /> |
---|
415 | </jsp:include> |
---|
416 | </t:tab> |
---|
417 | </t:tabcontrol> |
---|
418 | </base:body> |
---|
419 | </base:page> |
---|
420 | <% |
---|
421 | } |
---|
422 | finally |
---|
423 | { |
---|
424 | if (dc != null) dc.close(); |
---|
425 | } |
---|
426 | |
---|
427 | %> |
---|