source: trunk/www/views/derivedbioassays/edit_bioassay.jsp @ 5687

Last change on this file since 5687 was 5687, checked in by Nicklas Nordborg, 12 years ago

References #1597: Subtypes of items

Smarter selection of default subtypes and related items (protocols, etc) have now been implemented in the other important edit dialogs.

Added support for also loading and displaying project default items dynamically based on the selected subtype.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 26.5 KB
Line 
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<%
59final Item itemType = Item.DERIVEDBIOASSAY;
60final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
61final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
62final int itemId = cc.getId();
63final String ID = sc.getId();
64final float scale = Base.getScale(sc);
65final DbControl dc = sc.newDbControl();
66try
67{
68  DerivedBioAssay bioAssay = null;
69  String title = null;
70 
71  boolean readCurrentSubtype = true;
72  ItemSubtype currentSubtype = null;
73
74  boolean readCurrentPhysicalBioAssay = true;
75  PhysicalBioAssay currentPhysicalBioAssay = null;
76 
77  boolean readCurrentParentBioAssay = true;
78  DerivedBioAssay currentParentBioAssay = null;
79 
80  boolean readCurrentExtract = true;
81  Extract currentExtract = null;
82
83  boolean readCurrentProtocol = true;
84  Protocol currentProtocol = null;
85 
86  boolean readCurrentHardware = true;
87  Hardware currentHardware = null;
88 
89  boolean readCurrentSoftware = true;
90  Software currentSoftware = null;
91
92  if (itemId == 0)
93  {
94    title = "New derived bioassay";
95    cc.removeObject("item");
96    int currentSubtypeId = Values.getInt(request.getParameter("subtype_id"));
97    List<ItemSubtype> relatedToParent = Collections.emptyList();
98    int parentId = Values.getInt(request.getParameter("parent_id"));
99    if (parentId != 0)
100    {
101      currentParentBioAssay = DerivedBioAssay.getById(dc, parentId);
102      if (currentSubtypeId == 0)
103      {
104        relatedToParent = ItemSubtype.getParentSubtypes(dc, currentParentBioAssay, Item.DERIVEDBIOASSAY);
105      }
106      try
107      {
108        currentPhysicalBioAssay = currentParentBioAssay.getPhysicalBioAssay();
109      }
110      catch (PermissionDeniedException ex)
111      {
112        readCurrentPhysicalBioAssay = false;
113      }
114      try
115      {
116        currentExtract = currentParentBioAssay.getExtract();
117      }
118      catch (PermissionDeniedException ex)
119      {}
120    }
121    else
122    {
123      int physicalBioAssayId = Values.getInt(request.getParameter("physicalbioassay_id"));
124      if (physicalBioAssayId != 0)
125      {
126        currentPhysicalBioAssay = PhysicalBioAssay.getById(dc, physicalBioAssayId);
127        if (currentSubtypeId == 0)
128        {
129          relatedToParent = ItemSubtype.getParentSubtypes(dc, currentPhysicalBioAssay, Item.DERIVEDBIOASSAY);
130        }
131      }
132    }
133    if (currentSubtypeId == 0) 
134    {
135      if (relatedToParent.size() > 0)
136      {
137        // Find most recently used related subtype
138        List<ItemSubtype> recentSubtypes = (List<ItemSubtype>)cc.getRecent(dc, Item.ITEMSUBTYPE);
139        currentSubtype = ListUtil.findFirstCommon(recentSubtypes, relatedToParent, relatedToParent.get(0));
140      }
141      else
142      {
143        int recentSubtypeId = Values.getInt(cc.getRecent(Item.ITEMSUBTYPE.name(), 0));
144        currentSubtypeId = Values.getInt(cc.getPropertyValue("itemSubtype"), recentSubtypeId);
145        if (currentSubtypeId > 0) currentSubtype = ItemSubtype.getById(dc, currentSubtypeId);
146      }
147    }
148  }
149  else
150  {
151    bioAssay = DerivedBioAssay.getById(dc, itemId);
152    bioAssay.checkPermission(Permission.WRITE);
153    cc.setObject("item", bioAssay);
154    title = "Edit bioassay -- " + HTML.encodeTags(bioAssay.getName());
155   
156    try
157    {
158      currentSubtype = bioAssay.getItemSubtype();
159    }
160    catch (PermissionDeniedException ex)
161    {
162      readCurrentSubtype = false;
163    }
164    try
165    {
166      currentParentBioAssay = bioAssay.getParent();
167    }
168    catch (PermissionDeniedException ex)
169    {
170      readCurrentParentBioAssay = false;
171    }
172    try
173    {
174      currentPhysicalBioAssay = bioAssay.getPhysicalBioAssay();
175    }
176    catch (PermissionDeniedException ex)
177    {
178      readCurrentPhysicalBioAssay = false;
179    }
180    try
181    {
182      currentExtract = bioAssay.getExtract();
183    }
184    catch (PermissionDeniedException ex)
185    {
186      readCurrentExtract = false;
187    }
188    try
189    {
190      currentProtocol = bioAssay.getProtocol();
191    }
192    catch (PermissionDeniedException ex)
193    {
194      readCurrentProtocol = false;
195    }
196    try
197    {
198      currentHardware = bioAssay.getHardware();
199    }
200    catch (PermissionDeniedException ex)
201    {
202      readCurrentHardware = false;
203    }
204    try
205    {
206      currentSoftware = bioAssay.getSoftware();
207    }
208    catch (PermissionDeniedException ex)
209    {
210      readCurrentSoftware = false;
211    }
212  }
213
214  // Default items
215  int activeProjectId = sc.getActiveProjectId();
216  List<Protocol> defaultProtocols = null;
217  List<Hardware> defaultHardware = null;
218  List<Software> defaultSoftware = null;
219  if (activeProjectId > 0)
220  {
221    Project activeProject = Project.getById(dc, activeProjectId);
222    defaultProtocols = (List<Protocol>)activeProject.findDefaultItemsOfRelatedSubtype(dc, currentSubtype, Item.PROTOCOL);
223    defaultHardware = (List<Hardware>)activeProject.findDefaultItemsOfRelatedSubtype(dc, currentSubtype, Item.HARDWARE);
224    defaultSoftware = (List<Software>)activeProject.findDefaultItemsOfRelatedSubtype(dc, currentSubtype, Item.SOFTWARE);
225  }
226
227  // Load recently used items
228  List<PhysicalBioAssay> recentPhysicalBioAssays = (List<PhysicalBioAssay>)cc.getRecent(dc, Item.PHYSICALBIOASSAY);
229  List<DerivedBioAssay> recentParentBioAssays = (List<DerivedBioAssay>)cc.getRecent(dc, Item.DERIVEDBIOASSAY);
230  List<Protocol> recentProtocols = (List<Protocol>)cc.getRecent(dc, Item.PROTOCOL, currentSubtype);
231  List<Hardware> recentHardware = (List<Hardware>)cc.getRecent(dc, Item.HARDWARE, currentSubtype);
232  List<Software> recentSoftware = (List<Software>)cc.getRecent(dc, Item.SOFTWARE, currentSubtype);
233 
234  // Query to retrieve item types
235  final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(itemType);
236  subtypesQuery.include(Include.ALL);
237
238  final String clazz = "class=\"text\"";
239  final String requiredClazz = "class=\"text required\"";
240  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), bioAssay);
241  ExtensionsInvoker invoker = EditUtil.useEditExtensions(jspContext);
242  %>
243  <base:page type="popup" title="<%=title%>">
244  <base:head scripts="tabcontrol.js,annotations.js,platforms.js,subtypes.js,ajax.js,json2.js" styles="tabcontrol.css">
245    <ext:scripts context="<%=jspContext%>" />
246    <ext:stylesheets context="<%=jspContext%>" />
247    <script language="JavaScript">
248    // Validate the "BioAssay" tab
249    function validateBioAssay()
250    {
251      var frm = document.forms['bioAssay'];
252      if (Main.trimString(frm.name.value) == '')
253      {
254        alert("You must enter a name");
255        frm.name.focus();
256        return false;
257      }
258      if (frm.isRoot)
259      {
260        if (frm.isRoot[0].checked)
261        {
262          if (frm.physicalbioassay_id.selectedIndex < 0)
263          {
264            alert("You must select a parent bioassay");
265            frm.physicalbioassay_id.focus();
266            return false;
267          }
268        }
269        else
270        {
271          if (frm.parent_id.selectedIndex < 0)
272          {
273            alert("You must select a parent bioassay");
274            frm.parent_id.focus();
275            return false;
276          }
277        }
278       
279      }
280      return true;
281    }
282
283    // Submit the form
284    function saveSettings()
285    {
286      var frm = document.forms['bioAssay'];
287      if (TabControl.validateActiveTab('settings'))
288      {
289        if (annotationsLoaded) 
290        {
291          Annotations.addModifiedAnnotationsToForm(frames.annotations, frm);
292        }
293        if (inheritedAnnotationsLoaded)
294        {
295          Annotations.addInheritedAnnotationsToForm(frames.inheritedAnnotations, frm);
296        }
297        if (dataFilesLoaded)
298        {
299          Platforms.addDataFilesToForm(frames.datafiles, frm);
300        }
301        if (frm.isRoot)
302        {
303          if (frm.isRoot[0].checked)
304          {
305            frm.parent_id.selectedIndex = -1; 
306          }
307          else
308          {
309            frm.physicalbioassay_id.selectedIndex = -1;
310          }
311        }
312        frm.submit();
313      }
314    }
315   
316    var annotationsLoaded = false;
317    var inheritedAnnotationsLoaded = false;
318    var parentsChanged = false;
319    var protocolChanged = false;
320    var dataFilesLoaded = false;
321    function switchTab(tabControlId, tabId)
322    {
323      if (TabControl.setActiveTab(tabControlId, tabId))
324      {
325        if (tabId == 'annotations' && (protocolChanged || !annotationsLoaded))
326        {
327          Annotations.loadAnnotateFrame(frames.annotations, '<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, getProtocolId());
328          annotationsLoaded = true;
329          protocolChanged = false;
330        }
331        else if (tabId == 'inheritedAnnotations' && 
332          (parentsChanged || !inheritedAnnotationsLoaded))
333        {
334          Annotations.loadInheritFrame(frames.inheritedAnnotations, '<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, getParents());
335          inheritedAnnotationsLoaded = true;
336          parentsChanged = false;
337        }
338        else if (tabId == 'datafiles' && (!dataFilesLoaded))
339        {
340          //var platform = Platforms.getSelectedPlatform(frm.platform);
341          //var variant = Platforms.getSelectedVariant(frm.platform);
342          Platforms.loadDataFilesFrame(frames.datafiles, '<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, 0, 0);
343          dataFilesLoaded = true;
344        }
345      }
346    }
347   
348    function getProtocolId()
349    {
350      var frm = document.forms['bioAssay'];
351      var protocolId = 0;
352      if (frm.protocol_id.length > 0 && !frm.protocol_id.disabled)
353      {
354        protocolId = Math.abs(parseInt(frm.protocol_id[frm.protocol_id.selectedIndex].value));       
355      }
356      return protocolId;
357    }
358   
359    function getParents()
360    {
361      var frm = document.forms['bioAssay'];
362      if (!frm.physicalbioassay_id) return;
363     
364      var parents = new Array();
365      if (frm.isRoot[0].checked)
366      {
367        var bioAssayId = Math.abs(parseInt(frm.physicalbioassay_id[frm.physicalbioassay_id.selectedIndex].value));
368        if (bioAssayId > 0) parents[parents.length] = 'PHYSICALBIOASSAY:'+bioAssayId;
369      }
370      else
371      {
372        var bioAssayId = Math.abs(parseInt(frm.parent_id[frm.parent_id.selectedIndex].value));
373        if (bioAssayId > 0) parents[parents.length] = 'DERIVEDBIOASSAY:'+bioAssayId;
374      }
375      return parents;
376    }
377   
378    function subtypeOnChange()
379    {
380      var frm = document.forms['bioAssay'];
381      var subtypeId = ItemSubtype.getSubtypeId('bioAssay');
382      var recentInfo = ItemSubtype.getRecentAndRelatedInfo(subtypeId, 'BIOASSAY', ['PROTOCOL', 'HARDWARE', 'SOFTWARE']);
383      protocolChanged = ItemSubtype.updateRecentItemsInList(frm.protocol_id, recentInfo.PROTOCOL['recent']);
384      ItemSubtype.updateDefaultItemsInList(frm.protocol_id, recentInfo.PROTOCOL['default']);
385      ItemSubtype.updateRecentItemsInList(frm.hardware_id, recentInfo.HARDWARE['recent']);
386      ItemSubtype.updateDefaultItemsInList(frm.hardware_id, recentInfo.HARDWARE['default']);
387      ItemSubtype.updateRecentItemsInList(frm.software_id, recentInfo.SOFTWARE['recent']);
388      ItemSubtype.updateDefaultItemsInList(frm.software_id, 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', 1000, 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', 1000, 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      var frm = document.forms['bioAssay'];
453      initExtracts();
454    }
455   
456    function selectParentBioAssayOnClick()
457    {
458      var frm = document.forms['bioAssay'];
459      var url = 'index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone';
460      url += '&callback=setParentBioAssayCallback&resetTemporary=1';
461      url += ItemSubtype.createRelatedFilter('bioAssay', 'DERIVEDBIOASSAY');
462      if (frm.parent_id.selectedIndex >= 0)
463      {
464        var id = Math.abs(parseInt(frm.physicalbioassay_id[frm.parent_id.selectedIndex].value));       
465        url += '&item_id='+id;
466      }
467      Main.openPopup(url, 'SelectParentBioAssay', 1000, 700);
468    }
469    function setParentBioAssayCallback(id, name)
470    {
471      var frm = document.forms['bioAssay'];
472      var list = frm.parent_id;
473      if (list.length < 1 || list[0].value == '0') // >
474      {
475        Forms.addListOption(list, 0, new Option());
476      }
477      list[0].value = id;
478      list[0].text = name;
479      list.selectedIndex = 0;
480      parentsChanged = true;
481    }
482    function parentBioAssayOnChange()
483    {
484      parentsChanged = true;
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', 1000, 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', 1000, 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      frm.extract_id.length = 0;
573      var extracts;
574      <%
575      if (bioAssay == null)
576      {
577        %>
578        if (frm.isRoot[0].checked)
579        {
580          extracts = getExtractsFromPhysicalBioAssay(frm.physicalbioassay_id[frm.physicalbioassay_id.selectedIndex].value);
581        }
582        else
583        {
584          extracts = getExtractsFromParentBioassay(frm.parent_id[frm.parent_id.selectedIndex].value);
585        }
586        <%
587      }
588      else
589      {
590        if (currentParentBioAssay != null)
591        {
592          %>
593          extracts = getExtractsFromParentBioassay(<%=currentParentBioAssay.getId()%>);
594          <%
595        }
596        else if (currentPhysicalBioAssay != null)
597        {
598          %>
599          extracts = getExtractsFromPhysicalBioAssay(<%=currentPhysicalBioAssay.getId()%>);
600          <%
601        }
602      }
603      %>
604
605      var frm = document.forms['bioAssay'];
606      frm.extract_id.length = 0;
607      frm.extract_id[frm.extract_id.length] = new Option('- none -', 0);
608      var currentExtractId = <%=currentExtract == null ? 0 : currentExtract.getId()%>;
609      var currentWasFound = 0;
610      for (var i = 0; i < extracts.length; i++)
611      {
612        var position = extracts[i].position;
613        var prefix = position ? position + ': ' : '';
614        frm.extract_id[frm.extract_id.length] = new Option(prefix + extracts[i].name, extracts[i].id);
615        if (currentExtractId == extracts[i].id) 
616        {
617          frm.extract_id.selectedIndex = frm.extract_id.length - 1;
618          currentWasFound = 1;
619        }
620      }
621      <%
622      if (currentExtract != null)
623      {
624        %>
625        if (currentExtractId && !currentWasFound)
626        {
627          frm.extract_id[frm.extract_id.length] = new Option('<%=HTML.javaScriptEncode(currentExtract.getName())%>', currentExtractId);
628          frm.extract_id.selectedIndex = frm.extract_id.length - 1;
629        }
630        <%
631      }
632      %>
633    }
634   
635    function getExtractsFromPhysicalBioAssay(physicalBioAssayId)
636    {
637      var request = Ajax.getXmlHttpRequest();
638      var url = '../physicalbioassays/ajax.jsp?ID=<%=ID%>&cmd=GetSources';
639      url += '&item_id=' + physicalBioAssayId;
640      request.open("GET", url, false);
641      request.send(null);
642     
643      var response = JSON.parse(request.responseText);
644      if (response.status != 'ok')
645      {
646        alert(response.message);
647        return;
648      }
649      return response.sources;
650    }
651 
652    function getExtractsFromParentBioassay(bioAssayId)
653    {
654      var request = Ajax.getXmlHttpRequest();
655      var url = 'ajax.jsp?ID=<%=ID%>&cmd=GetExtracts';
656      url += '&item_id=' + bioAssayId;
657      request.open("GET", url, false);
658      request.send(null);
659
660      var response = JSON.parse(request.responseText);
661      if (response.status != 'ok')
662      {
663        alert(response.message);
664        return;
665      }
666     
667      return response.sources;
668    }
669    </script>
670  </base:head>
671  <base:body onload="init()">
672    <p>
673    <form action="index.jsp?ID=<%=ID%>" method="post" name="bioAssay" onsubmit="return false;">
674    <input type="hidden" name="cmd" value="UpdateItem">
675
676    <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3>
677    <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*370)+"px;"%>" 
678      position="bottom"  remember="<%=bioAssay != null%>" switch="switchTab"
679      extensions="<%=invoker%>">
680    <t:tab id="info" title="Bioassay" validate="validateBioAssay()" helpid="derivedbioassay.edit">
681      <table class="form" cellspacing=0>
682      <tr>
683        <td class="prompt" width="120px">Name</td>
684        <td><input <%=requiredClazz%> type="text" name="name" 
685          value="<%=HTML.encodeTags(bioAssay == null ? Values.getString(cc.getPropertyValue("name"), "New derived bioassay") : bioAssay.getName())%>" 
686          size="40" maxlength="<%=DerivedBioAssay.MAX_NAME_LENGTH%>"></td>
687      </tr>
688
689      <tr valign="top">
690        <td class="prompt">Type</td>
691        <td colspan="2">
692          <select name="subtype_id"
693            <%=!readCurrentSubtype ? "disabled readonly class=\"disabled selectionlist\"" : "class=\"selectionlist\""%>
694            onchange="subtypeOnChange()"
695            >
696          <%
697          if (!readCurrentSubtype)
698          {
699            %>
700            <option value="-1">- denied -
701            <%
702          }
703          else
704          {
705            %>
706            <option value="0">-none-
707            <%
708            int currentSubtypeId = currentSubtype == null ? 0 : currentSubtype.getId();
709            for (ItemSubtype subtype : subtypesQuery.list(dc))
710            {
711              int id = subtype.getId();
712              if (id != currentSubtypeId && subtype.isRemoved()) continue;
713              %>
714              <option value="<%=id == currentSubtypeId && bioAssay != null ? -id : id%>" 
715                <%=id == currentSubtypeId ? "selected" : ""%>
716                title="<%=HTML.encodeTags(subtype.getDescription()) %>"
717                ><%=HTML.encodeTags(subtype.getName())%>
718              <%
719            }
720          }
721          %>
722          </select>
723        </td>
724      </tr>
725      <%
726      if (bioAssay == null)
727      {
728        %>
729        <tr>
730          <td class="prompt">Parent type</td>
731          <td>
732            <input id="isRoot" type="radio" name="isRoot" value="1" 
733              <%=currentParentBioAssay == null ? "checked" : "" %>
734              onchange="isRootOnChange()"><label for="isRoot">Physical bioassay</label>
735            <input id="isChild" type="radio" name="isRoot" value="0"
736              <%=currentParentBioAssay == null ? "" : "checked" %>
737              onchange="isRootOnChange()"><label for="isChild">Derived bioassay</label><br>
738          </td>
739        </tr>
740        <tr id="physicalBioAssaySection" style="display: none;">
741          <td class="subprompt">-physical bioassay</td>
742          <td>
743            <base:select 
744              id="physicalbioassay_id"
745              clazz="selectionlist unchangeable"
746              required="true"
747              current="<%=currentPhysicalBioAssay%>"
748              recent="<%=recentPhysicalBioAssays%>"
749              newitem="true"
750              onselect="selectPhysicalBioAssayOnClick()"
751              onchange="physicalBioAssayOnChange()"
752            />
753          </td>
754        </tr>
755        <tr id="parentBioAssaySection" style="display: none;">
756          <td class="subprompt">-bioassay</td>
757          <td>
758            <base:select 
759              id="parent_id"
760              clazz="selectionlist unchangeable"
761              required="true"
762              current="<%=currentParentBioAssay%>"
763              recent="<%=recentParentBioAssays%>"
764              newitem="true"
765              onselect="selectParentBioAssayOnClick()"
766              onchange="parentBioAssayOnChange()"
767            />
768          </td>
769        </tr>
770        <%
771      }
772      %>
773      <tr>
774        <td class="prompt">Extract</td>
775        <td>
776          <select name="extract_id" class="selectionlist"></select>
777        </td>
778      </tr>
779      <tr>
780        <td class="prompt">Protocol</td>
781        <td>
782          <base:select 
783            id="protocol_id"
784            clazz="selectionlist"
785            required="false"
786            current="<%=currentProtocol%>"
787            denied="<%=!readCurrentProtocol%>"
788            recent="<%=recentProtocols%>"
789            defaultitems="<%=defaultProtocols%>"
790            newitem="<%=bioAssay == null%>"
791            onselect="selectProtocolOnClick()"
792            onchange="protocolOnChange()"
793          />
794        </td>
795      </tr>
796      <tr>
797        <td class="prompt">Hardware</td>
798        <td>
799          <base:select 
800            id="hardware_id"
801            clazz="selectionlist"
802            required="false"
803            current="<%=currentHardware%>"
804            denied="<%=!readCurrentHardware%>"
805            recent="<%=recentHardware%>"
806            defaultitems="<%=defaultHardware%>"
807            newitem="<%=bioAssay == null%>"
808            onselect="selectHardwareOnClick()"
809          />
810        </td>
811      </tr>
812      <tr>
813        <td class="prompt">Software</td>
814        <td>
815          <base:select 
816            id="software_id"
817            clazz="selectionlist"
818            required="false"
819            current="<%=currentSoftware%>"
820            denied="<%=!readCurrentSoftware%>"
821            recent="<%=recentSoftware%>"
822            defaultitems="<%=defaultSoftware%>"
823            newitem="<%=bioAssay == null%>"
824            onselect="selectSoftwareOnClick()"
825          />
826        </td>
827      </tr>
828
829      <tr valign=top>
830        <td class="prompt">Description</td>
831        <td nowrap>
832          <textarea <%=clazz%> rows="4" cols="40" name="description" wrap="virtual"
833            ><%=HTML.encodeTags(bioAssay == null ? cc.getPropertyValue("description") : bioAssay.getDescription())%></textarea>
834          <a href="javascript:Main.zoom('Description', 'bioAssay', 'description')"
835            title="Edit in larger window"><base:icon image="zoom.gif" /></a>
836        </td>
837      </tr>
838      </table>
839      <div align=right>&nbsp;<i><base:icon image="required.gif" /> = required information</i>
840      <%if (bioAssay == null) {%><br>
841        <i><base:icon image="unchangeable.gif" /> = can't be changed later</i>
842      <%}%>
843      </div>
844    </t:tab>
845
846    <t:tab id="datafiles" title="Data files" helpid="datafiles.edit">
847      <iframe name="datafiles" id="idDatafiles" src="../../../common/datafiles/wait.jsp" 
848        width="100%"  height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0
849        marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe>
850    </t:tab>
851
852    <t:tab id="annotations" title="Annotations" 
853      helpid="annotations.edit" tooltip="Enter values for annotations">
854      <iframe name="annotations" id="idAnnotations" src="../../../common/annotations/wait.jsp" 
855        width="100%"  height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0
856        marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe>
857    </t:tab>
858   
859    <t:tab id="inheritedAnnotations" title="Inherited annotations" helpid="annotations.edit.inherited">
860      <iframe name="inheritedAnnotations" id="idInheritedAnnotations" src="../../../common/annotations/wait.jsp" 
861        width="100%"  height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0
862        marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe>
863    </t:tab>
864    </t:tabcontrol>
865
866    <table align="center">
867    <tr>
868      <td width="50%"><base:button onclick="saveSettings()" title="Save" /></td>
869      <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td>
870    </tr>
871    </table>
872    </form>
873  </base:body>
874  </base:page>
875  <%
876}
877finally
878{
879  if (dc != null) dc.close();
880}
881%>
Note: See TracBrowser for help on using the repository browser.