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

Last change on this file since 6254 was 6254, checked in by Nicklas Nordborg, 10 years ago

References #1729 and #1730. Use lazy loading of 'Annotations'/'Inherited annotations' for all other items.

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