2454 |
30 Jun 06 |
nicklas |
1 |
<%-- $Id$ |
2454 |
30 Jun 06 |
nicklas |
2 |
------------------------------------------------------------------ |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2006 Nicklas Nordborg |
2454 |
30 Jun 06 |
nicklas |
4 |
|
2454 |
30 Jun 06 |
nicklas |
5 |
This file is part of BASE - BioArray Software Environment. |
2454 |
30 Jun 06 |
nicklas |
6 |
Available at http://base.thep.lu.se/ |
2454 |
30 Jun 06 |
nicklas |
7 |
|
2454 |
30 Jun 06 |
nicklas |
8 |
BASE is free software; you can redistribute it and/or |
2454 |
30 Jun 06 |
nicklas |
9 |
modify it under the terms of the GNU General Public License |
4476 |
05 Sep 08 |
jari |
10 |
as published by the Free Software Foundation; either version 3 |
2454 |
30 Jun 06 |
nicklas |
11 |
of the License, or (at your option) any later version. |
2454 |
30 Jun 06 |
nicklas |
12 |
|
2454 |
30 Jun 06 |
nicklas |
13 |
BASE is distributed in the hope that it will be useful, |
2454 |
30 Jun 06 |
nicklas |
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
2454 |
30 Jun 06 |
nicklas |
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2454 |
30 Jun 06 |
nicklas |
16 |
GNU General Public License for more details. |
2454 |
30 Jun 06 |
nicklas |
17 |
|
2454 |
30 Jun 06 |
nicklas |
18 |
You should have received a copy of the GNU General Public License |
4510 |
11 Sep 08 |
jari |
19 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
2454 |
30 Jun 06 |
nicklas |
20 |
------------------------------------------------------------------ |
2454 |
30 Jun 06 |
nicklas |
21 |
|
2454 |
30 Jun 06 |
nicklas |
22 |
@author Nicklas |
2454 |
30 Jun 06 |
nicklas |
23 |
@version 2.0 |
2454 |
30 Jun 06 |
nicklas |
24 |
--%> |
5426 |
24 Sep 10 |
nicklas |
25 |
<%@ page pageEncoding="UTF-8" session="false" |
2454 |
30 Jun 06 |
nicklas |
26 |
import="net.sf.basedb.core.SessionControl" |
2454 |
30 Jun 06 |
nicklas |
27 |
import="net.sf.basedb.core.DbControl" |
2454 |
30 Jun 06 |
nicklas |
28 |
import="net.sf.basedb.core.Item" |
2454 |
30 Jun 06 |
nicklas |
29 |
import="net.sf.basedb.core.ItemContext" |
2454 |
30 Jun 06 |
nicklas |
30 |
import="net.sf.basedb.core.BasicItem" |
6694 |
26 Jan 15 |
nicklas |
31 |
import="net.sf.basedb.core.AnnotatedItem" |
5075 |
24 Aug 09 |
nicklas |
32 |
import="net.sf.basedb.core.Annotation" |
5075 |
24 Aug 09 |
nicklas |
33 |
import="net.sf.basedb.core.AnnotationType" |
2454 |
30 Jun 06 |
nicklas |
34 |
import="net.sf.basedb.core.Annotatable" |
6694 |
26 Jan 15 |
nicklas |
35 |
import="net.sf.basedb.core.ItemSubtype" |
2454 |
30 Jun 06 |
nicklas |
36 |
import="net.sf.basedb.core.BaseException" |
6694 |
26 Jan 15 |
nicklas |
37 |
import="net.sf.basedb.core.SimpleProgressReporter" |
6694 |
26 Jan 15 |
nicklas |
38 |
import="net.sf.basedb.core.snapshot.SnapshotManager" |
6694 |
26 Jan 15 |
nicklas |
39 |
import="net.sf.basedb.util.annotations.RunnableInheritAnnotationsManager" |
6694 |
26 Jan 15 |
nicklas |
40 |
import="net.sf.basedb.util.annotations.InheritAnnotationsManager" |
6694 |
26 Jan 15 |
nicklas |
41 |
import="net.sf.basedb.util.annotations.InheritSpecification" |
2454 |
30 Jun 06 |
nicklas |
42 |
import="net.sf.basedb.clients.web.Base" |
2454 |
30 Jun 06 |
nicklas |
43 |
import="net.sf.basedb.clients.web.WebException" |
2753 |
20 Oct 06 |
nicklas |
44 |
import="net.sf.basedb.util.Values" |
2454 |
30 Jun 06 |
nicklas |
45 |
import="net.sf.basedb.clients.web.util.HTML" |
6694 |
26 Jan 15 |
nicklas |
46 |
import="java.util.Set" |
6694 |
26 Jan 15 |
nicklas |
47 |
import="java.util.List" |
6694 |
26 Jan 15 |
nicklas |
48 |
import="java.util.ArrayList" |
6694 |
26 Jan 15 |
nicklas |
49 |
|
6694 |
26 Jan 15 |
nicklas |
50 |
|
2454 |
30 Jun 06 |
nicklas |
51 |
%> |
2454 |
30 Jun 06 |
nicklas |
52 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
2454 |
30 Jun 06 |
nicklas |
53 |
<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
2454 |
30 Jun 06 |
nicklas |
54 |
|
2454 |
30 Jun 06 |
nicklas |
55 |
<% |
2454 |
30 Jun 06 |
nicklas |
56 |
final String root = request.getContextPath()+"/"; |
2454 |
30 Jun 06 |
nicklas |
57 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
2454 |
30 Jun 06 |
nicklas |
58 |
final String ID = sc.getId(); |
2454 |
30 Jun 06 |
nicklas |
59 |
final String cmd = request.getParameter("cmd"); |
2454 |
30 Jun 06 |
nicklas |
60 |
final int itemId = Values.getInt(request.getParameter("item_id")); |
2454 |
30 Jun 06 |
nicklas |
61 |
|
2454 |
30 Jun 06 |
nicklas |
62 |
DbControl newDc = null; |
2454 |
30 Jun 06 |
nicklas |
63 |
DbControl oldDc = null; |
2454 |
30 Jun 06 |
nicklas |
64 |
String forward = null; |
2454 |
30 Jun 06 |
nicklas |
65 |
String message = null; |
2454 |
30 Jun 06 |
nicklas |
66 |
String redirect = null; |
2454 |
30 Jun 06 |
nicklas |
67 |
try |
2454 |
30 Jun 06 |
nicklas |
68 |
{ |
5075 |
24 Aug 09 |
nicklas |
69 |
if ("EditItem".equals(cmd)) |
2454 |
30 Jun 06 |
nicklas |
70 |
{ |
7954 |
12 May 21 |
nicklas |
71 |
newDc = sc.newDbControl(":Edit annotation"); |
5075 |
24 Aug 09 |
nicklas |
72 |
Annotation a = Annotation.getById(newDc, itemId); |
5075 |
24 Aug 09 |
nicklas |
73 |
AnnotationType at = a.getAnnotationType(); |
5075 |
24 Aug 09 |
nicklas |
74 |
Annotatable item = a.getAnnotationSet().getItem(); |
5075 |
24 Aug 09 |
nicklas |
75 |
|
5075 |
24 Aug 09 |
nicklas |
76 |
redirect = "annotate.jsp?ID=" + ID + "&item_id=" + item.getId() + |
5075 |
24 Aug 09 |
nicklas |
77 |
"&item_type=" + item.getType().name() + |
7110 |
15 Mar 16 |
nicklas |
78 |
"&annotation_id="+itemId+ |
5075 |
24 Aug 09 |
nicklas |
79 |
"&annotationtype_id=" + at.getId() + "&standalone=1"; |
5075 |
24 Aug 09 |
nicklas |
80 |
newDc.close(); |
5075 |
24 Aug 09 |
nicklas |
81 |
} |
5075 |
24 Aug 09 |
nicklas |
82 |
else if ("SaveAnnotations".equals(cmd)) |
5075 |
24 Aug 09 |
nicklas |
83 |
{ |
5075 |
24 Aug 09 |
nicklas |
84 |
final Item itemType = Item.valueOf(request.getParameter("item_type")); |
7954 |
12 May 21 |
nicklas |
85 |
newDc = sc.newDbControl(":Edit annotations"); |
7954 |
12 May 21 |
nicklas |
86 |
oldDc = sc.newDbControl(":Edit annotations"); |
2454 |
30 Jun 06 |
nicklas |
87 |
ItemContext cc = sc.getCurrentContext(itemType); |
7605 |
26 Feb 19 |
nicklas |
88 |
Annotatable oldItem = cc.getObject("item"); |
2454 |
30 Jun 06 |
nicklas |
89 |
Annotatable newItem = (Annotatable)itemType.getById(newDc, itemId); |
5060 |
19 Aug 09 |
nicklas |
90 |
oldDc.reattachItem((BasicItem)oldItem, false); |
2454 |
30 Jun 06 |
nicklas |
91 |
Base.updateAnnotations(newDc, oldItem, newItem, request); |
2454 |
30 Jun 06 |
nicklas |
92 |
oldDc.close(); |
2454 |
30 Jun 06 |
nicklas |
93 |
newDc.commit(); |
2454 |
30 Jun 06 |
nicklas |
94 |
cc.removeObject("item"); |
2454 |
30 Jun 06 |
nicklas |
95 |
message = "Annotations saved"; |
2454 |
30 Jun 06 |
nicklas |
96 |
} |
6694 |
26 Jan 15 |
nicklas |
97 |
else if ("BatchInherit".equals(cmd)) |
6694 |
26 Jan 15 |
nicklas |
98 |
{ |
6694 |
26 Jan 15 |
nicklas |
99 |
final Item itemType = Item.valueOf(request.getParameter("item_type")); |
6694 |
26 Jan 15 |
nicklas |
100 |
final String subContext = Values.getString(request.getParameter("subcontext"), ""); |
6694 |
26 Jan 15 |
nicklas |
101 |
final ItemContext cc = sc.getCurrentContext(itemType, subContext); |
6694 |
26 Jan 15 |
nicklas |
102 |
|
7954 |
12 May 21 |
nicklas |
103 |
newDc = sc.newDbControl(":Inherit annotations"); |
6694 |
26 Jan 15 |
nicklas |
104 |
|
7605 |
26 Feb 19 |
nicklas |
105 |
Set<AnnotatedItem> items = cc.getObject("AnnotatedItems"); |
6694 |
26 Jan 15 |
nicklas |
106 |
cc.removeObject("AnnotatedItems"); |
6694 |
26 Jan 15 |
nicklas |
107 |
|
6694 |
26 Jan 15 |
nicklas |
108 |
RunnableInheritAnnotationsManager manager = new RunnableInheritAnnotationsManager(sc); |
6694 |
26 Jan 15 |
nicklas |
109 |
manager.addAllItems(items); |
6694 |
26 Jan 15 |
nicklas |
110 |
|
6694 |
26 Jan 15 |
nicklas |
111 |
for (Integer atId : Values.getInt(request.getParameter("annotationTypes").split(","))) |
6694 |
26 Jan 15 |
nicklas |
112 |
{ |
6694 |
26 Jan 15 |
nicklas |
113 |
AnnotationType at = AnnotationType.getById(newDc, atId); |
6729 |
13 Feb 15 |
nicklas |
114 |
if (at.getDisableInheritance()) continue; // Inheritance has been disabled |
6729 |
13 Feb 15 |
nicklas |
115 |
|
6694 |
26 Jan 15 |
nicklas |
116 |
InheritSpecification spec = new InheritSpecification(at); |
6694 |
26 Jan 15 |
nicklas |
117 |
String action = request.getParameter("action_"+atId); |
6694 |
26 Jan 15 |
nicklas |
118 |
|
6694 |
26 Jan 15 |
nicklas |
119 |
if ("remove".equals(action)) |
6694 |
26 Jan 15 |
nicklas |
120 |
{ |
6694 |
26 Jan 15 |
nicklas |
121 |
spec.setRemove(true); |
6694 |
26 Jan 15 |
nicklas |
122 |
} |
6926 |
03 Jun 15 |
nicklas |
123 |
else if ("resync".equals(action)) |
6926 |
03 Jun 15 |
nicklas |
124 |
{ |
6926 |
03 Jun 15 |
nicklas |
125 |
spec.setResyncCloned(true); |
6926 |
03 Jun 15 |
nicklas |
126 |
} |
6694 |
26 Jan 15 |
nicklas |
127 |
else |
6694 |
26 Jan 15 |
nicklas |
128 |
{ |
6925 |
03 Jun 15 |
nicklas |
129 |
spec.setClone("clone".equals(action)); |
6694 |
26 Jan 15 |
nicklas |
130 |
int subtypeId = Values.getInt(request.getParameter("from_"+atId)); |
6694 |
26 Jan 15 |
nicklas |
131 |
boolean noDup = Values.getBoolean(request.getParameter("nodup_"+atId)); |
6694 |
26 Jan 15 |
nicklas |
132 |
boolean replaceExisting = Values.getBoolean(request.getParameter("replace_"+atId)); |
6694 |
26 Jan 15 |
nicklas |
133 |
if (subtypeId != 0) |
6694 |
26 Jan 15 |
nicklas |
134 |
{ |
6694 |
26 Jan 15 |
nicklas |
135 |
spec.setItemSubtype(ItemSubtype.getById(newDc, subtypeId)); |
6694 |
26 Jan 15 |
nicklas |
136 |
} |
6694 |
26 Jan 15 |
nicklas |
137 |
spec.setNoDuplicates(noDup); |
6694 |
26 Jan 15 |
nicklas |
138 |
spec.setReplaceExisting(replaceExisting); |
6694 |
26 Jan 15 |
nicklas |
139 |
} |
6694 |
26 Jan 15 |
nicklas |
140 |
manager.addSpecification(spec); |
6694 |
26 Jan 15 |
nicklas |
141 |
} |
6694 |
26 Jan 15 |
nicklas |
142 |
newDc.commit(); |
6694 |
26 Jan 15 |
nicklas |
143 |
|
6694 |
26 Jan 15 |
nicklas |
144 |
SimpleProgressReporter progress = new SimpleProgressReporter(null); |
6694 |
26 Jan 15 |
nicklas |
145 |
sc.setSessionSetting("progress.inherit-annotations", progress); |
6694 |
26 Jan 15 |
nicklas |
146 |
manager.setProgressReporter(progress); |
6694 |
26 Jan 15 |
nicklas |
147 |
new Thread(manager).start(); |
6694 |
26 Jan 15 |
nicklas |
148 |
|
6694 |
26 Jan 15 |
nicklas |
149 |
redirect = "../../common/progress_reporter.jsp?ID="+ID+ |
7209 |
19 Oct 16 |
nicklas |
150 |
"&progress=inherit-annotations&title=Inheriting+annotations+to+" + items.size() + "+items"; |
6694 |
26 Jan 15 |
nicklas |
151 |
|
6694 |
26 Jan 15 |
nicklas |
152 |
} |
2454 |
30 Jun 06 |
nicklas |
153 |
else |
2454 |
30 Jun 06 |
nicklas |
154 |
{ |
2454 |
30 Jun 06 |
nicklas |
155 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
2454 |
30 Jun 06 |
nicklas |
156 |
} |
2454 |
30 Jun 06 |
nicklas |
157 |
} |
2454 |
30 Jun 06 |
nicklas |
158 |
finally |
2454 |
30 Jun 06 |
nicklas |
159 |
{ |
2454 |
30 Jun 06 |
nicklas |
160 |
if (oldDc != null) oldDc.close(); |
2454 |
30 Jun 06 |
nicklas |
161 |
if (newDc != null) newDc.close(); |
2454 |
30 Jun 06 |
nicklas |
162 |
} |
2454 |
30 Jun 06 |
nicklas |
163 |
|
2454 |
30 Jun 06 |
nicklas |
164 |
if (forward != null) |
2454 |
30 Jun 06 |
nicklas |
165 |
{ |
6192 |
31 Oct 12 |
nicklas |
166 |
sc.setSessionSetting("alert-message", message); |
2454 |
30 Jun 06 |
nicklas |
167 |
pageContext.forward(forward); |
2454 |
30 Jun 06 |
nicklas |
168 |
} |
2454 |
30 Jun 06 |
nicklas |
169 |
else if (redirect != null) |
2454 |
30 Jun 06 |
nicklas |
170 |
{ |
6192 |
31 Oct 12 |
nicklas |
171 |
sc.setSessionSetting("alert-message", message); |
2454 |
30 Jun 06 |
nicklas |
172 |
response.sendRedirect(redirect); |
2454 |
30 Jun 06 |
nicklas |
173 |
} |
2454 |
30 Jun 06 |
nicklas |
174 |
else if (message == null) |
2454 |
30 Jun 06 |
nicklas |
175 |
{ |
2454 |
30 Jun 06 |
nicklas |
176 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
2454 |
30 Jun 06 |
nicklas |
177 |
} |
2454 |
30 Jun 06 |
nicklas |
178 |
else |
2454 |
30 Jun 06 |
nicklas |
179 |
{ |
2454 |
30 Jun 06 |
nicklas |
180 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
2454 |
30 Jun 06 |
nicklas |
181 |
} |
2454 |
30 Jun 06 |
nicklas |
182 |
%> |
2454 |
30 Jun 06 |
nicklas |
183 |
|