852 |
30 Jun 05 |
nicklas |
1 |
<%-- $Id$ |
852 |
30 Jun 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 |
852 |
30 Jun 05 |
nicklas |
5 |
|
2304 |
22 May 06 |
jari |
6 |
This file is part of BASE - BioArray Software Environment. |
2304 |
22 May 06 |
jari |
7 |
Available at http://base.thep.lu.se/ |
852 |
30 Jun 05 |
nicklas |
8 |
|
852 |
30 Jun 05 |
nicklas |
9 |
BASE is free software; you can redistribute it and/or |
852 |
30 Jun 05 |
nicklas |
10 |
modify it under the terms of the GNU General Public License |
4476 |
05 Sep 08 |
jari |
11 |
as published by the Free Software Foundation; either version 3 |
852 |
30 Jun 05 |
nicklas |
12 |
of the License, or (at your option) any later version. |
852 |
30 Jun 05 |
nicklas |
13 |
|
852 |
30 Jun 05 |
nicklas |
14 |
BASE is distributed in the hope that it will be useful, |
852 |
30 Jun 05 |
nicklas |
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
852 |
30 Jun 05 |
nicklas |
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
852 |
30 Jun 05 |
nicklas |
17 |
GNU General Public License for more details. |
852 |
30 Jun 05 |
nicklas |
18 |
|
852 |
30 Jun 05 |
nicklas |
19 |
You should have received a copy of the GNU General Public License |
4510 |
11 Sep 08 |
jari |
20 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
852 |
30 Jun 05 |
nicklas |
21 |
------------------------------------------------------------------ |
852 |
30 Jun 05 |
nicklas |
22 |
|
852 |
30 Jun 05 |
nicklas |
23 |
|
852 |
30 Jun 05 |
nicklas |
24 |
@author Nicklas |
852 |
30 Jun 05 |
nicklas |
25 |
@version 2.0 |
852 |
30 Jun 05 |
nicklas |
26 |
--%> |
5426 |
24 Sep 10 |
nicklas |
27 |
<%@ page pageEncoding="UTF-8" session="false" |
852 |
30 Jun 05 |
nicklas |
28 |
import="net.sf.basedb.core.SessionControl" |
852 |
30 Jun 05 |
nicklas |
29 |
import="net.sf.basedb.core.DbControl" |
852 |
30 Jun 05 |
nicklas |
30 |
import="net.sf.basedb.core.Item" |
1866 |
30 Jan 06 |
nicklas |
31 |
import="net.sf.basedb.core.ItemContext" |
1866 |
30 Jan 06 |
nicklas |
32 |
import="net.sf.basedb.core.SystemItems" |
852 |
30 Jun 05 |
nicklas |
33 |
import="net.sf.basedb.core.Permission" |
852 |
30 Jun 05 |
nicklas |
34 |
import="net.sf.basedb.core.BioSource" |
5643 |
26 May 11 |
nicklas |
35 |
import="net.sf.basedb.core.ItemSubtype" |
5643 |
26 May 11 |
nicklas |
36 |
import="net.sf.basedb.core.ItemQuery" |
5643 |
26 May 11 |
nicklas |
37 |
import="net.sf.basedb.core.Include" |
1866 |
30 Jan 06 |
nicklas |
38 |
import="net.sf.basedb.core.PermissionDeniedException" |
852 |
30 Jun 05 |
nicklas |
39 |
import="net.sf.basedb.core.BaseException" |
852 |
30 Jun 05 |
nicklas |
40 |
import="net.sf.basedb.clients.web.Base" |
852 |
30 Jun 05 |
nicklas |
41 |
import="net.sf.basedb.clients.web.util.HTML" |
2753 |
20 Oct 06 |
nicklas |
42 |
import="net.sf.basedb.util.Values" |
5492 |
16 Nov 10 |
nicklas |
43 |
import="net.sf.basedb.core.plugin.GuiContext" |
5492 |
16 Nov 10 |
nicklas |
44 |
import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
5492 |
16 Nov 10 |
nicklas |
45 |
import="net.sf.basedb.clients.web.extensions.JspContext" |
5492 |
16 Nov 10 |
nicklas |
46 |
import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
7604 |
25 Feb 19 |
nicklas |
47 |
import="net.sf.basedb.clients.web.extensions.tabcontrol.TabAction" |
5492 |
16 Nov 10 |
nicklas |
48 |
import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
1866 |
30 Jan 06 |
nicklas |
49 |
import="java.util.List" |
1866 |
30 Jan 06 |
nicklas |
50 |
import="java.util.Set" |
1866 |
30 Jan 06 |
nicklas |
51 |
import="java.util.HashSet" |
852 |
30 Jun 05 |
nicklas |
52 |
%> |
852 |
30 Jun 05 |
nicklas |
53 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
852 |
30 Jun 05 |
nicklas |
54 |
<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
6139 |
19 Sep 12 |
nicklas |
55 |
<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
852 |
30 Jun 05 |
nicklas |
56 |
<% |
903 |
08 Jul 05 |
nicklas |
57 |
final Item itemType = Item.BIOSOURCE; |
1866 |
30 Jan 06 |
nicklas |
58 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
1866 |
30 Jan 06 |
nicklas |
59 |
final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
1866 |
30 Jan 06 |
nicklas |
60 |
final int itemId = cc.getId(); |
852 |
30 Jun 05 |
nicklas |
61 |
final String ID = sc.getId(); |
852 |
30 Jun 05 |
nicklas |
62 |
final float scale = Base.getScale(sc); |
7954 |
12 May 21 |
nicklas |
63 |
final DbControl dc = sc.newDbControl(":Edit "+itemType); |
852 |
30 Jun 05 |
nicklas |
64 |
try |
852 |
30 Jun 05 |
nicklas |
65 |
{ |
852 |
30 Jun 05 |
nicklas |
66 |
String title = null; |
852 |
30 Jun 05 |
nicklas |
67 |
BioSource bioSource = null; |
5643 |
26 May 11 |
nicklas |
68 |
boolean readCurrentSubtype = true; |
5643 |
26 May 11 |
nicklas |
69 |
int currentSubtypeId = 0; |
1866 |
30 Jan 06 |
nicklas |
70 |
|
1866 |
30 Jan 06 |
nicklas |
71 |
if (itemId == 0) |
852 |
30 Jun 05 |
nicklas |
72 |
{ |
903 |
08 Jul 05 |
nicklas |
73 |
title = "Create biosource"; |
1866 |
30 Jan 06 |
nicklas |
74 |
cc.removeObject("item"); |
5643 |
26 May 11 |
nicklas |
75 |
|
5643 |
26 May 11 |
nicklas |
76 |
currentSubtypeId = Values.getInt(request.getParameter("subtype_id")); |
5643 |
26 May 11 |
nicklas |
77 |
if (currentSubtypeId == 0) |
5643 |
26 May 11 |
nicklas |
78 |
{ |
5643 |
26 May 11 |
nicklas |
79 |
int recentSubtypeId = Values.getInt(cc.getRecent(Item.ITEMSUBTYPE.name(), 0)); |
5643 |
26 May 11 |
nicklas |
80 |
currentSubtypeId = Values.getInt(cc.getPropertyValue("itemSubtype"), recentSubtypeId); |
5643 |
26 May 11 |
nicklas |
81 |
} |
852 |
30 Jun 05 |
nicklas |
82 |
} |
852 |
30 Jun 05 |
nicklas |
83 |
else |
852 |
30 Jun 05 |
nicklas |
84 |
{ |
1866 |
30 Jan 06 |
nicklas |
85 |
bioSource = BioSource.getById(dc, itemId); |
5643 |
26 May 11 |
nicklas |
86 |
bioSource.checkPermission(Permission.WRITE); |
5643 |
26 May 11 |
nicklas |
87 |
|
1866 |
30 Jan 06 |
nicklas |
88 |
cc.setObject("item", bioSource); |
903 |
08 Jul 05 |
nicklas |
89 |
title = "Edit biosource -- " + HTML.encodeTags(bioSource.getName()); |
5643 |
26 May 11 |
nicklas |
90 |
|
5643 |
26 May 11 |
nicklas |
91 |
try |
5643 |
26 May 11 |
nicklas |
92 |
{ |
5643 |
26 May 11 |
nicklas |
93 |
ItemSubtype subtype = bioSource.getItemSubtype(); |
5643 |
26 May 11 |
nicklas |
94 |
if (subtype != null) currentSubtypeId = subtype.getId(); |
5643 |
26 May 11 |
nicklas |
95 |
} |
5643 |
26 May 11 |
nicklas |
96 |
catch (PermissionDeniedException ex) |
5643 |
26 May 11 |
nicklas |
97 |
{ |
5643 |
26 May 11 |
nicklas |
98 |
readCurrentSubtype = false; |
5643 |
26 May 11 |
nicklas |
99 |
} |
5643 |
26 May 11 |
nicklas |
100 |
|
852 |
30 Jun 05 |
nicklas |
101 |
} |
5643 |
26 May 11 |
nicklas |
102 |
|
5643 |
26 May 11 |
nicklas |
103 |
// Query to retrieve item types |
5643 |
26 May 11 |
nicklas |
104 |
final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(itemType); |
5643 |
26 May 11 |
nicklas |
105 |
subtypesQuery.include(Include.ALL); |
5492 |
16 Nov 10 |
nicklas |
106 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), bioSource); |
7604 |
25 Feb 19 |
nicklas |
107 |
ExtensionsInvoker<TabAction> invoker = EditUtil.useEditExtensions(jspContext); |
852 |
30 Jun 05 |
nicklas |
108 |
%> |
6245 |
25 Feb 13 |
nicklas |
109 |
<base:page type="popup" title="<%=title%>" id="edit-page"> |
6246 |
25 Feb 13 |
nicklas |
110 |
<base:head scripts="tabcontrol-2.js,subtypes.js,~biosources.js" styles="tabcontrol.css"> |
5492 |
16 Nov 10 |
nicklas |
111 |
<ext:scripts context="<%=jspContext%>" /> |
5492 |
16 Nov 10 |
nicklas |
112 |
<ext:stylesheets context="<%=jspContext%>" /> |
6245 |
25 Feb 13 |
nicklas |
113 |
</base:head> |
6245 |
25 Feb 13 |
nicklas |
114 |
<base:body> |
6245 |
25 Feb 13 |
nicklas |
115 |
<h1><%=title%> <base:help tabcontrol="settings" /></h1> |
6246 |
25 Feb 13 |
nicklas |
116 |
|
6162 |
10 Oct 12 |
nicklas |
117 |
<form action="index.jsp?ID=<%=ID%>" method="post" name="biosource"> |
1866 |
30 Jan 06 |
nicklas |
118 |
<input type="hidden" name="cmd" value="UpdateItem"> |
916 |
12 Jul 05 |
nicklas |
119 |
|
5913 |
15 Dec 11 |
nicklas |
120 |
<t:tabcontrol id="settings" |
5913 |
15 Dec 11 |
nicklas |
121 |
subclass="content dialogtabcontrol" |
6245 |
25 Feb 13 |
nicklas |
122 |
position="bottom" remember="<%=bioSource != null%>" |
5492 |
16 Nov 10 |
nicklas |
123 |
extensions="<%=invoker%>"> |
6245 |
25 Feb 13 |
nicklas |
124 |
<t:tab id="info" title="Biosource" helpid="biosource.edit"> |
5913 |
15 Dec 11 |
nicklas |
125 |
<table class="fullform input100"> |
852 |
30 Jun 05 |
nicklas |
126 |
<tr> |
6139 |
19 Sep 12 |
nicklas |
127 |
<th>Name</th> |
6245 |
25 Feb 13 |
nicklas |
128 |
<td><input class="text required auto-init" data-auto-init="<%=bioSource == null ? "focus-select" : "focus" %>" |
6245 |
25 Feb 13 |
nicklas |
129 |
type="text" name="name" |
1866 |
30 Jan 06 |
nicklas |
130 |
value="<%=HTML.encodeTags(bioSource == null ? Values.getString(cc.getPropertyValue("name"), "New biosource") : bioSource.getName())%>" |
5913 |
15 Dec 11 |
nicklas |
131 |
maxlength="<%=BioSource.MAX_NAME_LENGTH%>"></td> |
5913 |
15 Dec 11 |
nicklas |
132 |
<td></td> |
852 |
30 Jun 05 |
nicklas |
133 |
</tr> |
5913 |
15 Dec 11 |
nicklas |
134 |
<tr> |
5913 |
15 Dec 11 |
nicklas |
135 |
<th>Type</th> |
5913 |
15 Dec 11 |
nicklas |
136 |
<td> |
5643 |
26 May 11 |
nicklas |
137 |
<select name="subtype_id" |
5643 |
26 May 11 |
nicklas |
138 |
<%=!readCurrentSubtype ? "disabled readonly class=\"disabled selectionlist\"" : "class=\"selectionlist\""%>> |
5643 |
26 May 11 |
nicklas |
139 |
<% |
5643 |
26 May 11 |
nicklas |
140 |
if (!readCurrentSubtype) |
5643 |
26 May 11 |
nicklas |
141 |
{ |
5643 |
26 May 11 |
nicklas |
142 |
%> |
5643 |
26 May 11 |
nicklas |
143 |
<option value="-1">- denied - |
5643 |
26 May 11 |
nicklas |
144 |
<% |
5643 |
26 May 11 |
nicklas |
145 |
} |
5643 |
26 May 11 |
nicklas |
146 |
else |
5643 |
26 May 11 |
nicklas |
147 |
{ |
5643 |
26 May 11 |
nicklas |
148 |
%> |
5643 |
26 May 11 |
nicklas |
149 |
<option value="0">-none- |
5643 |
26 May 11 |
nicklas |
150 |
<% |
5643 |
26 May 11 |
nicklas |
151 |
for (ItemSubtype subtype : subtypesQuery.list(dc)) |
5643 |
26 May 11 |
nicklas |
152 |
{ |
5643 |
26 May 11 |
nicklas |
153 |
int id = subtype.getId(); |
5643 |
26 May 11 |
nicklas |
154 |
if (id != currentSubtypeId && subtype.isRemoved()) continue; |
5643 |
26 May 11 |
nicklas |
155 |
%> |
5643 |
26 May 11 |
nicklas |
156 |
<option value="<%=id == currentSubtypeId && bioSource != null ? -id : id%>" |
5643 |
26 May 11 |
nicklas |
157 |
<%=id == currentSubtypeId ? "selected" : ""%> |
5643 |
26 May 11 |
nicklas |
158 |
title="<%=HTML.encodeTags(subtype.getDescription()) %>" |
5643 |
26 May 11 |
nicklas |
159 |
><%=HTML.encodeTags(subtype.getName())%> |
5643 |
26 May 11 |
nicklas |
160 |
<% |
5643 |
26 May 11 |
nicklas |
161 |
} |
5643 |
26 May 11 |
nicklas |
162 |
} |
5643 |
26 May 11 |
nicklas |
163 |
%> |
5643 |
26 May 11 |
nicklas |
164 |
</select> |
5643 |
26 May 11 |
nicklas |
165 |
</td> |
5913 |
15 Dec 11 |
nicklas |
166 |
<td></td> |
5643 |
26 May 11 |
nicklas |
167 |
</tr> |
852 |
30 Jun 05 |
nicklas |
168 |
<tr> |
5913 |
15 Dec 11 |
nicklas |
169 |
<th>External ID</th> |
6217 |
14 Dec 12 |
nicklas |
170 |
<td><input class="text" type="text" name="external_id" |
1866 |
30 Jan 06 |
nicklas |
171 |
value="<%=HTML.encodeTags(bioSource == null ? Values.getString(cc.getPropertyValue("externalId"), "") : bioSource.getExternalId())%>" |
5913 |
15 Dec 11 |
nicklas |
172 |
maxlength="<%=BioSource.MAX_EXTERNAL_ID_LENGTH%>"></td> |
5913 |
15 Dec 11 |
nicklas |
173 |
<td></td> |
852 |
30 Jun 05 |
nicklas |
174 |
</tr> |
5913 |
15 Dec 11 |
nicklas |
175 |
<tr class="dynamic"> |
5913 |
15 Dec 11 |
nicklas |
176 |
<th>Description</th> |
5913 |
15 Dec 11 |
nicklas |
177 |
<td> |
6217 |
14 Dec 12 |
nicklas |
178 |
<textarea class="text" rows="6" name="description" id="description" |
1866 |
30 Jan 06 |
nicklas |
179 |
><%=HTML.encodeTags(bioSource == null ? cc.getPropertyValue("description") : bioSource.getDescription())%></textarea> |
852 |
30 Jun 05 |
nicklas |
180 |
</td> |
5913 |
15 Dec 11 |
nicklas |
181 |
<td style="width: 20px;"> |
6215 |
13 Dec 12 |
nicklas |
182 |
<base:zoom textarea="description" title="Description" /> |
5913 |
15 Dec 11 |
nicklas |
183 |
</td> |
852 |
30 Jun 05 |
nicklas |
184 |
</tr> |
852 |
30 Jun 05 |
nicklas |
185 |
</table> |
852 |
30 Jun 05 |
nicklas |
186 |
</t:tab> |
1866 |
30 Jan 06 |
nicklas |
187 |
|
6246 |
25 Feb 13 |
nicklas |
188 |
<t:tab id="annotations" title="Annotations" helpid="annotations.edit"> |
6246 |
25 Feb 13 |
nicklas |
189 |
<jsp:include page="../../common/annotations/annotate_frameset.jsp"> |
6246 |
25 Feb 13 |
nicklas |
190 |
<jsp:param name="item_type" value="<%=itemType.name()%>" /> |
6246 |
25 Feb 13 |
nicklas |
191 |
<jsp:param name="item_id" value="<%=itemId%>" /> |
6246 |
25 Feb 13 |
nicklas |
192 |
<jsp:param name="ID" value="<%=ID%>" /> |
6246 |
25 Feb 13 |
nicklas |
193 |
</jsp:include> |
6246 |
25 Feb 13 |
nicklas |
194 |
</t:tab> |
852 |
30 Jun 05 |
nicklas |
195 |
</t:tabcontrol> |
5913 |
15 Dec 11 |
nicklas |
196 |
</form> |
852 |
30 Jun 05 |
nicklas |
197 |
|
5913 |
15 Dec 11 |
nicklas |
198 |
<div class="legend"> |
5946 |
03 Feb 12 |
nicklas |
199 |
<base:icon image="required.png" />= required information |
5913 |
15 Dec 11 |
nicklas |
200 |
</div> |
5913 |
15 Dec 11 |
nicklas |
201 |
|
5913 |
15 Dec 11 |
nicklas |
202 |
<base:buttongroup subclass="dialogbuttons"> |
6245 |
25 Feb 13 |
nicklas |
203 |
<base:button id="btnSave" title="Save" /> |
6245 |
25 Feb 13 |
nicklas |
204 |
<base:button id="close" title="Cancel" /> |
5913 |
15 Dec 11 |
nicklas |
205 |
</base:buttongroup> |
852 |
30 Jun 05 |
nicklas |
206 |
</base:body> |
852 |
30 Jun 05 |
nicklas |
207 |
</base:page> |
852 |
30 Jun 05 |
nicklas |
208 |
<% |
852 |
30 Jun 05 |
nicklas |
209 |
} |
852 |
30 Jun 05 |
nicklas |
210 |
finally |
852 |
30 Jun 05 |
nicklas |
211 |
{ |
852 |
30 Jun 05 |
nicklas |
212 |
if (dc != null) dc.close(); |
852 |
30 Jun 05 |
nicklas |
213 |
} |
852 |
30 Jun 05 |
nicklas |
214 |
%> |