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