1 | <%-- $Id: info.jsp 5104 2009-09-28 09:39:57Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2009 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 | <%@ page session="false" |
---|
23 | import="net.sf.basedb.core.SessionControl" |
---|
24 | import="net.sf.basedb.core.DbControl" |
---|
25 | import="net.sf.basedb.core.Project" |
---|
26 | import="net.sf.basedb.core.Item" |
---|
27 | import="net.sf.basedb.core.BasicItem" |
---|
28 | import="net.sf.basedb.core.Nameable" |
---|
29 | import="net.sf.basedb.core.Annotatable" |
---|
30 | import="net.sf.basedb.core.AnnotationSet" |
---|
31 | import="net.sf.basedb.core.AnnotationType" |
---|
32 | import="net.sf.basedb.core.Annotation" |
---|
33 | import="net.sf.basedb.core.FileStoreEnabled" |
---|
34 | import="net.sf.basedb.core.FileSetMember" |
---|
35 | import="net.sf.basedb.core.File" |
---|
36 | import="net.sf.basedb.core.DataFileType" |
---|
37 | import="net.sf.basedb.core.ItemContext" |
---|
38 | import="net.sf.basedb.core.Permission" |
---|
39 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
40 | import="net.sf.basedb.core.ItemNotFoundException" |
---|
41 | import="net.sf.basedb.clients.web.Base" |
---|
42 | import="net.sf.basedb.clients.web.util.HTML" |
---|
43 | import="net.sf.basedb.util.Values" |
---|
44 | import="net.sf.basedb.util.NestedIterator" |
---|
45 | import="net.sf.basedb.util.overview.GenericOverview" |
---|
46 | import="net.sf.basedb.util.overview.OverviewUtil" |
---|
47 | import="net.sf.basedb.util.overview.Node" |
---|
48 | import="net.sf.basedb.util.overview.ValidationOptions" |
---|
49 | import="net.sf.basedb.util.overview.Validator" |
---|
50 | import="net.sf.basedb.util.overview.Severity" |
---|
51 | import="net.sf.basedb.util.overview.Failure" |
---|
52 | import="net.sf.basedb.util.overview.Fix" |
---|
53 | import="java.util.ArrayList" |
---|
54 | import="java.util.List" |
---|
55 | import="java.util.LinkedList" |
---|
56 | import="java.util.Iterator" |
---|
57 | import="java.util.Collection" |
---|
58 | import="java.util.Collections" |
---|
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 | <%! |
---|
64 | private String getPath(String ID, Node node) |
---|
65 | { |
---|
66 | Node parent = node.getParent(); |
---|
67 | if (parent == null) return ""; |
---|
68 | String path = getPath(ID, parent); |
---|
69 | if (parent.getNodeType() == Node.Type.FOLDER) |
---|
70 | { |
---|
71 | //path += "/" + HTML.encodeTags(parent.getTitle()); |
---|
72 | } |
---|
73 | else |
---|
74 | { |
---|
75 | BasicItem item = parent.getItem(); |
---|
76 | if (path.length() > 0) |
---|
77 | { |
---|
78 | path += "<img src=\"../../images/submenu.gif\" style=\"padding: 0px 4px 5px 6px;\" >"; |
---|
79 | } |
---|
80 | path += Base.getLink(ID, parent.getTitle(), item.getType(), item.getId(), item.hasPermission(Permission.WRITE)); |
---|
81 | // path += "<a href=\"javascript:Main.editItem('" + item.getType().name() + "', " + item.getId() + |
---|
82 | // ")\" title=\"Edit this item\" style=\"padding-right: 4px; white-space: nowrap;\">" + HTML.encodeTags(parent.getTitle()) + "</a>"; |
---|
83 | } |
---|
84 | return path; |
---|
85 | } |
---|
86 | %> |
---|
87 | <% |
---|
88 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
89 | final String ID = sc.getId(); |
---|
90 | final float scale = Base.getScale(sc); |
---|
91 | final DbControl dc = sc.newDbControl(); |
---|
92 | try |
---|
93 | { |
---|
94 | GenericOverview overview = OverviewUtil.getCurrentOverview(sc); |
---|
95 | ValidationOptions options = overview.getValidationOptions(); |
---|
96 | String nodeId = request.getParameter("nodeId"); |
---|
97 | Boolean showFailures = Values.getBoolean(request.getParameter("show_failures"), false); |
---|
98 | Node node = overview.getNode(nodeId); |
---|
99 | if (node == null) node = overview.getRootNode(); |
---|
100 | |
---|
101 | BasicItem item = node.getItem(); |
---|
102 | List<Failure> failures = overview.getFailures(); |
---|
103 | if (failures == null) failures = new LinkedList<Failure>(); |
---|
104 | %> |
---|
105 | <base:page title="" type="popup"> |
---|
106 | <base:head scripts="" styles="newjoust.css"> |
---|
107 | <script language="JavaScript"> |
---|
108 | function editItem(itemType, itemId, extraUrl) |
---|
109 | { |
---|
110 | Main.viewOrEditItem('<%=ID%>', itemType, itemId, true, extraUrl); |
---|
111 | } |
---|
112 | function editAnnotation(itemType, itemId, annotationTypeId) |
---|
113 | { |
---|
114 | var url = getRoot() + 'common/annotations/annotate.jsp?ID=<%=ID%>'; |
---|
115 | url += '&item_type=' + itemType; |
---|
116 | url += '&item_id=' + itemId; |
---|
117 | url += '&annotationtype_id='+annotationTypeId; |
---|
118 | url += '&standalone=1'; |
---|
119 | Main.openPopup(url, 'EditAnnotation', 700, 460); |
---|
120 | } |
---|
121 | function editInheritedAnnotation(itemType, itemId, annotationTypeId) |
---|
122 | { |
---|
123 | var url = getRoot() + 'common/annotations/inherit.jsp?ID=<%=ID%>'; |
---|
124 | url += '&item_type='+itemType; |
---|
125 | url += '&item_id='+itemId; |
---|
126 | url += '&annotationtype_id='+annotationTypeId; |
---|
127 | url += '&standalone=1'; |
---|
128 | Main.openPopup(url, 'EditAnnotation', 700, 460); |
---|
129 | } |
---|
130 | function editDataFile(itemType, itemId) |
---|
131 | { |
---|
132 | Main.viewOrEditItem('<%=ID%>', itemType, itemId, true, '&tab=datafiles'); |
---|
133 | } |
---|
134 | </script> |
---|
135 | </base:head> |
---|
136 | |
---|
137 | <base:body> |
---|
138 | <table class="form"> |
---|
139 | <tr> |
---|
140 | <td class="prompt">Path</td> |
---|
141 | <td><%=getPath(ID, node)%></td> |
---|
142 | </tr> |
---|
143 | <% |
---|
144 | if (item instanceof FileSetMember) |
---|
145 | { |
---|
146 | FileSetMember member = null; |
---|
147 | boolean notFound = false; |
---|
148 | try |
---|
149 | { |
---|
150 | member = FileSetMember.getById(dc, item.getId()); |
---|
151 | } |
---|
152 | catch (ItemNotFoundException ex) |
---|
153 | { |
---|
154 | notFound = true; |
---|
155 | } |
---|
156 | File file = null; |
---|
157 | DataFileType dft = null; |
---|
158 | boolean deniedFile = false; |
---|
159 | boolean deniedFileType = false; |
---|
160 | if (member != null) |
---|
161 | { |
---|
162 | try |
---|
163 | { |
---|
164 | file = member.getFile(); |
---|
165 | } |
---|
166 | catch (PermissionDeniedException ex) |
---|
167 | { |
---|
168 | deniedFile = true; |
---|
169 | } |
---|
170 | try |
---|
171 | { |
---|
172 | dft = member.getDataFileType(); |
---|
173 | } |
---|
174 | catch (PermissionDeniedException ex) |
---|
175 | { |
---|
176 | deniedFileType = true; |
---|
177 | } |
---|
178 | } |
---|
179 | if (dft != null || file != null) |
---|
180 | { |
---|
181 | %> |
---|
182 | <tr> |
---|
183 | <td class="prompt"> |
---|
184 | <%=dft == null ? "Data file" : HTML.encodeTags(dft.getName())%> |
---|
185 | </td> |
---|
186 | <td> |
---|
187 | <%=Base.getLinkedFile(ID, file, deniedFile, true, true, "../../")%> |
---|
188 | </td> |
---|
189 | </tr> |
---|
190 | <% |
---|
191 | } |
---|
192 | else |
---|
193 | { |
---|
194 | %> |
---|
195 | <tr> |
---|
196 | <td class="prompt"><%=HTML.encodeTags(node.getTitle())%></td> |
---|
197 | <td> |
---|
198 | <%=notFound ? "<i>- not found -</i>" : "<i>- denied -</i>"%> |
---|
199 | </td> |
---|
200 | </tr> |
---|
201 | <% |
---|
202 | } |
---|
203 | } |
---|
204 | else |
---|
205 | { |
---|
206 | %> |
---|
207 | <tr> |
---|
208 | <td class="prompt"><%=node.getNodeType() == Node.Type.FOLDER ? |
---|
209 | "Folder" : item != null ? item.getType().toString() : "Item"%></td> |
---|
210 | <td> |
---|
211 | <% |
---|
212 | if (item != null) |
---|
213 | { |
---|
214 | %> |
---|
215 | <%=Base.getLink(ID, node.getTitle(), item.getType(),item.getId(), item.hasPermission(Permission.WRITE))%> |
---|
216 | <% |
---|
217 | } |
---|
218 | else |
---|
219 | { |
---|
220 | %> |
---|
221 | <%=HTML.encodeTags(node.getTitle())%> |
---|
222 | <% |
---|
223 | } |
---|
224 | %> |
---|
225 | </td> |
---|
226 | </tr> |
---|
227 | <% |
---|
228 | } |
---|
229 | %> |
---|
230 | <tr> |
---|
231 | <td class="prompt">Errors (children)</td> |
---|
232 | <% |
---|
233 | if (showFailures) |
---|
234 | { |
---|
235 | %> |
---|
236 | <td><%=node.getNumErrors()+node.getChildErrors()%> (<%=node.getChildErrors()%>)</td> |
---|
237 | <% |
---|
238 | } |
---|
239 | else |
---|
240 | { |
---|
241 | %> |
---|
242 | <td><i>- n/a -</i></td> |
---|
243 | <% |
---|
244 | } |
---|
245 | %> |
---|
246 | </tr> |
---|
247 | <tr> |
---|
248 | <td class="prompt">Warnings (children)</td> |
---|
249 | <% |
---|
250 | if (showFailures) |
---|
251 | { |
---|
252 | %> |
---|
253 | <td><%=node.getNumWarnings()+node.getChildWarnings()%> (<%=node.getChildWarnings()%>)</td> |
---|
254 | <% |
---|
255 | } |
---|
256 | else |
---|
257 | { |
---|
258 | %> |
---|
259 | <td><i>- n/a -</i></td> |
---|
260 | <% |
---|
261 | } |
---|
262 | %> |
---|
263 | </tr> |
---|
264 | <% |
---|
265 | if (item instanceof Nameable) |
---|
266 | { |
---|
267 | Nameable nameable = (Nameable)item; |
---|
268 | %> |
---|
269 | <tr> |
---|
270 | <td class="prompt">Description</td> |
---|
271 | <td><%=HTML.niceFormat(nameable.getDescription())%></td> |
---|
272 | </tr> |
---|
273 | <% |
---|
274 | } |
---|
275 | %> |
---|
276 | </table> |
---|
277 | <p> |
---|
278 | |
---|
279 | <% |
---|
280 | List<Annotation> annotations = null; |
---|
281 | String annotationsTitle = ""; |
---|
282 | Annotatable annotatable = null; |
---|
283 | if (item instanceof Annotation) |
---|
284 | { |
---|
285 | Annotation a = (Annotation)item; |
---|
286 | dc.reattachItem(a, false); |
---|
287 | annotations = Collections.singletonList(a); |
---|
288 | try |
---|
289 | { |
---|
290 | annotatable = a.getAnnotationSet().getItem(); |
---|
291 | } |
---|
292 | catch (Throwable t) |
---|
293 | {} |
---|
294 | annotationsTitle = "Annotation values"; |
---|
295 | } |
---|
296 | else if (item instanceof AnnotationType) |
---|
297 | { |
---|
298 | // Find the annotatable parent |
---|
299 | Node parentNode = node; |
---|
300 | while (parentNode != null) |
---|
301 | { |
---|
302 | BasicItem parentItem = parentNode.getItem(); |
---|
303 | if (parentItem instanceof Annotatable) |
---|
304 | { |
---|
305 | annotatable = (Annotatable)parentItem; |
---|
306 | dc.reattachItem((BasicItem)annotatable, false); |
---|
307 | if (annotatable.isAnnotated()) |
---|
308 | { |
---|
309 | annotations = annotatable.getAnnotationSet().findAnnotations(dc, (AnnotationType)item, true); |
---|
310 | } |
---|
311 | annotationsTitle = "Annotation values"; |
---|
312 | break; |
---|
313 | } |
---|
314 | parentNode = parentNode.getParent(); |
---|
315 | } |
---|
316 | } |
---|
317 | else if (item instanceof Annotatable) |
---|
318 | { |
---|
319 | annotationsTitle = "Annotations & protocol parameters"; |
---|
320 | annotatable = (Annotatable)item; |
---|
321 | if (annotatable.isAnnotated()) |
---|
322 | { |
---|
323 | dc.reattachItem((BasicItem)annotatable, false); |
---|
324 | |
---|
325 | // Load annotations & protocol parameters |
---|
326 | List<Node> nodes = new LinkedList<Node>(); |
---|
327 | Node folder = node.getChild("annotations"); |
---|
328 | if (folder != null && folder.getChildren() != null) nodes.addAll(folder.getChildren()); |
---|
329 | Node protocolNode = node.getChild("protocol"); |
---|
330 | if (protocolNode != null && protocolNode.getChildren() != null) nodes.addAll(protocolNode.getChildren()); |
---|
331 | if (nodes.size() > 0) |
---|
332 | { |
---|
333 | annotations = new LinkedList<Annotation>(); |
---|
334 | for (Node n : nodes) |
---|
335 | { |
---|
336 | BasicItem aItem = n.getItem(); |
---|
337 | if (aItem instanceof Annotation) |
---|
338 | { |
---|
339 | annotations.add((Annotation)aItem); |
---|
340 | } |
---|
341 | else if (aItem instanceof AnnotationType) |
---|
342 | { |
---|
343 | annotations.addAll(annotatable.getAnnotationSet().findAnnotations(dc, (AnnotationType)aItem, true)); |
---|
344 | } |
---|
345 | } |
---|
346 | } |
---|
347 | } |
---|
348 | } |
---|
349 | if (annotations != null && annotations.size() > 0) |
---|
350 | { |
---|
351 | %> |
---|
352 | <h4><%=annotationsTitle%></h4> |
---|
353 | <table border=0 cellspacing=0 cellpadding=0> |
---|
354 | <% |
---|
355 | for (Annotation a : annotations) |
---|
356 | { |
---|
357 | a = Annotation.getById(dc, a.getId()); |
---|
358 | String unitSymbol = a.hasUnit() ? " " + a.getUnitSymbol(null) : ""; |
---|
359 | AnnotationType at = null; |
---|
360 | Annotatable annotationOwner = null; |
---|
361 | try |
---|
362 | { |
---|
363 | at = a.getAnnotationType(); |
---|
364 | } |
---|
365 | catch (Throwable t) |
---|
366 | {} |
---|
367 | try |
---|
368 | { |
---|
369 | annotationOwner = a.getAnnotationSet().getItem(); |
---|
370 | } |
---|
371 | catch (Throwable t) |
---|
372 | {} |
---|
373 | String icon = at != null && at.isProtocolParameter() ? |
---|
374 | "parameter.gif" : "joust/annotation.gif"; |
---|
375 | String editLink = null; |
---|
376 | String editTooltip = null; |
---|
377 | if (annotatable != null && annotatable.hasPermission(Permission.WRITE) && at != null) |
---|
378 | { |
---|
379 | if (annotatable.equals(annotationOwner)) |
---|
380 | { |
---|
381 | editLink = "editAnnotation('" + annotatable.getType().name() + "', " + annotatable.getId() + ", " + at.getId() + ")"; |
---|
382 | editTooltip = "Edit the values of this annotation"; |
---|
383 | } |
---|
384 | else |
---|
385 | { |
---|
386 | editLink = "editInheritedAnnotation('" + annotatable.getType().name() + "', " + annotatable.getId() + ", " + at.getId() + ")"; |
---|
387 | editTooltip = "Inherit this annotation from another item"; |
---|
388 | } |
---|
389 | } |
---|
390 | %> |
---|
391 | <tr> |
---|
392 | <td><base:icon visible="<%=icon != null%>" image="<%=icon%>" /> </td> |
---|
393 | <td> |
---|
394 | <% |
---|
395 | if (at != null) |
---|
396 | { |
---|
397 | %> |
---|
398 | <%=Base.getLinkedName(ID, at, false, true)%> |
---|
399 | <% |
---|
400 | } |
---|
401 | else |
---|
402 | { |
---|
403 | %> |
---|
404 | <%=a.getValueType() %> |
---|
405 | <% |
---|
406 | } |
---|
407 | %> |
---|
408 | </td> |
---|
409 | <td> |
---|
410 | <% |
---|
411 | if (annotationOwner != null && !annotationOwner.equals(annotatable)) |
---|
412 | { |
---|
413 | String ownerName = annotationOwner instanceof Nameable ? |
---|
414 | ((Nameable)annotationOwner).getName() : annotationOwner.toString(); |
---|
415 | %> |
---|
416 | <base:icon image="bullet.gif" tooltip="Annotation is inherited from" /> |
---|
417 | <%=Base.getLink(ID, ownerName, annotationOwner.getType(), annotationOwner.getId(), annotationOwner.hasPermission(Permission.WRITE)) %> |
---|
418 | <% |
---|
419 | } |
---|
420 | %> |
---|
421 | </td> |
---|
422 | <td><base:icon image="bullet.gif" /></td> |
---|
423 | <td><%=Values.getString(a.getValues(null), ", ", true)%><%=unitSymbol%></td> |
---|
424 | <td> |
---|
425 | <% |
---|
426 | if (editLink != null) |
---|
427 | { |
---|
428 | %><base:icon image="edit.gif" onclick="<%=editLink%>" |
---|
429 | tooltip="<%=editTooltip%>" /> |
---|
430 | <% |
---|
431 | } |
---|
432 | %> |
---|
433 | </td> |
---|
434 | </tr> |
---|
435 | <% |
---|
436 | } |
---|
437 | %> |
---|
438 | </table> |
---|
439 | <% |
---|
440 | } |
---|
441 | if (showFailures) |
---|
442 | { |
---|
443 | %> |
---|
444 | <h4>Failure details</h4> |
---|
445 | <table> |
---|
446 | <% |
---|
447 | int numFailures = 0; |
---|
448 | for (Failure failure : failures) |
---|
449 | { |
---|
450 | Validator validator = failure.getValidator(); |
---|
451 | Severity severity = options.getSeverity(validator); |
---|
452 | if (failure.getNode() == node && severity != Severity.IGNORE) |
---|
453 | { |
---|
454 | numFailures++; |
---|
455 | List<Fix> fixes = failure.getFixes(); |
---|
456 | %> |
---|
457 | <tr> |
---|
458 | <td><base:icon image="<%=severity == Severity.ERROR ? |
---|
459 | "error.gif" : "warning.gif"%>" /></td> |
---|
460 | <td><b><%=HTML.encodeTags(failure.getMessage())%></b></td> |
---|
461 | </tr> |
---|
462 | <tr> |
---|
463 | <td style="border-bottom: 1px dotted #999999;"></td> |
---|
464 | <td style="border-bottom: 1px dotted #999999;"> |
---|
465 | <%=HTML.encodeTags(validator.getDescription())%><br> |
---|
466 | <% |
---|
467 | if (fixes != null && fixes.size() > 0) |
---|
468 | { |
---|
469 | for (Fix fix : fixes) |
---|
470 | { |
---|
471 | if (fix == null) continue; |
---|
472 | BasicItem fixItem = fix.getItem(); |
---|
473 | if (fixItem.hasPermission(Permission.WRITE)) |
---|
474 | { |
---|
475 | String fixIt = ""; |
---|
476 | if (fix.isAnnotationFix()) |
---|
477 | { |
---|
478 | AnnotationType at = fix.getAnnotationType(); |
---|
479 | if (fix.isFromInherited()) |
---|
480 | { |
---|
481 | fixIt = "editInheritedAnnotation('" + fixItem.getType().name() + "', " + |
---|
482 | fixItem.getId() + ", " + at.getId() + ")"; |
---|
483 | } |
---|
484 | else |
---|
485 | { |
---|
486 | fixIt = "editAnnotation('" + fixItem.getType().name() + "', " + |
---|
487 | fixItem.getId() + ", " + at.getId() + ")"; |
---|
488 | } |
---|
489 | } |
---|
490 | else if (fix.isDataFileFix()) |
---|
491 | { |
---|
492 | FileSetMember member = fix.getFileSetMember(); |
---|
493 | fixIt = "editDataFile('" + fixItem.getType().name() + "', " + |
---|
494 | fixItem.getId() + ")"; |
---|
495 | } |
---|
496 | else |
---|
497 | { |
---|
498 | fixIt = "editItem('" + fixItem.getType().name() + "', " + |
---|
499 | fixItem.getId() + ")"; |
---|
500 | } |
---|
501 | %> |
---|
502 | <base:icon image="fixit.png" |
---|
503 | style="padding-bottom: 4px;" /><a href="javascript:<%=fixIt%>" |
---|
504 | title="Edit this item to fix the problem"><%=HTML.encodeTags(fix.getMessage())%></a><br> |
---|
505 | <% |
---|
506 | } |
---|
507 | } |
---|
508 | } |
---|
509 | %> |
---|
510 | </td> |
---|
511 | </tr> |
---|
512 | <% |
---|
513 | } |
---|
514 | } |
---|
515 | %> |
---|
516 | </table> |
---|
517 | <% |
---|
518 | if (numFailures == 0) |
---|
519 | { |
---|
520 | %> |
---|
521 | No validation failures on this item |
---|
522 | <% |
---|
523 | } |
---|
524 | } |
---|
525 | %> |
---|
526 | </base:body> |
---|
527 | </base:page> |
---|
528 | <% |
---|
529 | } |
---|
530 | finally |
---|
531 | { |
---|
532 | if (dc != null) dc.close(); |
---|
533 | } |
---|
534 | %> |
---|