1 | <%-- $Id $ |
---|
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 | <%@ page pageEncoding="UTF-8" session="false" |
---|
23 | import="net.sf.basedb.core.SessionControl" |
---|
24 | import="net.sf.basedb.core.DbControl" |
---|
25 | import="net.sf.basedb.core.DerivedBioAssay" |
---|
26 | import="net.sf.basedb.core.PhysicalBioAssay" |
---|
27 | import="net.sf.basedb.core.Extract" |
---|
28 | import="net.sf.basedb.core.ItemSubtype" |
---|
29 | import="net.sf.basedb.core.Protocol" |
---|
30 | import="net.sf.basedb.core.Hardware" |
---|
31 | import="net.sf.basedb.core.Software" |
---|
32 | import="net.sf.basedb.core.Item" |
---|
33 | import="net.sf.basedb.core.ItemContext" |
---|
34 | import="net.sf.basedb.core.Permission" |
---|
35 | import="net.sf.basedb.core.ItemQuery" |
---|
36 | import="net.sf.basedb.core.ItemResultList" |
---|
37 | import="net.sf.basedb.core.Include" |
---|
38 | import="net.sf.basedb.core.query.Orders" |
---|
39 | import="net.sf.basedb.core.query.Hql" |
---|
40 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
41 | import="net.sf.basedb.core.BaseException" |
---|
42 | import="net.sf.basedb.clients.web.Base" |
---|
43 | import="net.sf.basedb.clients.web.util.HTML" |
---|
44 | import="net.sf.basedb.util.Values" |
---|
45 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
46 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
47 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
48 | import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
---|
49 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
50 | import="java.util.Date" |
---|
51 | import="java.util.List" |
---|
52 | %> |
---|
53 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
54 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
55 | <% |
---|
56 | final Item itemType = Item.DERIVEDBIOASSAY; |
---|
57 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
58 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
59 | final int itemId = cc.getId(); |
---|
60 | final String ID = sc.getId(); |
---|
61 | final float scale = Base.getScale(sc); |
---|
62 | final DbControl dc = sc.newDbControl(); |
---|
63 | try |
---|
64 | { |
---|
65 | DerivedBioAssay bioAssay = null; |
---|
66 | String title = null; |
---|
67 | |
---|
68 | boolean readCurrentSubtype = true; |
---|
69 | int currentSubtypeId = 0; |
---|
70 | |
---|
71 | boolean readCurrentPhysicalBioAssay = true; |
---|
72 | PhysicalBioAssay currentPhysicalBioAssay = null; |
---|
73 | |
---|
74 | boolean readCurrentParentBioAssay = true; |
---|
75 | DerivedBioAssay currentParentBioAssay = null; |
---|
76 | |
---|
77 | boolean readCurrentExtract = true; |
---|
78 | Extract currentExtract = null; |
---|
79 | |
---|
80 | boolean readCurrentProtocol = true; |
---|
81 | Protocol currentProtocol = null; |
---|
82 | Protocol defaultProtocol = null; |
---|
83 | |
---|
84 | boolean readCurrentHardware = true; |
---|
85 | Hardware currentHardware = null; |
---|
86 | Hardware defaultHardware = null; |
---|
87 | |
---|
88 | boolean readCurrentSoftware = true; |
---|
89 | Software currentSoftware = null; |
---|
90 | Software defaultSoftware = null; |
---|
91 | |
---|
92 | // Load recently used items |
---|
93 | List<PhysicalBioAssay> recentPhysicalBioAssays = (List<PhysicalBioAssay>)cc.getRecent(dc, Item.PHYSICALBIOASSAY); |
---|
94 | List<DerivedBioAssay> recentParentBioAssays = (List<DerivedBioAssay>)cc.getRecent(dc, Item.DERIVEDBIOASSAY); |
---|
95 | List<Protocol> recentProtocols = (List<Protocol>)cc.getRecent(dc, Item.PROTOCOL); |
---|
96 | List<Hardware> recentHardware = (List<Hardware>)cc.getRecent(dc, Item.HARDWARE); |
---|
97 | List<Software> recentSoftware = (List<Software>)cc.getRecent(dc, Item.SOFTWARE); |
---|
98 | |
---|
99 | if (itemId == 0) |
---|
100 | { |
---|
101 | title = "New derived bioassay"; |
---|
102 | cc.removeObject("item"); |
---|
103 | currentSubtypeId = Values.getInt(request.getParameter("subtype_id")); |
---|
104 | if (currentSubtypeId == 0) |
---|
105 | { |
---|
106 | int recentSubtypeId = Values.getInt(cc.getRecent(Item.ITEMSUBTYPE.name(), 0)); |
---|
107 | currentSubtypeId = Values.getInt(cc.getPropertyValue("itemSubtype"), recentSubtypeId); |
---|
108 | } |
---|
109 | |
---|
110 | int parentId = Values.getInt(request.getParameter("parent_id")); |
---|
111 | if (parentId != 0) |
---|
112 | { |
---|
113 | currentParentBioAssay = DerivedBioAssay.getById(dc, parentId); |
---|
114 | try |
---|
115 | { |
---|
116 | currentPhysicalBioAssay = currentParentBioAssay.getPhysicalBioAssay(); |
---|
117 | } |
---|
118 | catch (PermissionDeniedException ex) |
---|
119 | { |
---|
120 | readCurrentPhysicalBioAssay = false; |
---|
121 | } |
---|
122 | try |
---|
123 | { |
---|
124 | currentExtract = currentParentBioAssay.getExtract(); |
---|
125 | } |
---|
126 | catch (PermissionDeniedException ex) |
---|
127 | {} |
---|
128 | } |
---|
129 | else |
---|
130 | { |
---|
131 | int physicalBioAssayId = Values.getInt(request.getParameter("physicalbioassay_id")); |
---|
132 | if (physicalBioAssayId != 0) |
---|
133 | { |
---|
134 | currentPhysicalBioAssay = PhysicalBioAssay.getById(dc, physicalBioAssayId); |
---|
135 | } |
---|
136 | } |
---|
137 | |
---|
138 | } |
---|
139 | else |
---|
140 | { |
---|
141 | bioAssay = DerivedBioAssay.getById(dc, itemId); |
---|
142 | bioAssay.checkPermission(Permission.WRITE); |
---|
143 | cc.setObject("item", bioAssay); |
---|
144 | title = "Edit bioassay -- " + HTML.encodeTags(bioAssay.getName()); |
---|
145 | |
---|
146 | try |
---|
147 | { |
---|
148 | ItemSubtype subtype = bioAssay.getItemSubtype(); |
---|
149 | if (subtype != null) currentSubtypeId = subtype.getId(); |
---|
150 | } |
---|
151 | catch (PermissionDeniedException ex) |
---|
152 | { |
---|
153 | readCurrentSubtype = false; |
---|
154 | } |
---|
155 | try |
---|
156 | { |
---|
157 | currentParentBioAssay = bioAssay.getParent(); |
---|
158 | } |
---|
159 | catch (PermissionDeniedException ex) |
---|
160 | { |
---|
161 | readCurrentParentBioAssay = false; |
---|
162 | } |
---|
163 | try |
---|
164 | { |
---|
165 | currentPhysicalBioAssay = bioAssay.getPhysicalBioAssay(); |
---|
166 | } |
---|
167 | catch (PermissionDeniedException ex) |
---|
168 | { |
---|
169 | readCurrentPhysicalBioAssay = false; |
---|
170 | } |
---|
171 | try |
---|
172 | { |
---|
173 | currentExtract = bioAssay.getExtract(); |
---|
174 | } |
---|
175 | catch (PermissionDeniedException ex) |
---|
176 | { |
---|
177 | readCurrentExtract = false; |
---|
178 | } |
---|
179 | try |
---|
180 | { |
---|
181 | currentProtocol = bioAssay.getProtocol(); |
---|
182 | } |
---|
183 | catch (PermissionDeniedException ex) |
---|
184 | { |
---|
185 | readCurrentProtocol = false; |
---|
186 | } |
---|
187 | try |
---|
188 | { |
---|
189 | currentHardware = bioAssay.getHardware(); |
---|
190 | } |
---|
191 | catch (PermissionDeniedException ex) |
---|
192 | { |
---|
193 | readCurrentHardware = false; |
---|
194 | } |
---|
195 | try |
---|
196 | { |
---|
197 | currentSoftware = bioAssay.getSoftware(); |
---|
198 | } |
---|
199 | catch (PermissionDeniedException ex) |
---|
200 | { |
---|
201 | readCurrentSoftware = false; |
---|
202 | } |
---|
203 | } |
---|
204 | // Query to retrieve item types |
---|
205 | final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(itemType); |
---|
206 | subtypesQuery.include(Include.ALL); |
---|
207 | |
---|
208 | final String clazz = "class=\"text\""; |
---|
209 | final String requiredClazz = "class=\"text required\""; |
---|
210 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), bioAssay); |
---|
211 | ExtensionsInvoker invoker = EditUtil.useEditExtensions(jspContext); |
---|
212 | %> |
---|
213 | <base:page type="popup" title="<%=title%>"> |
---|
214 | <base:head scripts="tabcontrol.js,annotations.js,platforms.js,subtypes.js,ajax.js,json2.js" styles="tabcontrol.css"> |
---|
215 | <ext:scripts context="<%=jspContext%>" /> |
---|
216 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
217 | <script language="JavaScript"> |
---|
218 | // Validate the "BioAssay" tab |
---|
219 | function validateBioAssay() |
---|
220 | { |
---|
221 | var frm = document.forms['bioAssay']; |
---|
222 | if (Main.trimString(frm.name.value) == '') |
---|
223 | { |
---|
224 | alert("You must enter a name"); |
---|
225 | frm.name.focus(); |
---|
226 | return false; |
---|
227 | } |
---|
228 | if (frm.isRoot) |
---|
229 | { |
---|
230 | if (frm.isRoot[0].checked) |
---|
231 | { |
---|
232 | if (frm.physicalbioassay_id.selectedIndex < 0) |
---|
233 | { |
---|
234 | alert("You must select a parent bioassay"); |
---|
235 | frm.physicalbioassay_id.focus(); |
---|
236 | return false; |
---|
237 | } |
---|
238 | } |
---|
239 | else |
---|
240 | { |
---|
241 | if (frm.parent_id.selectedIndex < 0) |
---|
242 | { |
---|
243 | alert("You must select a parent bioassay"); |
---|
244 | frm.parent_id.focus(); |
---|
245 | return false; |
---|
246 | } |
---|
247 | } |
---|
248 | |
---|
249 | } |
---|
250 | return true; |
---|
251 | } |
---|
252 | |
---|
253 | // Submit the form |
---|
254 | function saveSettings() |
---|
255 | { |
---|
256 | var frm = document.forms['bioAssay']; |
---|
257 | if (TabControl.validateActiveTab('settings')) |
---|
258 | { |
---|
259 | if (annotationsLoaded) |
---|
260 | { |
---|
261 | Annotations.addModifiedAnnotationsToForm(frames.annotations, frm); |
---|
262 | } |
---|
263 | if (inheritedAnnotationsLoaded) |
---|
264 | { |
---|
265 | Annotations.addInheritedAnnotationsToForm(frames.inheritedAnnotations, frm); |
---|
266 | } |
---|
267 | if (dataFilesLoaded) |
---|
268 | { |
---|
269 | Platforms.addDataFilesToForm(frames.datafiles, frm); |
---|
270 | } |
---|
271 | if (frm.isRoot) |
---|
272 | { |
---|
273 | if (frm.isRoot[0].checked) |
---|
274 | { |
---|
275 | frm.parent_id.selectedIndex = -1; |
---|
276 | } |
---|
277 | else |
---|
278 | { |
---|
279 | frm.physicalbioassay_id.selectedIndex = -1; |
---|
280 | } |
---|
281 | } |
---|
282 | frm.submit(); |
---|
283 | } |
---|
284 | } |
---|
285 | |
---|
286 | var annotationsLoaded = false; |
---|
287 | var inheritedAnnotationsLoaded = false; |
---|
288 | var parentsChanged = false; |
---|
289 | var protocolChanged = false; |
---|
290 | var dataFilesLoaded = false; |
---|
291 | function switchTab(tabControlId, tabId) |
---|
292 | { |
---|
293 | if (TabControl.setActiveTab(tabControlId, tabId)) |
---|
294 | { |
---|
295 | if (tabId == 'annotations' && (protocolChanged || !annotationsLoaded)) |
---|
296 | { |
---|
297 | Annotations.loadAnnotateFrame(frames.annotations, '<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, getProtocolId()); |
---|
298 | annotationsLoaded = true; |
---|
299 | protocolChanged = false; |
---|
300 | } |
---|
301 | else if (tabId == 'inheritedAnnotations' && |
---|
302 | (parentsChanged || !inheritedAnnotationsLoaded)) |
---|
303 | { |
---|
304 | Annotations.loadInheritFrame(frames.inheritedAnnotations, '<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, getParents()); |
---|
305 | inheritedAnnotationsLoaded = true; |
---|
306 | parentsChanged = false; |
---|
307 | } |
---|
308 | else if (tabId == 'datafiles' && (!dataFilesLoaded)) |
---|
309 | { |
---|
310 | //var platform = Platforms.getSelectedPlatform(frm.platform); |
---|
311 | //var variant = Platforms.getSelectedVariant(frm.platform); |
---|
312 | Platforms.loadDataFilesFrame(frames.datafiles, '<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, 0, 0); |
---|
313 | dataFilesLoaded = true; |
---|
314 | } |
---|
315 | } |
---|
316 | } |
---|
317 | |
---|
318 | function getProtocolId() |
---|
319 | { |
---|
320 | var frm = document.forms['bioAssay']; |
---|
321 | var protocolId = 0; |
---|
322 | if (frm.protocol_id.length > 0 && !frm.protocol_id.disabled) |
---|
323 | { |
---|
324 | protocolId = Math.abs(parseInt(frm.protocol_id[frm.protocol_id.selectedIndex].value)); |
---|
325 | } |
---|
326 | return protocolId; |
---|
327 | } |
---|
328 | |
---|
329 | function getParents() |
---|
330 | { |
---|
331 | var frm = document.forms['bioAssay']; |
---|
332 | if (!frm.physicalbioassay_id) return; |
---|
333 | |
---|
334 | var parents = new Array(); |
---|
335 | if (frm.isRoot[0].checked) |
---|
336 | { |
---|
337 | var bioAssayId = Math.abs(parseInt(frm.physicalbioassay_id[frm.physicalbioassay_id.selectedIndex].value)); |
---|
338 | if (bioAssayId > 0) parents[parents.length] = 'PHYSICALBIOASSAY:'+bioAssayId; |
---|
339 | } |
---|
340 | else |
---|
341 | { |
---|
342 | var bioAssayId = Math.abs(parseInt(frm.parent_id[frm.parent_id.selectedIndex].value)); |
---|
343 | if (bioAssayId > 0) parents[parents.length] = 'DERIVEDBIOASSAY:'+bioAssayId; |
---|
344 | } |
---|
345 | return parents; |
---|
346 | } |
---|
347 | |
---|
348 | function selectProtocolOnClick() |
---|
349 | { |
---|
350 | var frm = document.forms['bioAssay']; |
---|
351 | var url = '../../../admin/protocols/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone'; |
---|
352 | url += '&callback=setProtocolCallback&resetTemporary=1'; |
---|
353 | url += ItemSubtype.createRelatedFilter('bioAssay', 'PROTOCOL'); |
---|
354 | if (frm.protocol_id.length > 1) |
---|
355 | { |
---|
356 | var id = Math.abs(parseInt(frm.protocol_id[1].value)); |
---|
357 | url += '&item_id='+id; |
---|
358 | } |
---|
359 | Main.openPopup(url, 'SelectProtocol', 1000, 700); |
---|
360 | } |
---|
361 | function setProtocolCallback(id, name) |
---|
362 | { |
---|
363 | var frm = document.forms['bioAssay']; |
---|
364 | var list = frm.protocol_id; |
---|
365 | if (list.length < 2 || list[1].value == '0') // > |
---|
366 | { |
---|
367 | Forms.addListOption(list, 1, new Option()); |
---|
368 | } |
---|
369 | list[1].value = id; |
---|
370 | list[1].text = name; |
---|
371 | list.selectedIndex = 1; |
---|
372 | protocolChanged = true; |
---|
373 | } |
---|
374 | function protocolOnChange() |
---|
375 | { |
---|
376 | protocolChanged = true; |
---|
377 | } |
---|
378 | |
---|
379 | function selectPhysicalBioAssayOnClick() |
---|
380 | { |
---|
381 | var frm = document.forms['bioAssay']; |
---|
382 | var url = '../physicalbioassays/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone'; |
---|
383 | url += '&callback=setPhysicalBioAssayCallback&resetTemporary=1'; |
---|
384 | url += ItemSubtype.createRelatedFilter('bioAssay', 'PHYSICALBIOASSAY'); |
---|
385 | if (frm.physicalbioassay_id.selectedIndex >= 0) |
---|
386 | { |
---|
387 | var id = Math.abs(parseInt(frm.physicalbioassay_id[frm.physicalbioassay_id.selectedIndex].value)); |
---|
388 | url += '&item_id='+id; |
---|
389 | } |
---|
390 | Main.openPopup(url, 'SelectPhysicalBioAssay', 1000, 700); |
---|
391 | } |
---|
392 | function setPhysicalBioAssayCallback(id, name) |
---|
393 | { |
---|
394 | var frm = document.forms['bioAssay']; |
---|
395 | var list = frm.physicalbioassay_id; |
---|
396 | if (list.length < 1 || list[0].value == '0') // > |
---|
397 | { |
---|
398 | Forms.addListOption(list, 0, new Option()); |
---|
399 | } |
---|
400 | list[0].value = id; |
---|
401 | list[0].text = name; |
---|
402 | list.selectedIndex = 0; |
---|
403 | physicalBioAssayOnChange(); |
---|
404 | } |
---|
405 | function physicalBioAssayOnChange() |
---|
406 | { |
---|
407 | parentsChanged = true; |
---|
408 | var frm = document.forms['bioAssay']; |
---|
409 | initExtracts(); |
---|
410 | } |
---|
411 | |
---|
412 | function selectParentBioAssayOnClick() |
---|
413 | { |
---|
414 | var frm = document.forms['bioAssay']; |
---|
415 | var url = 'index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone'; |
---|
416 | url += '&callback=setParentBioAssayCallback&resetTemporary=1'; |
---|
417 | url += ItemSubtype.createRelatedFilter('bioAssay', 'DERIVEDBIOASSAY'); |
---|
418 | if (frm.parent_id.selectedIndex >= 0) |
---|
419 | { |
---|
420 | var id = Math.abs(parseInt(frm.physicalbioassay_id[frm.parent_id.selectedIndex].value)); |
---|
421 | url += '&item_id='+id; |
---|
422 | } |
---|
423 | Main.openPopup(url, 'SelectParentBioAssay', 1000, 700); |
---|
424 | } |
---|
425 | function setParentBioAssayCallback(id, name) |
---|
426 | { |
---|
427 | var frm = document.forms['bioAssay']; |
---|
428 | var list = frm.parent_id; |
---|
429 | if (list.length < 1 || list[0].value == '0') // > |
---|
430 | { |
---|
431 | Forms.addListOption(list, 0, new Option()); |
---|
432 | } |
---|
433 | list[0].value = id; |
---|
434 | list[0].text = name; |
---|
435 | list.selectedIndex = 0; |
---|
436 | parentsChanged = true; |
---|
437 | } |
---|
438 | function parentBioAssayOnChange() |
---|
439 | { |
---|
440 | parentsChanged = true; |
---|
441 | } |
---|
442 | |
---|
443 | function selectHardwareOnClick() |
---|
444 | { |
---|
445 | var frm = document.forms['bioAssay']; |
---|
446 | var url = '../../../admin/hardware/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone'; |
---|
447 | url += '&callback=setHardwareCallback&resetTemporary=1'; |
---|
448 | url += ItemSubtype.createRelatedFilter('bioAssay', 'HARDWARE'); |
---|
449 | if (frm.hardware_id.length > 1) |
---|
450 | { |
---|
451 | var id = Math.abs(parseInt(frm.hardware_id[1].value)); |
---|
452 | url += '&item_id='+id; |
---|
453 | } |
---|
454 | Main.openPopup(url, 'SelectHardware', 1000, 700); |
---|
455 | } |
---|
456 | function setHardwareCallback(id, name) |
---|
457 | { |
---|
458 | var frm = document.forms['bioAssay']; |
---|
459 | var list = frm.hardware_id; |
---|
460 | if (list.length < 2 || list[1].value == '0') // > |
---|
461 | { |
---|
462 | Forms.addListOption(list, 1, new Option()); |
---|
463 | } |
---|
464 | list[1].value = id; |
---|
465 | list[1].text = name; |
---|
466 | list.selectedIndex = 1; |
---|
467 | } |
---|
468 | function selectSoftwareOnClick() |
---|
469 | { |
---|
470 | var frm = document.forms['bioAssay']; |
---|
471 | var url = '../../../admin/software/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone'; |
---|
472 | url += '&callback=setSoftwareCallback&resetTemporary=1'; |
---|
473 | url += ItemSubtype.createRelatedFilter('bioAssay', 'SOFTWARE'); |
---|
474 | if (frm.software_id.length > 1) |
---|
475 | { |
---|
476 | var id = Math.abs(parseInt(frm.software_id[1].value)); |
---|
477 | url += '&item_id='+id; |
---|
478 | } |
---|
479 | Main.openPopup(url, 'SelectSoftware', 1000, 700); |
---|
480 | } |
---|
481 | function setSoftwareCallback(id, name) |
---|
482 | { |
---|
483 | var frm = document.forms['bioAssay']; |
---|
484 | var list = frm.software_id; |
---|
485 | if (list.length < 2 || list[1].value == '0') // > |
---|
486 | { |
---|
487 | Forms.addListOption(list, 1, new Option()); |
---|
488 | } |
---|
489 | list[1].value = id; |
---|
490 | list[1].text = name; |
---|
491 | list.selectedIndex = 1; |
---|
492 | } |
---|
493 | |
---|
494 | function init() |
---|
495 | { |
---|
496 | var frm = document.forms['bioAssay']; |
---|
497 | <% |
---|
498 | if (bioAssay == null) |
---|
499 | { |
---|
500 | %> |
---|
501 | frm.name.focus(); |
---|
502 | frm.name.select(); |
---|
503 | <% |
---|
504 | } |
---|
505 | %> |
---|
506 | if (frm.isRoot) |
---|
507 | { |
---|
508 | isRootOnChange(); |
---|
509 | } |
---|
510 | else |
---|
511 | { |
---|
512 | initExtracts(); |
---|
513 | } |
---|
514 | } |
---|
515 | |
---|
516 | function isRootOnChange() |
---|
517 | { |
---|
518 | var frm = document.forms['bioAssay']; |
---|
519 | var isRoot = frm.isRoot[0].checked; |
---|
520 | Main.showHide('physicalBioAssaySection', isRoot); |
---|
521 | Main.showHide('parentBioAssaySection', !isRoot); |
---|
522 | initExtracts(); |
---|
523 | } |
---|
524 | |
---|
525 | function initExtracts() |
---|
526 | { |
---|
527 | var frm = document.forms['bioAssay']; |
---|
528 | frm.extract_id.length = 0; |
---|
529 | var extracts; |
---|
530 | <% |
---|
531 | if (bioAssay == null) |
---|
532 | { |
---|
533 | %> |
---|
534 | if (frm.isRoot[0].checked) |
---|
535 | { |
---|
536 | extracts = getExtractsFromPhysicalBioAssay(frm.physicalbioassay_id[frm.physicalbioassay_id.selectedIndex].value); |
---|
537 | } |
---|
538 | else |
---|
539 | { |
---|
540 | extracts = getExtractsFromParentBioassay(frm.parent_id[frm.parent_id.selectedIndex].value); |
---|
541 | } |
---|
542 | <% |
---|
543 | } |
---|
544 | else |
---|
545 | { |
---|
546 | if (currentParentBioAssay != null) |
---|
547 | { |
---|
548 | %> |
---|
549 | extracts = getExtractsFromParentBioassay(<%=currentParentBioAssay.getId()%>); |
---|
550 | <% |
---|
551 | } |
---|
552 | else if (currentPhysicalBioAssay != null) |
---|
553 | { |
---|
554 | %> |
---|
555 | extracts = getExtractsFromPhysicalBioAssay(<%=currentPhysicalBioAssay.getId()%>); |
---|
556 | <% |
---|
557 | } |
---|
558 | } |
---|
559 | %> |
---|
560 | |
---|
561 | var frm = document.forms['bioAssay']; |
---|
562 | frm.extract_id.length = 0; |
---|
563 | frm.extract_id[frm.extract_id.length] = new Option('- none -', 0); |
---|
564 | var currentExtractId = <%=currentExtract == null ? 0 : currentExtract.getId()%>; |
---|
565 | var currentWasFound = 0; |
---|
566 | for (var i = 0; i < extracts.length; i++) |
---|
567 | { |
---|
568 | var position = extracts[i].position; |
---|
569 | var prefix = position ? position + ': ' : ''; |
---|
570 | frm.extract_id[frm.extract_id.length] = new Option(prefix + extracts[i].name, extracts[i].id); |
---|
571 | if (currentExtractId == extracts[i].id) |
---|
572 | { |
---|
573 | frm.extract_id.selectedIndex = frm.extract_id.length - 1; |
---|
574 | currentWasFound = 1; |
---|
575 | } |
---|
576 | } |
---|
577 | <% |
---|
578 | if (currentExtract != null) |
---|
579 | { |
---|
580 | %> |
---|
581 | if (currentExtractId && !currentWasFound) |
---|
582 | { |
---|
583 | frm.extract_id[frm.extract_id.length] = new Option('<%=HTML.javaScriptEncode(currentExtract.getName())%>', currentExtractId); |
---|
584 | frm.extract_id.selectedIndex = frm.extract_id.length - 1; |
---|
585 | } |
---|
586 | <% |
---|
587 | } |
---|
588 | %> |
---|
589 | } |
---|
590 | |
---|
591 | function getExtractsFromPhysicalBioAssay(physicalBioAssayId) |
---|
592 | { |
---|
593 | var request = Ajax.getXmlHttpRequest(); |
---|
594 | var url = '../physicalbioassays/ajax.jsp?ID=<%=ID%>&cmd=GetSources'; |
---|
595 | url += '&item_id=' + physicalBioAssayId; |
---|
596 | request.open("GET", url, false); |
---|
597 | request.send(null); |
---|
598 | |
---|
599 | var response = JSON.parse(request.responseText); |
---|
600 | if (response.status != 'ok') |
---|
601 | { |
---|
602 | alert(response.message); |
---|
603 | return; |
---|
604 | } |
---|
605 | return response.sources; |
---|
606 | } |
---|
607 | |
---|
608 | function getExtractsFromParentBioassay(bioAssayId) |
---|
609 | { |
---|
610 | var request = Ajax.getXmlHttpRequest(); |
---|
611 | var url = 'ajax.jsp?ID=<%=ID%>&cmd=GetExtracts'; |
---|
612 | url += '&item_id=' + bioAssayId; |
---|
613 | request.open("GET", url, false); |
---|
614 | request.send(null); |
---|
615 | |
---|
616 | var response = JSON.parse(request.responseText); |
---|
617 | if (response.status != 'ok') |
---|
618 | { |
---|
619 | alert(response.message); |
---|
620 | return; |
---|
621 | } |
---|
622 | |
---|
623 | return response.sources; |
---|
624 | } |
---|
625 | </script> |
---|
626 | </base:head> |
---|
627 | <base:body onload="init()"> |
---|
628 | <p> |
---|
629 | <form action="index.jsp?ID=<%=ID%>" method="post" name="bioAssay" onsubmit="return false;"> |
---|
630 | <input type="hidden" name="cmd" value="UpdateItem"> |
---|
631 | |
---|
632 | <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3> |
---|
633 | <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*370)+"px;"%>" |
---|
634 | position="bottom" remember="<%=bioAssay != null%>" switch="switchTab" |
---|
635 | extensions="<%=invoker%>"> |
---|
636 | <t:tab id="info" title="Bioassay" validate="validateBioAssay()" helpid="derivedbioassay.edit"> |
---|
637 | <table class="form" cellspacing=0> |
---|
638 | <tr> |
---|
639 | <td class="prompt" width="120px">Name</td> |
---|
640 | <td><input <%=requiredClazz%> type="text" name="name" |
---|
641 | value="<%=HTML.encodeTags(bioAssay == null ? Values.getString(cc.getPropertyValue("name"), "New derived bioassay") : bioAssay.getName())%>" |
---|
642 | size="40" maxlength="<%=DerivedBioAssay.MAX_NAME_LENGTH%>"></td> |
---|
643 | </tr> |
---|
644 | |
---|
645 | <tr valign="top"> |
---|
646 | <td class="prompt">Type</td> |
---|
647 | <td colspan="2"> |
---|
648 | <select name="subtype_id" |
---|
649 | <%=!readCurrentSubtype ? "disabled readonly class=\"disabled selectionlist\"" : "class=\"selectionlist\""%>> |
---|
650 | <% |
---|
651 | if (!readCurrentSubtype) |
---|
652 | { |
---|
653 | %> |
---|
654 | <option value="-1">- denied - |
---|
655 | <% |
---|
656 | } |
---|
657 | else |
---|
658 | { |
---|
659 | %> |
---|
660 | <option value="0">-none- |
---|
661 | <% |
---|
662 | for (ItemSubtype subtype : subtypesQuery.list(dc)) |
---|
663 | { |
---|
664 | int id = subtype.getId(); |
---|
665 | if (id != currentSubtypeId && subtype.isRemoved()) continue; |
---|
666 | %> |
---|
667 | <option value="<%=id == currentSubtypeId && bioAssay != null ? -id : id%>" |
---|
668 | <%=id == currentSubtypeId ? "selected" : ""%> |
---|
669 | title="<%=HTML.encodeTags(subtype.getDescription()) %>" |
---|
670 | ><%=HTML.encodeTags(subtype.getName())%> |
---|
671 | <% |
---|
672 | } |
---|
673 | } |
---|
674 | %> |
---|
675 | </select> |
---|
676 | </td> |
---|
677 | </tr> |
---|
678 | <% |
---|
679 | if (bioAssay == null) |
---|
680 | { |
---|
681 | %> |
---|
682 | <tr> |
---|
683 | <td class="prompt">Parent type</td> |
---|
684 | <td> |
---|
685 | <input id="isRoot" type="radio" name="isRoot" value="1" |
---|
686 | <%=currentParentBioAssay == null ? "checked" : "" %> |
---|
687 | onchange="isRootOnChange()"><label for="isRoot">Physical bioassay</label> |
---|
688 | <input id="isChild" type="radio" name="isRoot" value="0" |
---|
689 | <%=currentParentBioAssay == null ? "" : "checked" %> |
---|
690 | onchange="isRootOnChange()"><label for="isChild">Derived bioassay</label><br> |
---|
691 | </td> |
---|
692 | </tr> |
---|
693 | <tr id="physicalBioAssaySection" style="display: none;"> |
---|
694 | <td class="subprompt">-physical bioassay</td> |
---|
695 | <td> |
---|
696 | <base:select |
---|
697 | id="physicalbioassay_id" |
---|
698 | clazz="selectionlist unchangeable" |
---|
699 | required="true" |
---|
700 | current="<%=currentPhysicalBioAssay%>" |
---|
701 | recent="<%=recentPhysicalBioAssays%>" |
---|
702 | newitem="true" |
---|
703 | onselect="selectPhysicalBioAssayOnClick()" |
---|
704 | onchange="physicalBioAssayOnChange()" |
---|
705 | /> |
---|
706 | </td> |
---|
707 | </tr> |
---|
708 | <tr id="parentBioAssaySection" style="display: none;"> |
---|
709 | <td class="subprompt">-bioassay</td> |
---|
710 | <td> |
---|
711 | <base:select |
---|
712 | id="parent_id" |
---|
713 | clazz="selectionlist unchangeable" |
---|
714 | required="true" |
---|
715 | current="<%=currentParentBioAssay%>" |
---|
716 | recent="<%=recentParentBioAssays%>" |
---|
717 | newitem="true" |
---|
718 | onselect="selectParentBioAssayOnClick()" |
---|
719 | onchange="parentBioAssayOnChange()" |
---|
720 | /> |
---|
721 | </td> |
---|
722 | </tr> |
---|
723 | <% |
---|
724 | } |
---|
725 | %> |
---|
726 | <tr> |
---|
727 | <td class="prompt">Extract</td> |
---|
728 | <td> |
---|
729 | <select name="extract_id" class="selectionlist"></select> |
---|
730 | </td> |
---|
731 | </tr> |
---|
732 | <tr> |
---|
733 | <td class="prompt">Protocol</td> |
---|
734 | <td> |
---|
735 | <base:select |
---|
736 | id="protocol_id" |
---|
737 | clazz="selectionlist" |
---|
738 | required="false" |
---|
739 | current="<%=currentProtocol%>" |
---|
740 | denied="<%=!readCurrentProtocol%>" |
---|
741 | recent="<%=recentProtocols%>" |
---|
742 | defaultitem="<%=defaultProtocol%>" |
---|
743 | newitem="<%=bioAssay == null%>" |
---|
744 | onselect="selectProtocolOnClick()" |
---|
745 | onchange="protocolOnChange()" |
---|
746 | /> |
---|
747 | </td> |
---|
748 | </tr> |
---|
749 | <tr> |
---|
750 | <td class="prompt">Hardware</td> |
---|
751 | <td> |
---|
752 | <base:select |
---|
753 | id="hardware_id" |
---|
754 | clazz="selectionlist" |
---|
755 | required="false" |
---|
756 | current="<%=currentHardware%>" |
---|
757 | denied="<%=!readCurrentHardware%>" |
---|
758 | recent="<%=recentHardware%>" |
---|
759 | defaultitem="<%=defaultHardware%>" |
---|
760 | newitem="<%=bioAssay == null%>" |
---|
761 | onselect="selectHardwareOnClick()" |
---|
762 | /> |
---|
763 | </td> |
---|
764 | </tr> |
---|
765 | <tr> |
---|
766 | <td class="prompt">Software</td> |
---|
767 | <td> |
---|
768 | <base:select |
---|
769 | id="software_id" |
---|
770 | clazz="selectionlist" |
---|
771 | required="false" |
---|
772 | current="<%=currentSoftware%>" |
---|
773 | denied="<%=!readCurrentSoftware%>" |
---|
774 | recent="<%=recentSoftware%>" |
---|
775 | defaultitem="<%=defaultSoftware%>" |
---|
776 | newitem="<%=bioAssay == null%>" |
---|
777 | onselect="selectSoftwareOnClick()" |
---|
778 | /> |
---|
779 | </td> |
---|
780 | </tr> |
---|
781 | |
---|
782 | <tr valign=top> |
---|
783 | <td class="prompt">Description</td> |
---|
784 | <td nowrap> |
---|
785 | <textarea <%=clazz%> rows="4" cols="40" name="description" wrap="virtual" |
---|
786 | ><%=HTML.encodeTags(bioAssay == null ? cc.getPropertyValue("description") : bioAssay.getDescription())%></textarea> |
---|
787 | <a href="javascript:Main.zoom('Description', 'bioAssay', 'description')" |
---|
788 | title="Edit in larger window"><base:icon image="zoom.gif" /></a> |
---|
789 | </td> |
---|
790 | </tr> |
---|
791 | </table> |
---|
792 | <div align=right> <i><base:icon image="required.gif" /> = required information</i> |
---|
793 | <%if (bioAssay == null) {%><br> |
---|
794 | <i><base:icon image="unchangeable.gif" /> = can't be changed later</i> |
---|
795 | <%}%> |
---|
796 | </div> |
---|
797 | </t:tab> |
---|
798 | |
---|
799 | <t:tab id="datafiles" title="Data files" helpid="datafiles.edit"> |
---|
800 | <iframe name="datafiles" id="idDatafiles" src="../../../common/datafiles/wait.jsp" |
---|
801 | width="100%" height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0 |
---|
802 | marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe> |
---|
803 | </t:tab> |
---|
804 | |
---|
805 | <t:tab id="annotations" title="Annotations" |
---|
806 | helpid="annotations.edit" tooltip="Enter values for annotations"> |
---|
807 | <iframe name="annotations" id="idAnnotations" src="../../../common/annotations/wait.jsp" |
---|
808 | width="100%" height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0 |
---|
809 | marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe> |
---|
810 | </t:tab> |
---|
811 | |
---|
812 | <t:tab id="inheritedAnnotations" title="Inherited annotations" helpid="annotations.edit.inherited"> |
---|
813 | <iframe name="inheritedAnnotations" id="idInheritedAnnotations" src="../../../common/annotations/wait.jsp" |
---|
814 | width="100%" height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0 |
---|
815 | marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe> |
---|
816 | </t:tab> |
---|
817 | </t:tabcontrol> |
---|
818 | |
---|
819 | <table align="center"> |
---|
820 | <tr> |
---|
821 | <td width="50%"><base:button onclick="saveSettings()" title="Save" /></td> |
---|
822 | <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td> |
---|
823 | </tr> |
---|
824 | </table> |
---|
825 | </form> |
---|
826 | </base:body> |
---|
827 | </base:page> |
---|
828 | <% |
---|
829 | } |
---|
830 | finally |
---|
831 | { |
---|
832 | if (dc != null) dc.close(); |
---|
833 | } |
---|
834 | %> |
---|