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

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

References #1729 and #1730. Fixed the 'subtypes.js' script and hopefully all places that uses it.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 27.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.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        DataFiles.writeFileActionsToForm(frm);
271        if (frm.addedPhysicalBioAssays)
272        {
273          frm.addedPhysicalBioAssays.value = Link.getActionIds(1, 'P').join(',');
274          frm.removedPhysicalBioAssays.value = Link.getActionIds(-1, 'P').join(',');
275        }
276        if (frm.addedParents)
277        {
278          frm.addedParents.value = Link.getActionIds(1, 'D').join(',');
279          frm.removedParents.value = Link.getActionIds(-1, 'D').join(',');
280        }
281        frm.submit();
282      }
283    }
284   
285    function loadAnnotationsFrame()
286    {
287      Annotations.autoLoadEditFrame(getProtocolId(), ItemSubtype.getSubtypeId('subtype_id'));
288    }
289   
290    function loadInheritedAnnotationsFrame()
291    {
292      Annotations.autoLoadInheritFrame(getParents());
293    }
294
295    function loadDataFilesFrame()
296    {
297      var subtypeId = ItemSubtype.getSubtypeId('subtype_id');
298      DataFiles.autoLoadEditFrame(0, 0, subtypeId);
299    }
300     
301    function getProtocolId()
302    {
303      var frm = document.forms['bioAssay'];
304      var protocolId = 0;
305      if (frm.protocol_id.length > 0 && !frm.protocol_id.disabled)
306      {
307        protocolId = Math.abs(parseInt(frm.protocol_id[frm.protocol_id.selectedIndex].value));       
308      }
309      return protocolId;
310    }
311   
312    function getParents()
313    {
314      var frm = document.forms['bioAssay'];
315     
316      var parents = new Array();
317      if (frm.physicalBioAssays && (!frm.isRoot || frm.isRoot[0].checked))
318      {
319        var ids = Link.getListIds(frm.physicalBioAssays, 'P');
320        if (ids.length > 0)
321        {
322          parents[parents.length] = 'PHYSICALBIOASSAY:'+ids.join(':');
323        }
324      }
325      else if (frm.parents && (!frm.isRoot || frm.isRoot[1].checked))
326      {
327        var ids = Link.getListIds(frm.parents, 'D');
328        if (ids.length > 0)
329        {
330          parents[parents.length] = 'DERIVEDBIOASSAY:'+ids.join(':');
331        }
332      }
333      var extractId = Math.abs(parseInt(frm.extract_id[frm.extract_id.selectedIndex].value));
334      if (extractId > 0) parents[parents.length] = 'EXTRACT:'+extractId;
335      return parents;
336    }
337   
338    function subtypeOnChange()
339    {
340      var frm = document.forms['bioAssay'];
341      var subtypeId = ItemSubtype.getSubtypeId('subtype_id');
342      var recentInfo = ItemSubtype.getRelatedProjectDefaultAndRecentItems('DERIVEDBIOASSAY', subtypeId, ['PROTOCOL', 'HARDWARE', 'SOFTWARE']);
343      ItemSubtype.updateSelectionList(frm.protocol_id, recentInfo.PROTOCOL['recent'], recentInfo.PROTOCOL['default']);
344      ItemSubtype.updateSelectionList(frm.hardware_id, recentInfo.HARDWARE['recent'], recentInfo.HARDWARE['default']);
345      ItemSubtype.updateSelectionList(frm.software_id, recentInfo.SOFTWARE['recent'], recentInfo.SOFTWARE['default']);
346    }
347
348   
349    function selectProtocolOnClick()
350    {
351      var frm = document.forms['bioAssay'];
352      var url = '../../admin/protocols/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone';
353      url += '&callback=setProtocolCallback&resetTemporary=1';
354      url += ItemSubtype.createRelatedFilter('subtype_id', 'PROTOCOL');
355      if (frm.protocol_id.length > 1)
356      {
357        var id = Math.abs(parseInt(frm.protocol_id[1].value));       
358        url += '&item_id='+id;
359      }
360      Main.openPopup(url, 'SelectProtocol', 1050, 700);
361    }
362    function setProtocolCallback(id, name)
363    {
364      var frm = document.forms['bioAssay'];
365      var list = frm.protocol_id;
366      if (list.length < 2 || list[1].value == '0') // >
367      {
368        Forms.addListOption(list, 1, new Option());
369      }
370      list[1].value = id;
371      list[1].text = name;
372      list.selectedIndex = 1;
373    }
374   
375    function selectHardwareOnClick()
376    {
377      var frm = document.forms['bioAssay'];
378      var url = '../../admin/hardware/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone';
379      url += '&callback=setHardwareCallback&resetTemporary=1';
380      url += ItemSubtype.createRelatedFilter('subtype_id', 'HARDWARE');
381      if (frm.hardware_id.length > 1)
382      {
383        var id = Math.abs(parseInt(frm.hardware_id[1].value));       
384        url += '&item_id='+id;
385      }
386      Main.openPopup(url, 'SelectHardware', 1050, 700);
387    }
388    function setHardwareCallback(id, name)
389    {
390      var frm = document.forms['bioAssay'];
391      var list = frm.hardware_id;
392      if (list.length < 2 || list[1].value == '0') // >
393      {
394        Forms.addListOption(list, 1, new Option());
395      }
396      list[1].value = id;
397      list[1].text = name;
398      list.selectedIndex = 1;
399    }
400    function selectSoftwareOnClick()
401    {
402      var frm = document.forms['bioAssay'];
403      var url = '../../admin/software/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone';
404      url += '&callback=setSoftwareCallback&resetTemporary=1';
405      url += ItemSubtype.createRelatedFilter('subtype_id', 'SOFTWARE');
406      if (frm.software_id.length > 1)
407      {
408        var id = Math.abs(parseInt(frm.software_id[1].value));       
409        url += '&item_id='+id;
410      }
411      Main.openPopup(url, 'SelectSoftware', 1050, 700);
412    }
413    function setSoftwareCallback(id, name)
414    {
415      var frm = document.forms['bioAssay'];
416      var list = frm.software_id;
417      if (list.length < 2 || list[1].value == '0') // >
418      {
419        Forms.addListOption(list, 1, new Option());
420      }
421      list[1].value = id;
422      list[1].text = name;
423      list.selectedIndex = 1;
424    }
425   
426    function selectExtractOnClick()
427    {
428      var frm = document.forms['bioAssay'];
429     
430      var relatedExtractIds = null;
431      if (frm.physicalBioAssays && (!frm.isRoot || frm.isRoot[0].checked))
432      {
433        var ids = Link.getListIds(frm.physicalBioAssays, 'P');
434        if (ids.length > 0)
435        {
436          var request = Ajax.getXmlHttpRequest();
437          var url = '../physicalbioassays/ajax.jsp?ID=<%=ID%>&cmd=GetAllExtractIds';
438          url += '&bioassay_ids=' + ids.join(',');
439          request.open("GET", url, false);
440          request.send(null);
441                   
442          var response = JSON.parse(request.responseText);
443          if (response.status != 'ok')
444          {
445            alert(response.message);
446            return null;
447          }
448          relatedExtractIds = response.allExtractIds;
449        }
450      }
451      else if (frm.parents && (!frm.isRoot || frm.isRoot[1].checked))
452      {
453        var ids = Link.getListIds(frm.parents, 'D');
454        if (ids.length > 0)
455        {
456          var request = Ajax.getXmlHttpRequest();
457          var url = 'ajax.jsp?ID=<%=ID%>&cmd=GetAllExtractIds';
458          url += '&bioassay_ids=' + ids.join(',');
459          request.open("GET", url, false);
460          request.send(null);
461                   
462          var response = JSON.parse(request.responseText);
463          if (response.status != 'ok')
464          {
465            alert(response.message);
466            return null;
467          }
468          relatedExtractIds = response.allExtractIds;
469        }
470      }
471
472      var url = '../../biomaterials/extracts/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone';
473      url += '&callback=setExtractCallback&resetTemporary=1';
474      if (relatedExtractIds)
475      {
476        url += '&tmpfilter:INT:id='+relatedExtractIds.join('|');
477      }
478      url += ItemSubtype.createRelatedFilter('subtype_id', 'EXTRACT');
479      if (frm.extract_id.length > 1)
480      {
481        var id = Math.abs(parseInt(frm.extract_id[1].value));       
482        url += '&item_id='+id;
483      }
484      Main.openPopup(url, 'SelectExtract', 1050, 700);
485    }
486
487    function setExtractCallback(id, name)
488    {
489      var frm = document.forms['bioAssay'];
490      var list = frm.extract_id;
491      if (list.length < 2 || list[1].value == '0') // >
492      {
493        Forms.addListOption(list, 1, new Option());
494      }
495      list[1].value = id;
496      list[1].text = name;
497      list.selectedIndex = 1;
498    }
499   
500    function addPhysicalBioAssayOnClick()
501    {
502      var frm = document.forms['bioAssay'];
503      var url = '../physicalbioassays/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectmultiple';
504      url += '&callback=addPhysicalBioAssayCallback&resetTemporary=1';
505      url += ItemSubtype.createRelatedFilter('subtype_id', 'PHYSICALBIOASSAY');
506      Main.openPopup(url, 'AddPhysicalBioAssay', 1050, 700);
507    }
508   
509    function addPhysicalBioAssayCallback(pbaId, name)
510    {
511      var frm = document.forms['bioAssay'];
512      var item = Link.getItem('P', pbaId);
513      if (!item) item = new Item('P', pbaId, name);
514      Link.addItem(frm.physicalBioAssays, item);
515    }
516
517    function removePhysicalBioAssayOnClick()
518    {
519      Link.removeSelected(document.forms['bioAssay'].physicalBioAssays);
520    }
521
522   
523    function addParentOnClick()
524    {
525      var frm = document.forms['bioAssay'];
526      var url = 'index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectmultiple';
527      url += '&callback=addParentCallback&resetTemporary=1';
528      url += ItemSubtype.createRelatedFilter('subtype_id', 'DERIVEDBIOASSAY');
529      Main.openPopup(url, 'AddParentBioAssay', 1050, 700);
530    }
531   
532    function addParentCallback(dbaId, name)
533    {
534      var frm = document.forms['bioAssay'];
535      var item = Link.getItem('D', dbaId);
536      if (!item) item = new Item('D', dbaId, name);
537      Link.addItem(frm.parents, item);
538    }
539
540    function removeParentOnClick()
541    {
542      Link.removeSelected(document.forms['bioAssay'].parents);
543    }
544
545   
546    function init()
547    {
548      var frm = document.forms['bioAssay'];
549      <%
550      if (bioAssay == null)
551      {
552        %>
553        frm.name.focus();
554        frm.name.select();
555        <%
556      }
557      %>
558      initParents();
559      initPhysicalBioAssays();
560      if (frm.isRoot)
561      {
562        isRootOnChange();
563      }
564    }
565   
566    function initPhysicalBioAssays()
567    {
568      var physicalBioAssays = document.forms['bioAssay'].physicalBioAssays;
569      <%
570      if (physicalQuery != null)
571      {
572        physicalQuery.include(Include.ALL);
573        physicalQuery.order(Orders.asc(Hql.property("name")));
574        ItemResultList<PhysicalBioAssay> physicalBioAssays = physicalQuery.list(dc);
575        for (PhysicalBioAssay pba : physicalBioAssays)
576        {
577          if (bioAssay != null)
578          {
579            %>
580            Link.addNewItem(physicalBioAssays, new Item('P', <%=pba.getId()%>, '<%=HTML.javaScriptEncode(pba.getName())%>'));
581            <%
582          }
583          else
584          {
585            %>
586            Link.addItem(physicalBioAssays, new Item('P', <%=pba.getId()%>, '<%=HTML.javaScriptEncode(pba.getName())%>'));
587            <%
588          }
589        }
590      }
591      %>
592    }
593   
594    function initParents()
595    {
596      var parents = document.forms['bioAssay'].parents;
597      <%
598      if (parentQuery != null)
599      {
600        parentQuery.include(Include.ALL);
601        parentQuery.order(Orders.asc(Hql.property("name")));
602        ItemResultList<DerivedBioAssay> parents = parentQuery.list(dc);
603        for (DerivedBioAssay dba : parents)
604        {
605          if (bioAssay != null)
606          {
607            %>
608            Link.addNewItem(parents, new Item('D', <%=dba.getId()%>, '<%=HTML.javaScriptEncode(dba.getName())%>'));
609            <%
610          }
611          else
612          {
613            %>
614            Link.addItem(parents, new Item('D', <%=dba.getId()%>, '<%=HTML.javaScriptEncode(dba.getName())%>'));
615            <%
616          }
617          if (parents.size() == 1 && currentExtract == null)
618          {
619            try
620            {
621              currentExtract = dba.getExtract();
622            }
623            catch (PermissionDeniedException ex)
624            {}
625          }
626        }
627      }
628      %>
629    }
630   
631    function isRootOnChange()
632    {
633      var frm = document.forms['bioAssay'];
634      var isRoot = frm.isRoot[0].checked;
635      Main.showHide('physicalBioAssaySection', isRoot);
636      Main.showHide('parentBioAssaySection', !isRoot);
637    }
638
639    </script>
640  </base:head>
641  <base:body onload="init()">
642    <h1><%=title%> <base:help tabcontrol="settings" /></h1>
643    <form action="index.jsp?ID=<%=ID%>" method="post" name="bioAssay">
644    <input type="hidden" name="cmd" value="UpdateItem">
645   
646    <t:tabcontrol id="settings"
647      subclass="content dialogtabcontrol"
648      position="bottom" active="<%=tabId%>" remember="<%=tabId == null && bioAssay != null%>" 
649      extensions="<%=invoker%>">
650    <t:tab id="info" title="Bioassay" validate="validateBioAssay()" helpid="derivedbioassay.edit">
651      <table class="fullform input100">
652      <tr>
653        <th>Name</th>
654        <td><input class="text required" type="text" name="name" 
655          value="<%=HTML.encodeTags(bioAssay == null ? Values.getString(cc.getPropertyValue("name"), "New derived bioassay") : bioAssay.getName())%>" 
656          maxlength="<%=DerivedBioAssay.MAX_NAME_LENGTH%>"></td>
657        <td></td>
658      </tr>
659
660      <tr>
661        <th>Type</th>
662        <td>
663          <select name="subtype_id" id="subtype_id"
664            <%=!readCurrentSubtype ? "disabled readonly class=\"disabled selectionlist\"" : "class=\"selectionlist\""%>
665            onchange="subtypeOnChange()"
666            >
667          <%
668          if (!readCurrentSubtype)
669          {
670            %>
671            <option value="-1">- denied -
672            <%
673          }
674          else
675          {
676            %>
677            <option value="0">-none-
678            <%
679            int currentSubtypeId = currentSubtype == null ? 0 : currentSubtype.getId();
680            for (ItemSubtype subtype : subtypesQuery.list(dc))
681            {
682              int id = subtype.getId();
683              if (id != currentSubtypeId && subtype.isRemoved()) continue;
684              %>
685              <option value="<%=id == currentSubtypeId && bioAssay != null ? -id : id%>" 
686                <%=id == currentSubtypeId ? "selected" : ""%>
687                title="<%=HTML.encodeTags(subtype.getDescription()) %>"
688                ><%=HTML.encodeTags(subtype.getName())%>
689              <%
690            }
691          }
692          %>
693          </select>
694        </td>
695        <td></td>
696      </tr>
697      <%
698      if (bioAssay == null)
699      {
700        %>
701        <tr>
702          <th>Parent type</th>
703          <td>
704            <input id="isRoot" type="radio" name="isRoot" value="1" 
705              <%=parentType == Item.PHYSICALBIOASSAY ? "checked" : "" %>
706              onchange="isRootOnChange()"><label for="isRoot">Physical bioassay</label>
707            <input id="isChild" type="radio" name="isRoot" value="0"
708              <%=parentType != Item.PHYSICALBIOASSAY ? "checked" : "" %>
709              onchange="isRootOnChange()"><label for="isChild">Derived bioassay</label><br>
710          </td>
711          <td></td>
712        </tr>
713        <%
714      }
715      %>
716      <%
717      if (bioAssay == null || bioAssay.isRoot())
718      {
719        %>
720        <tr id="physicalBioAssaySection">
721          <th class="subprompt">- physical bioassays</th>
722          <td>
723            <div class="selectionlist">
724            <table>
725            <tr>
726            <td>
727              <select name="physicalBioAssays" size="4" multiple>
728              </select>
729            </td>
730            <td>
731            <td style="vertical-align: top;">
732              <base:buttongroup vertical="true">
733                <base:button 
734                  subclass="leftaligned"
735                  style="width: 12em;"
736                  onclick="addPhysicalBioAssayOnClick()" 
737                  title="Add&nbsp;bioassays&hellip;" 
738                  tooltip="Add physical bioassays"
739                />
740                <base:button 
741                  subclass="leftaligned"
742                  style="width: 12em;"
743                  onclick="removePhysicalBioAssayOnClick()" 
744                  title="Remove" 
745                  tooltip="Remove the selected physical bioassays"
746                />
747              </base:buttongroup>
748              <input type="hidden" name="addedPhysicalBioAssays" value="">
749              <input type="hidden" name="removedPhysicalBioAssays" value="">
750            </td>
751            </tr>
752            </table>
753            </div>
754          </td>
755          <td></td>
756        </tr>
757        <%
758      }
759      if (bioAssay == null || !bioAssay.isRoot())
760      {
761        %>
762        <tr id="parentBioAssaySection">
763          <th class="subprompt">- bioassays</th>
764          <td>
765            <div class="selectionlist">
766            <table>
767            <tr>
768            <td>
769              <select name="parents" size="4" multiple>
770              </select>
771            </td>
772            <td>
773            <td style="vertical-align: top;">
774              <base:buttongroup vertical="true">
775                <base:button 
776                  subclass="leftaligned"
777                  style="width: 12em;"
778                  onclick="addParentOnClick()" 
779                  title="Add&nbsp;bioassays&hellip;" 
780                  tooltip="Add parent derived bioassays"
781                />
782                <base:button 
783                  subclass="leftaligned"
784                  style="width: 12em;"
785                  onclick="removeParentOnClick()" 
786                  title="Remove" 
787                  tooltip="Remove the selected derived bioassays"
788                />
789              </base:buttongroup>
790              <input type="hidden" name="addedParents" value="">
791              <input type="hidden" name="removedParents" value="">
792            </td>
793            </tr>
794            </table>
795            </div>
796           
797          </td>
798          <td></td>
799        </tr>
800        <%
801      }
802      %>
803      <tr>
804        <th>Extract</th>
805        <td>
806          <base:select 
807            id="extract_id"
808            clazz="selectionlist"
809            required="false"
810            current="<%=currentExtract%>"
811            denied="<%=!readCurrentExtract%>"
812            newitem="<%=bioAssay == null%>"
813            onselect="selectExtractOnClick()"
814          />
815        </td>
816        <td></td>
817      </tr>
818      <tr>
819        <th>Protocol</th>
820        <td>
821          <base:select 
822            id="protocol_id"
823            clazz="selectionlist"
824            required="false"
825            current="<%=currentProtocol%>"
826            denied="<%=!readCurrentProtocol%>"
827            recent="<%=recentProtocols%>"
828            defaultitems="<%=defaultProtocols%>"
829            newitem="<%=bioAssay == null%>"
830            onselect="selectProtocolOnClick()"
831          />
832        </td>
833        <td></td>
834      </tr>
835      <tr>
836        <th>Hardware</th>
837        <td>
838          <base:select 
839            id="hardware_id"
840            clazz="selectionlist"
841            required="false"
842            current="<%=currentHardware%>"
843            denied="<%=!readCurrentHardware%>"
844            recent="<%=recentHardware%>"
845            defaultitems="<%=defaultHardware%>"
846            newitem="<%=bioAssay == null%>"
847            onselect="selectHardwareOnClick()"
848          />
849        </td>
850        <td></td>
851      </tr>
852      <tr>
853        <th>Software</th>
854        <td>
855          <base:select 
856            id="software_id"
857            clazz="selectionlist"
858            required="false"
859            current="<%=currentSoftware%>"
860            denied="<%=!readCurrentSoftware%>"
861            recent="<%=recentSoftware%>"
862            defaultitems="<%=defaultSoftware%>"
863            newitem="<%=bioAssay == null%>"
864            onselect="selectSoftwareOnClick()"
865          />
866        </td>
867        <td></td>
868      </tr>
869
870      <tr class="dynamic">
871        <th>Description</th>
872        <td>
873          <textarea class="text" rows="6" name="description" id="description"
874            ><%=HTML.encodeTags(bioAssay == null ? cc.getPropertyValue("description") : bioAssay.getDescription())%></textarea>
875        </td>
876        <td style="width: 20px;">
877          <base:zoom textarea="description" title="Description" />
878        </td>
879      </tr>
880      </table>
881    </t:tab>
882
883    <t:tab id="datafiles" title="Data files" helpid="datafiles.edit" activate="loadDataFilesFrame()">
884      <jsp:include page="../../common/datafiles/select_frameset.jsp">
885        <jsp:param name="item_type" value="<%=itemType.name()%>" />
886        <jsp:param name="item_id" value="<%=itemId%>" />
887        <jsp:param name="ID" value="<%=ID%>" />
888      </jsp:include>   
889    </t:tab>
890
891    <t:tab id="annotations" title="Annotations &amp; parameters" helpid="annotations.edit" activate="loadAnnotationsFrame()">
892      <jsp:include page="../../common/annotations/annotate_frameset.jsp">
893        <jsp:param name="item_type" value="<%=itemType.name()%>" />
894        <jsp:param name="item_id" value="<%=itemId%>" />
895        <jsp:param name="ID" value="<%=ID%>" />
896      </jsp:include>
897    </t:tab>
898   
899    <t:tab id="inheritedAnnotations" title="Inherited annotations" 
900      helpid="annotations.edit.inherited" activate="loadInheritedAnnotationsFrame()">
901      <jsp:include page="../../common/annotations/inherit_frameset.jsp">
902        <jsp:param name="item_type" value="<%=itemType.name()%>" />
903        <jsp:param name="item_id" value="<%=itemId%>" />
904        <jsp:param name="ID" value="<%=ID%>" />
905      </jsp:include>
906    </t:tab>
907    </t:tabcontrol>
908    </form>
909
910    <div class="legend">
911      <base:icon image="required.png" />= required information
912      <%if (bioAssay == null) {%><br>
913        <base:icon image="unchangeable.png" />= can't be changed later
914      <%}%>
915    </div>
916
917    <base:buttongroup subclass="dialogbuttons">
918      <base:button onclick="saveSettings()" title="Save" />
919      <base:button onclick="window.close()" title="Cancel" />
920    </base:buttongroup>
921
922  </base:body>
923  </base:page>
924  <%
925}
926finally
927{
928  if (dc != null) dc.close();
929}
930%>
Note: See TracBrowser for help on using the repository browser.