927 |
13 Jul 05 |
nicklas |
1 |
<%-- $Id$ |
927 |
13 Jul 05 |
nicklas |
2 |
------------------------------------------------------------------ |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2005 Nicklas Nordborg |
5425 |
23 Sep 10 |
nicklas |
Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2007 Nicklas Nordborg |
927 |
13 Jul 05 |
nicklas |
6 |
|
2304 |
22 May 06 |
jari |
7 |
This file is part of BASE - BioArray Software Environment. |
2304 |
22 May 06 |
jari |
8 |
Available at http://base.thep.lu.se/ |
927 |
13 Jul 05 |
nicklas |
9 |
|
927 |
13 Jul 05 |
nicklas |
10 |
BASE is free software; you can redistribute it and/or |
927 |
13 Jul 05 |
nicklas |
11 |
modify it under the terms of the GNU General Public License |
4476 |
05 Sep 08 |
jari |
12 |
as published by the Free Software Foundation; either version 3 |
927 |
13 Jul 05 |
nicklas |
13 |
of the License, or (at your option) any later version. |
927 |
13 Jul 05 |
nicklas |
14 |
|
927 |
13 Jul 05 |
nicklas |
15 |
BASE is distributed in the hope that it will be useful, |
927 |
13 Jul 05 |
nicklas |
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
927 |
13 Jul 05 |
nicklas |
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
927 |
13 Jul 05 |
nicklas |
18 |
GNU General Public License for more details. |
927 |
13 Jul 05 |
nicklas |
19 |
|
927 |
13 Jul 05 |
nicklas |
20 |
You should have received a copy of the GNU General Public License |
4510 |
11 Sep 08 |
jari |
21 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
927 |
13 Jul 05 |
nicklas |
22 |
------------------------------------------------------------------ |
927 |
13 Jul 05 |
nicklas |
23 |
|
927 |
13 Jul 05 |
nicklas |
24 |
This page is used to display and modify the attributes of |
927 |
13 Jul 05 |
nicklas |
25 |
the of a news item |
927 |
13 Jul 05 |
nicklas |
26 |
|
927 |
13 Jul 05 |
nicklas |
27 |
@author Nicklas |
927 |
13 Jul 05 |
nicklas |
28 |
@version 2.0 |
927 |
13 Jul 05 |
nicklas |
29 |
--%> |
5426 |
24 Sep 10 |
nicklas |
30 |
<%@ page pageEncoding="UTF-8" session="false" |
2166 |
19 Apr 06 |
nicklas |
31 |
import="net.sf.basedb.core.SessionControl" |
2166 |
19 Apr 06 |
nicklas |
32 |
import="net.sf.basedb.core.DbControl" |
2166 |
19 Apr 06 |
nicklas |
33 |
import="net.sf.basedb.core.Item" |
2166 |
19 Apr 06 |
nicklas |
34 |
import="net.sf.basedb.core.Type" |
2166 |
19 Apr 06 |
nicklas |
35 |
import="net.sf.basedb.core.BasicItem" |
2166 |
19 Apr 06 |
nicklas |
36 |
import="net.sf.basedb.core.Permission" |
2166 |
19 Apr 06 |
nicklas |
37 |
import="net.sf.basedb.core.Annotatable" |
2166 |
19 Apr 06 |
nicklas |
38 |
import="net.sf.basedb.core.AnnotationSet" |
2166 |
19 Apr 06 |
nicklas |
39 |
import="net.sf.basedb.core.Annotation" |
4131 |
08 Feb 08 |
nicklas |
40 |
import="net.sf.basedb.core.RawBioAssay" |
5642 |
26 May 11 |
nicklas |
41 |
import="net.sf.basedb.core.PhysicalBioAssay" |
5749 |
19 Sep 11 |
nicklas |
42 |
import="net.sf.basedb.core.DerivedBioAssay" |
5749 |
19 Sep 11 |
nicklas |
43 |
import="net.sf.basedb.core.Extract" |
5965 |
16 Feb 12 |
nicklas |
44 |
import="net.sf.basedb.core.ItemSubtype" |
2166 |
19 Apr 06 |
nicklas |
45 |
import="net.sf.basedb.core.ItemQuery" |
2166 |
19 Apr 06 |
nicklas |
46 |
import="net.sf.basedb.core.Include" |
2166 |
19 Apr 06 |
nicklas |
47 |
import="net.sf.basedb.core.Nameable" |
2166 |
19 Apr 06 |
nicklas |
48 |
import="net.sf.basedb.core.ItemResultList" |
2166 |
19 Apr 06 |
nicklas |
49 |
import="net.sf.basedb.core.AnnotationType" |
2166 |
19 Apr 06 |
nicklas |
50 |
import="net.sf.basedb.core.PermissionDeniedException" |
6091 |
24 Aug 12 |
nicklas |
51 |
import="net.sf.basedb.util.AnnotationUtil" |
6091 |
24 Aug 12 |
nicklas |
52 |
import="net.sf.basedb.core.Subtypable" |
2166 |
19 Apr 06 |
nicklas |
53 |
import="net.sf.basedb.core.query.Orders" |
2166 |
19 Apr 06 |
nicklas |
54 |
import="net.sf.basedb.core.query.Hql" |
6737 |
13 Feb 15 |
nicklas |
55 |
import="net.sf.basedb.core.query.Expressions" |
6737 |
13 Feb 15 |
nicklas |
56 |
import="net.sf.basedb.core.query.Restrictions" |
2166 |
19 Apr 06 |
nicklas |
57 |
import="net.sf.basedb.util.Tree" |
2166 |
19 Apr 06 |
nicklas |
58 |
import="net.sf.basedb.clients.web.Base" |
2229 |
10 May 06 |
nicklas |
59 |
import="net.sf.basedb.clients.web.WebException" |
2166 |
19 Apr 06 |
nicklas |
60 |
import="net.sf.basedb.clients.web.util.HTML" |
2753 |
20 Oct 06 |
nicklas |
61 |
import="net.sf.basedb.util.Values" |
2942 |
22 Nov 06 |
nicklas |
62 |
import="net.sf.basedb.util.formatter.Formatter" |
2942 |
22 Nov 06 |
nicklas |
63 |
import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
2166 |
19 Apr 06 |
nicklas |
64 |
import="java.util.List" |
2166 |
19 Apr 06 |
nicklas |
65 |
import="java.util.Set" |
2166 |
19 Apr 06 |
nicklas |
66 |
import="java.util.HashSet" |
2166 |
19 Apr 06 |
nicklas |
67 |
import="java.util.Map" |
2166 |
19 Apr 06 |
nicklas |
68 |
import="java.util.HashMap" |
6384 |
18 Dec 13 |
nicklas |
69 |
import="org.json.simple.JSONArray" |
6384 |
18 Dec 13 |
nicklas |
70 |
import="org.json.simple.JSONObject" |
927 |
13 Jul 05 |
nicklas |
71 |
%> |
927 |
13 Jul 05 |
nicklas |
72 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
2166 |
19 Apr 06 |
nicklas |
73 |
<%! |
6091 |
24 Aug 12 |
nicklas |
74 |
private void loadParents(DbControl dc, Set<AnnotationSet> parentAnnotations, Set<Annotatable> parentItems, Annotatable current) |
2166 |
19 Apr 06 |
nicklas |
75 |
{ |
6091 |
24 Aug 12 |
nicklas |
76 |
Set<Annotatable> parents = AnnotationUtil.getAllAnnotatableParentItems(dc, current, null); |
6091 |
24 Aug 12 |
nicklas |
77 |
for (Annotatable parent : parents) |
6091 |
24 Aug 12 |
nicklas |
78 |
{ |
6091 |
24 Aug 12 |
nicklas |
79 |
if (parent != null && parentItems.add(parent)) |
6091 |
24 Aug 12 |
nicklas |
80 |
{ |
6091 |
24 Aug 12 |
nicklas |
81 |
if (parent.hasPermission(Permission.USE) && parent.isAnnotated()) |
6091 |
24 Aug 12 |
nicklas |
82 |
{ |
6091 |
24 Aug 12 |
nicklas |
83 |
parentAnnotations.add(parent.getAnnotationSet()); |
6091 |
24 Aug 12 |
nicklas |
84 |
} |
6091 |
24 Aug 12 |
nicklas |
85 |
} |
6091 |
24 Aug 12 |
nicklas |
86 |
} |
2166 |
19 Apr 06 |
nicklas |
87 |
} |
927 |
13 Jul 05 |
nicklas |
88 |
|
6912 |
20 May 15 |
nicklas |
89 |
JSONArray generateJoustTree(Set<AnnotationSet> parentAnnotations, Set<AnnotationSet> nonParents, Set<Annotation> inheritedAnnotations) |
2166 |
19 Apr 06 |
nicklas |
90 |
{ |
2173 |
21 Apr 06 |
nicklas |
91 |
String itemIcon = "Annotatable"; |
2173 |
21 Apr 06 |
nicklas |
92 |
String annotationIcon = "Annotation"; |
2883 |
09 Nov 06 |
nicklas |
93 |
String parameterIcon = "Parameter"; |
3051 |
08 Jan 07 |
nicklas |
94 |
String nonParentIcon = "NonParent"; |
6384 |
18 Dec 13 |
nicklas |
95 |
JSONArray json = new JSONArray(); |
2166 |
19 Apr 06 |
nicklas |
96 |
|
2166 |
19 Apr 06 |
nicklas |
97 |
for (AnnotationSet as : parentAnnotations) |
2166 |
19 Apr 06 |
nicklas |
98 |
{ |
2166 |
19 Apr 06 |
nicklas |
99 |
Annotatable item = null; |
5965 |
16 Feb 12 |
nicklas |
100 |
String itemType = as.getItemType().toString(); |
2166 |
19 Apr 06 |
nicklas |
101 |
try |
2166 |
19 Apr 06 |
nicklas |
102 |
{ |
2166 |
19 Apr 06 |
nicklas |
103 |
item = as.getItem(); |
2166 |
19 Apr 06 |
nicklas |
104 |
} |
2166 |
19 Apr 06 |
nicklas |
105 |
catch (PermissionDeniedException ex) |
2166 |
19 Apr 06 |
nicklas |
106 |
{} |
5965 |
16 Feb 12 |
nicklas |
107 |
if (item instanceof Subtypable) |
5965 |
16 Feb 12 |
nicklas |
108 |
{ |
5965 |
16 Feb 12 |
nicklas |
109 |
try |
5965 |
16 Feb 12 |
nicklas |
110 |
{ |
5965 |
16 Feb 12 |
nicklas |
111 |
ItemSubtype subtype = ((Subtypable)item).getItemSubtype(); |
5965 |
16 Feb 12 |
nicklas |
112 |
if (subtype != null) itemType = subtype.getName(); |
5965 |
16 Feb 12 |
nicklas |
113 |
} |
5965 |
16 Feb 12 |
nicklas |
114 |
catch (PermissionDeniedException ex) |
5965 |
16 Feb 12 |
nicklas |
115 |
{} |
5965 |
16 Feb 12 |
nicklas |
116 |
} |
2166 |
19 Apr 06 |
nicklas |
117 |
|
3051 |
08 Jan 07 |
nicklas |
118 |
String icon = nonParents.contains(as) ? nonParentIcon : itemIcon; |
3051 |
08 Jan 07 |
nicklas |
119 |
|
6384 |
18 Dec 13 |
nicklas |
120 |
String joustId = "as-"+as.getId(); |
2166 |
19 Apr 06 |
nicklas |
121 |
String input = "<input type=\"checkbox\""+ |
6912 |
20 May 15 |
nicklas |
122 |
" name=\""+joustId+"\">"; |
2166 |
19 Apr 06 |
nicklas |
123 |
String name = item == null ? "<i>- denied -</i>" : |
6384 |
18 Dec 13 |
nicklas |
124 |
HTML.encodeTags(((Nameable)item).getName()) + " <span class=\"itemsubtype\">(" + itemType + ")</span>"; |
6384 |
18 Dec 13 |
nicklas |
125 |
|
6947 |
08 Sep 15 |
nicklas |
126 |
ItemQuery<Annotation> query = as.getAnnotations(Annotation.Source.PRIMARY); |
6737 |
13 Feb 15 |
nicklas |
127 |
query.restrict(Restrictions.eq(Hql.property("annotationType.disableInheritance"), Expressions.bool(false))); |
6737 |
13 Feb 15 |
nicklas |
128 |
List<Annotation> annotations = query.list(as.getDbControl()); |
6912 |
20 May 15 |
nicklas |
129 |
if (annotations.size() == 0) continue; // With the next AnnotationSet/item |
6737 |
13 Feb 15 |
nicklas |
130 |
|
6947 |
08 Sep 15 |
nicklas |
131 |
JSONObject jsonJoust = null; |
2166 |
19 Apr 06 |
nicklas |
132 |
|
2942 |
22 Nov 06 |
nicklas |
133 |
SessionControl sc = as.getSessionControl(); |
2166 |
19 Apr 06 |
nicklas |
134 |
for (Annotation a : annotations) |
2166 |
19 Apr 06 |
nicklas |
135 |
{ |
7605 |
26 Feb 19 |
nicklas |
136 |
Formatter<Object> formatter = FormatterFactory.getAnnotationFormatter(sc, a, null); |
2217 |
05 May 06 |
nicklas |
137 |
boolean inherited = inheritedAnnotations != null && inheritedAnnotations.contains(a); |
6947 |
08 Sep 15 |
nicklas |
138 |
if (inherited) continue; |
6947 |
08 Sep 15 |
nicklas |
139 |
|
6947 |
08 Sep 15 |
nicklas |
140 |
if (jsonJoust == null) |
6947 |
08 Sep 15 |
nicklas |
141 |
{ |
6947 |
08 Sep 15 |
nicklas |
142 |
jsonJoust = newJoustEntry(null, icon, input+name, joustId); |
6947 |
08 Sep 15 |
nicklas |
143 |
jsonJoust.put("isOpen", 1); |
6947 |
08 Sep 15 |
nicklas |
144 |
jsonJoust.put("type", "annotation-set"); |
6947 |
08 Sep 15 |
nicklas |
145 |
jsonJoust.put("externalId", as.getId()); |
6947 |
08 Sep 15 |
nicklas |
146 |
json.add(jsonJoust); |
6947 |
08 Sep 15 |
nicklas |
147 |
} |
6947 |
08 Sep 15 |
nicklas |
148 |
|
6037 |
29 Mar 12 |
nicklas |
149 |
AnnotationType at = a.getAnnotationType(); |
6037 |
29 Mar 12 |
nicklas |
150 |
String annotationName = at.getName(); |
6037 |
29 Mar 12 |
nicklas |
151 |
boolean isParameter = at.isProtocolParameter(); |
6037 |
29 Mar 12 |
nicklas |
152 |
|
6384 |
18 Dec 13 |
nicklas |
153 |
joustId = "a-"+a.getId(); |
4547 |
26 Sep 08 |
nicklas |
154 |
String values = Values.getString(a.getValues(null), ", ", true, formatter); |
6384 |
18 Dec 13 |
nicklas |
155 |
name = HTML.encodeTags(annotationName + |
2166 |
19 Apr 06 |
nicklas |
156 |
" [" + Values.trimString(values, 20)+"]"); |
2166 |
19 Apr 06 |
nicklas |
157 |
input = "<input type=\"checkbox\""+ |
6384 |
18 Dec 13 |
nicklas |
158 |
" name=\""+joustId+"\""+ |
6912 |
20 May 15 |
nicklas |
159 |
(inherited ? " checked" : "")+ |
2166 |
19 Apr 06 |
nicklas |
160 |
">"; |
6384 |
18 Dec 13 |
nicklas |
161 |
|
6384 |
18 Dec 13 |
nicklas |
162 |
JSONObject jsonAnnotation = newJoustEntry(jsonJoust, isParameter ? parameterIcon : annotationIcon, input+name, joustId); |
6384 |
18 Dec 13 |
nicklas |
163 |
jsonAnnotation.put("type", "annotation"); |
6384 |
18 Dec 13 |
nicklas |
164 |
jsonAnnotation.put("externalId", a.getId()); |
6384 |
18 Dec 13 |
nicklas |
165 |
jsonAnnotation.put("annotationType", HTML.encodeTags(annotationName)); |
6384 |
18 Dec 13 |
nicklas |
166 |
jsonAnnotation.put("values", HTML.encodeTags(values)); |
6384 |
18 Dec 13 |
nicklas |
167 |
jsonAnnotation.put("inherited", inherited ? 1 : 0); |
6912 |
20 May 15 |
nicklas |
168 |
jsonAnnotation.put("modified", 0); |
2166 |
19 Apr 06 |
nicklas |
169 |
} |
2166 |
19 Apr 06 |
nicklas |
170 |
} |
6384 |
18 Dec 13 |
nicklas |
171 |
return json; |
2166 |
19 Apr 06 |
nicklas |
172 |
} |
6384 |
18 Dec 13 |
nicklas |
173 |
|
6384 |
18 Dec 13 |
nicklas |
174 |
JSONObject newJoustEntry(JSONObject jsonParent, String icon, String text, String id) |
6384 |
18 Dec 13 |
nicklas |
175 |
{ |
6384 |
18 Dec 13 |
nicklas |
176 |
JSONObject jsonJoust = new JSONObject(); |
6384 |
18 Dec 13 |
nicklas |
177 |
jsonJoust.put("icon", icon); |
6384 |
18 Dec 13 |
nicklas |
178 |
jsonJoust.put("text", text); |
6384 |
18 Dec 13 |
nicklas |
179 |
jsonJoust.put("id", id); |
6384 |
18 Dec 13 |
nicklas |
180 |
if (jsonParent != null) |
6384 |
18 Dec 13 |
nicklas |
181 |
{ |
6384 |
18 Dec 13 |
nicklas |
182 |
JSONArray jsonChildren = (JSONArray)jsonParent.get("children"); |
6384 |
18 Dec 13 |
nicklas |
183 |
if (jsonChildren == null) |
6384 |
18 Dec 13 |
nicklas |
184 |
{ |
6384 |
18 Dec 13 |
nicklas |
185 |
jsonChildren = new JSONArray(); |
6384 |
18 Dec 13 |
nicklas |
186 |
jsonParent.put("children", jsonChildren); |
6384 |
18 Dec 13 |
nicklas |
187 |
} |
6384 |
18 Dec 13 |
nicklas |
188 |
jsonChildren.add(jsonJoust); |
6384 |
18 Dec 13 |
nicklas |
189 |
} |
6384 |
18 Dec 13 |
nicklas |
190 |
return jsonJoust; |
6384 |
18 Dec 13 |
nicklas |
191 |
} |
2166 |
19 Apr 06 |
nicklas |
192 |
%> |
2166 |
19 Apr 06 |
nicklas |
193 |
<% |
2166 |
19 Apr 06 |
nicklas |
194 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
2166 |
19 Apr 06 |
nicklas |
195 |
final String ID = sc.getId(); |
2166 |
19 Apr 06 |
nicklas |
196 |
final float scale = Base.getScale(sc); |
2166 |
19 Apr 06 |
nicklas |
197 |
final Item itemType = Item.valueOf(request.getParameter("item_type")); |
2166 |
19 Apr 06 |
nicklas |
198 |
final int itemId = Values.getInt(request.getParameter("item_id")); |
2166 |
19 Apr 06 |
nicklas |
199 |
|
6947 |
08 Sep 15 |
nicklas |
200 |
//final boolean standalone = Values.getBoolean(request.getParameter("standalone")); |
6947 |
08 Sep 15 |
nicklas |
201 |
|
7954 |
12 May 21 |
nicklas |
202 |
final DbControl dc = sc.newDbControl(":Inherit annotations"); |
2166 |
19 Apr 06 |
nicklas |
203 |
ItemResultList<AnnotationType> annotationTypes = null; |
2166 |
19 Apr 06 |
nicklas |
204 |
try |
2166 |
19 Apr 06 |
nicklas |
205 |
{ |
2166 |
19 Apr 06 |
nicklas |
206 |
final Annotatable item = itemId == 0 ? null : (Annotatable)itemType.getById(dc, itemId); |
5749 |
19 Sep 11 |
nicklas |
207 |
Set<AnnotationSet> parentAnnotations = new java.util.LinkedHashSet<AnnotationSet>(); |
2584 |
24 Aug 06 |
nicklas |
208 |
Set<Annotatable> parentItems = new HashSet<Annotatable>(); |
3051 |
08 Jan 07 |
nicklas |
209 |
Set<AnnotationSet> nonParents = new HashSet<AnnotationSet>(); |
2584 |
24 Aug 06 |
nicklas |
210 |
|
2584 |
24 Aug 06 |
nicklas |
211 |
if (item != null) |
2584 |
24 Aug 06 |
nicklas |
212 |
{ |
2584 |
24 Aug 06 |
nicklas |
213 |
// Get all annotated parents and their annotation sets |
6091 |
24 Aug 12 |
nicklas |
214 |
loadParents(dc, parentAnnotations, parentItems, item); |
2584 |
24 Aug 06 |
nicklas |
215 |
} |
6947 |
08 Sep 15 |
nicklas |
216 |
|
3045 |
20 Dec 06 |
nicklas |
217 |
String title = "Inherit annotations to " + |
3045 |
20 Dec 06 |
nicklas |
218 |
HTML.encodeTags((item instanceof Nameable ? ((Nameable)item).getName() : |
3045 |
20 Dec 06 |
nicklas |
219 |
(item == null ? " new item" : item.toString()))); |
3045 |
20 Dec 06 |
nicklas |
220 |
|
2584 |
24 Aug 06 |
nicklas |
221 |
// Parent items may have been submitted by caller |
2584 |
24 Aug 06 |
nicklas |
222 |
String[] parents = request.getParameterValues("parents"); |
2584 |
24 Aug 06 |
nicklas |
223 |
// Each parameter is ITEMTYPE:ID:ID:... |
2584 |
24 Aug 06 |
nicklas |
224 |
if (parents != null) |
2229 |
10 May 06 |
nicklas |
225 |
{ |
2584 |
24 Aug 06 |
nicklas |
226 |
for (String parent : parents) |
2584 |
24 Aug 06 |
nicklas |
227 |
{ |
2584 |
24 Aug 06 |
nicklas |
228 |
String[] temp = parent.split(":"); |
2584 |
24 Aug 06 |
nicklas |
229 |
Item parentType = Item.valueOf(temp[0]); |
2584 |
24 Aug 06 |
nicklas |
230 |
for (int i = 1; i < temp.length; ++i) |
2584 |
24 Aug 06 |
nicklas |
231 |
{ |
2584 |
24 Aug 06 |
nicklas |
232 |
int parentId = Values.getInt(temp[i], -1); |
2584 |
24 Aug 06 |
nicklas |
233 |
if (parentId != -1) |
2584 |
24 Aug 06 |
nicklas |
234 |
{ |
2584 |
24 Aug 06 |
nicklas |
235 |
Annotatable parentItem = (Annotatable)parentType.getById(dc, parentId); |
2584 |
24 Aug 06 |
nicklas |
236 |
if (parentItems.add(parentItem)) |
2584 |
24 Aug 06 |
nicklas |
237 |
{ |
2584 |
24 Aug 06 |
nicklas |
238 |
// This is a new parent |
2584 |
24 Aug 06 |
nicklas |
239 |
if (parentItem.hasPermission(Permission.USE) && parentItem.isAnnotated()) |
2584 |
24 Aug 06 |
nicklas |
240 |
{ |
2584 |
24 Aug 06 |
nicklas |
241 |
parentAnnotations.add(parentItem.getAnnotationSet()); |
2584 |
24 Aug 06 |
nicklas |
242 |
} |
6091 |
24 Aug 12 |
nicklas |
243 |
loadParents(dc, parentAnnotations, parentItems, parentItem); |
2584 |
24 Aug 06 |
nicklas |
244 |
} |
2584 |
24 Aug 06 |
nicklas |
245 |
} |
2584 |
24 Aug 06 |
nicklas |
246 |
} |
2584 |
24 Aug 06 |
nicklas |
247 |
} |
2229 |
10 May 06 |
nicklas |
248 |
} |
2229 |
10 May 06 |
nicklas |
249 |
|
2166 |
19 Apr 06 |
nicklas |
250 |
// Get the currently inherited annotations |
2584 |
24 Aug 06 |
nicklas |
251 |
final AnnotationSet as = item != null && item.isAnnotated() ? item.getAnnotationSet() : null; |
2166 |
19 Apr 06 |
nicklas |
252 |
Set<Annotation> inheritedAnnotations = null; |
6937 |
07 Aug 15 |
nicklas |
253 |
|
2166 |
19 Apr 06 |
nicklas |
254 |
if (as != null) |
2166 |
19 Apr 06 |
nicklas |
255 |
{ |
6937 |
07 Aug 15 |
nicklas |
256 |
ItemQuery<Annotation> inheritedQuery = as.getAnnotations(null); |
6937 |
07 Aug 15 |
nicklas |
257 |
inheritedQuery.restrict( |
6937 |
07 Aug 15 |
nicklas |
258 |
Restrictions.neq( |
6937 |
07 Aug 15 |
nicklas |
259 |
Hql.property("source"), |
6937 |
07 Aug 15 |
nicklas |
260 |
Expressions.integer(Annotation.Source.PRIMARY.ordinal()) |
6937 |
07 Aug 15 |
nicklas |
261 |
)); |
6937 |
07 Aug 15 |
nicklas |
262 |
|
6947 |
08 Sep 15 |
nicklas |
263 |
// Ignore annotations marked for DELETE (so it is possible to re-select them) |
6947 |
08 Sep 15 |
nicklas |
264 |
String d = request.getParameter("deleted"); |
6947 |
08 Sep 15 |
nicklas |
265 |
if (d != null) |
6947 |
08 Sep 15 |
nicklas |
266 |
{ |
6947 |
08 Sep 15 |
nicklas |
267 |
Integer[] deleted = Values.getInt(d.split(",")); |
6947 |
08 Sep 15 |
nicklas |
268 |
if (deleted.length > 0) |
6947 |
08 Sep 15 |
nicklas |
269 |
{ |
6947 |
08 Sep 15 |
nicklas |
270 |
inheritedQuery.restrict(Restrictions.not(Restrictions.in(Hql.property("id"), Expressions.parameter("deleted")))); |
6947 |
08 Sep 15 |
nicklas |
271 |
inheritedQuery.setParameter("deleted", java.util.Arrays.asList(deleted), Type.INT); |
6947 |
08 Sep 15 |
nicklas |
272 |
} |
6947 |
08 Sep 15 |
nicklas |
273 |
} |
6947 |
08 Sep 15 |
nicklas |
274 |
|
2166 |
19 Apr 06 |
nicklas |
275 |
inheritedQuery.order(Orders.asc(Hql.property("annotationSet"))); |
2166 |
19 Apr 06 |
nicklas |
276 |
inheritedQuery.order(Orders.asc(Hql.property("annotationType.name"))); |
6937 |
07 Aug 15 |
nicklas |
277 |
inheritedAnnotations = new HashSet<Annotation>(); |
6937 |
07 Aug 15 |
nicklas |
278 |
for (Annotation a : inheritedQuery.list(dc)) |
2166 |
19 Apr 06 |
nicklas |
279 |
{ |
6937 |
07 Aug 15 |
nicklas |
280 |
a = a.getInheritedFrom(); |
6937 |
07 Aug 15 |
nicklas |
281 |
if (a != null) |
2166 |
19 Apr 06 |
nicklas |
282 |
{ |
6937 |
07 Aug 15 |
nicklas |
283 |
inheritedAnnotations.add(a); |
6937 |
07 Aug 15 |
nicklas |
284 |
AnnotationSet from = a.getAnnotationSet(); |
6937 |
07 Aug 15 |
nicklas |
285 |
if (!parentAnnotations.contains(from) && from.hasPermission(Permission.USE)) |
6937 |
07 Aug 15 |
nicklas |
286 |
{ |
6937 |
07 Aug 15 |
nicklas |
287 |
parentAnnotations.add(from); |
6937 |
07 Aug 15 |
nicklas |
288 |
nonParents.add(from); |
6937 |
07 Aug 15 |
nicklas |
289 |
} |
2166 |
19 Apr 06 |
nicklas |
290 |
} |
2166 |
19 Apr 06 |
nicklas |
291 |
} |
2166 |
19 Apr 06 |
nicklas |
292 |
} |
6912 |
20 May 15 |
nicklas |
293 |
JSONArray json = generateJoustTree(parentAnnotations, nonParents, inheritedAnnotations); |
2166 |
19 Apr 06 |
nicklas |
294 |
%> |
4547 |
26 Sep 08 |
nicklas |
295 |
<base:page type="popup" title="Inherit annotations"> |
6386 |
18 Dec 13 |
nicklas |
296 |
<base:head scripts="joust-2.js,~inherit.js" styles="joust-2.css"> |
6384 |
18 Dec 13 |
nicklas |
297 |
<style> |
6384 |
18 Dec 13 |
nicklas |
298 |
.selected .itemsubtype |
2166 |
19 Apr 06 |
nicklas |
299 |
{ |
6384 |
18 Dec 13 |
nicklas |
300 |
color: #E8E8E8; |
2166 |
19 Apr 06 |
nicklas |
301 |
} |
6384 |
18 Dec 13 |
nicklas |
302 |
</style> |
2166 |
19 Apr 06 |
nicklas |
303 |
</base:head> |
6255 |
22 Mar 13 |
nicklas |
304 |
<base:body> |
6947 |
08 Sep 15 |
nicklas |
305 |
|
6947 |
08 Sep 15 |
nicklas |
306 |
<h1><%=title%> <base:help helpid="annotations.inherit" /></h1> |
6947 |
08 Sep 15 |
nicklas |
307 |
<div class="content bottomborder"> |
6947 |
08 Sep 15 |
nicklas |
308 |
|
6947 |
08 Sep 15 |
nicklas |
309 |
<div id="page-data" class="datacontainer" |
6947 |
08 Sep 15 |
nicklas |
310 |
data-callback="<%=HTML.encodeTags(request.getParameter("callback"))%>" |
6947 |
08 Sep 15 |
nicklas |
311 |
></div> |
6947 |
08 Sep 15 |
nicklas |
312 |
|
5913 |
15 Dec 11 |
nicklas |
313 |
<form name="annotations"> |
5913 |
15 Dec 11 |
nicklas |
314 |
<div class="absolutefull"> |
5913 |
15 Dec 11 |
nicklas |
315 |
|
6607 |
19 Nov 14 |
nicklas |
316 |
<div class="absolutefull bg-filled-100 rightborder" style="width: 28em;"> |
5913 |
15 Dec 11 |
nicklas |
317 |
|
6692 |
21 Jan 15 |
nicklas |
318 |
<div class="absolutefull bottomborder" style="height: 2em;"> |
6692 |
21 Jan 15 |
nicklas |
319 |
<% |
6692 |
21 Jan 15 |
nicklas |
320 |
if (parentAnnotations.size() > 0) |
6692 |
21 Jan 15 |
nicklas |
321 |
{ |
6692 |
21 Jan 15 |
nicklas |
322 |
%> |
6692 |
21 Jan 15 |
nicklas |
323 |
<table style="width: 100%;"> |
6692 |
21 Jan 15 |
nicklas |
324 |
<tr> |
6692 |
21 Jan 15 |
nicklas |
325 |
<td style="padding-left: 4px; padding-right: 4px;"><base:icon image="filter.png"/></td> |
6692 |
21 Jan 15 |
nicklas |
326 |
<td style="width: 100%; padding-top: 1px;"> |
6692 |
21 Jan 15 |
nicklas |
327 |
<input type="text" name="quickFilter" id="quickFilter" |
6692 |
21 Jan 15 |
nicklas |
328 |
class="auto-init" data-auto-init="focus" |
6692 |
21 Jan 15 |
nicklas |
329 |
style="width: calc(100% - 10px);" |
6692 |
21 Jan 15 |
nicklas |
330 |
title="Type to filter annotation types"> |
6692 |
21 Jan 15 |
nicklas |
331 |
</td> |
6692 |
21 Jan 15 |
nicklas |
332 |
</table> |
6692 |
21 Jan 15 |
nicklas |
333 |
<% |
6692 |
21 Jan 15 |
nicklas |
334 |
} |
6692 |
21 Jan 15 |
nicklas |
335 |
%> |
6692 |
21 Jan 15 |
nicklas |
336 |
</div> |
6692 |
21 Jan 15 |
nicklas |
337 |
<div class="absolutefull parameterlist" style="top: 2em; bottom: 3em;"> |
6384 |
18 Dec 13 |
nicklas |
338 |
<div id="joust" class="joust absolutefull" |
6384 |
18 Dec 13 |
nicklas |
339 |
data-joust-tree="<%=HTML.encodeTags(json.toJSONString()) %>" |
6384 |
18 Dec 13 |
nicklas |
340 |
> |
5913 |
15 Dec 11 |
nicklas |
341 |
<% |
5913 |
15 Dec 11 |
nicklas |
342 |
if (parentAnnotations.size() == 0) |
5913 |
15 Dec 11 |
nicklas |
343 |
{ |
5913 |
15 Dec 11 |
nicklas |
344 |
%> |
6692 |
21 Jan 15 |
nicklas |
345 |
<div class="messagecontainer error" style="margin: 2em;">There are no parent items with annotations.</div> |
5913 |
15 Dec 11 |
nicklas |
346 |
<% |
5913 |
15 Dec 11 |
nicklas |
347 |
} |
5913 |
15 Dec 11 |
nicklas |
348 |
%> |
6692 |
21 Jan 15 |
nicklas |
349 |
<div id="noMatchingFilter" class="messagecontainer error" style="margin: 2em; display: none;">No annotations matches the filter.</div> |
5913 |
15 Dec 11 |
nicklas |
350 |
</div> |
5913 |
15 Dec 11 |
nicklas |
351 |
</div> |
5913 |
15 Dec 11 |
nicklas |
352 |
|
5913 |
15 Dec 11 |
nicklas |
353 |
<div class="absolutefull topborder" style="top: auto; bottom: 0px; height: 3em;"> |
5913 |
15 Dec 11 |
nicklas |
354 |
<table style="height: 100%; margin:auto;"><tr><td> |
6384 |
18 Dec 13 |
nicklas |
355 |
<base:icon image="annotation.png" style="vertical-align: text-bottom;"/> = annotation |
6384 |
18 Dec 13 |
nicklas |
356 |
<base:icon image="parameter.png" style="vertical-align: text-bottom;"/> = protocol parameter<br> |
6384 |
18 Dec 13 |
nicklas |
357 |
<base:icon image="item-error.png" style="vertical-align: text-bottom;" /> = not a parent item |
5913 |
15 Dec 11 |
nicklas |
358 |
</td></tr></table> |
5913 |
15 Dec 11 |
nicklas |
359 |
</div> |
5913 |
15 Dec 11 |
nicklas |
360 |
|
2166 |
19 Apr 06 |
nicklas |
361 |
</div> |
5913 |
15 Dec 11 |
nicklas |
362 |
|
6384 |
18 Dec 13 |
nicklas |
363 |
<div class="absolutefull" style="left: 28em; padding: 1em;"> |
6384 |
18 Dec 13 |
nicklas |
364 |
<div id="annotationType" style="font-weight: bold;"></div> |
6384 |
18 Dec 13 |
nicklas |
365 |
<div id="annotationValues"></div> |
2166 |
19 Apr 06 |
nicklas |
366 |
</div> |
5913 |
15 Dec 11 |
nicklas |
367 |
|
5913 |
15 Dec 11 |
nicklas |
368 |
</div> |
2166 |
19 Apr 06 |
nicklas |
369 |
</form> |
6947 |
08 Sep 15 |
nicklas |
370 |
</div> |
3045 |
20 Dec 06 |
nicklas |
371 |
|
6947 |
08 Sep 15 |
nicklas |
372 |
<base:buttongroup subclass="dialogbuttons"> |
6981 |
08 Oct 15 |
nicklas |
373 |
<base:button id="btnClone" title="Clone" image="copy.png" data-clone="1" /> |
6981 |
08 Oct 15 |
nicklas |
374 |
<base:button id="btnInherit" title="Inherit" image="inherit.png" /> |
6947 |
08 Sep 15 |
nicklas |
375 |
<base:button id="close" title="Cancel" /> |
6947 |
08 Sep 15 |
nicklas |
376 |
</base:buttongroup> |
6947 |
08 Sep 15 |
nicklas |
377 |
|
927 |
13 Jul 05 |
nicklas |
378 |
</base:body> |
927 |
13 Jul 05 |
nicklas |
379 |
</base:page> |
2166 |
19 Apr 06 |
nicklas |
380 |
<% |
2166 |
19 Apr 06 |
nicklas |
381 |
} |
2166 |
19 Apr 06 |
nicklas |
382 |
finally |
2166 |
19 Apr 06 |
nicklas |
383 |
{ |
2166 |
19 Apr 06 |
nicklas |
384 |
if (dc != null) dc.close(); |
2166 |
19 Apr 06 |
nicklas |
385 |
} |
2166 |
19 Apr 06 |
nicklas |
386 |
%> |
927 |
13 Jul 05 |
nicklas |
387 |
|