source: trunk/www/views/rawbioassays/edit_rawbioassay.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: 27.4 KB
Line 
1<%-- $Id: edit_rawbioassay.jsp 5687 2011-08-09 11:39:40Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2005 Nicklas Nordborg
4  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
5  Copyright (C) 2007 Nicklas Nordborg
6
7  This file is part of BASE - BioArray Software Environment.
8  Available at http://base.thep.lu.se/
9
10  BASE is free software; you can redistribute it and/or
11  modify it under the terms of the GNU General Public License
12  as published by the Free Software Foundation; either version 3
13  of the License, or (at your option) any later version.
14
15  BASE is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  GNU General Public License for more details.
19
20  You should have received a copy of the GNU General Public License
21  along with BASE. If not, see <http://www.gnu.org/licenses/>.
22  ------------------------------------------------------------------
23
24
25  @author Nicklas
26  @version 2.0
27--%>
28<%@ page pageEncoding="UTF-8" session="false"
29  import="net.sf.basedb.core.SessionControl"
30  import="net.sf.basedb.core.DbControl"
31  import="net.sf.basedb.core.Item"
32  import="net.sf.basedb.core.ItemContext"
33  import="net.sf.basedb.core.SystemItems"
34  import="net.sf.basedb.core.Permission"
35  import="net.sf.basedb.core.RawBioAssay"
36  import="net.sf.basedb.core.Platform"
37  import="net.sf.basedb.core.PlatformVariant"
38  import="net.sf.basedb.core.Protocol"
39  import="net.sf.basedb.core.Project"
40  import="net.sf.basedb.core.Software"
41  import="net.sf.basedb.core.ArrayDesign"
42  import="net.sf.basedb.core.Extract"
43  import="net.sf.basedb.core.DerivedBioAssay"
44  import="net.sf.basedb.core.ItemSubtype"
45  import="net.sf.basedb.core.File"
46  import="net.sf.basedb.core.RawDataType"
47  import="net.sf.basedb.core.RawDataTypes"
48  import="net.sf.basedb.core.ItemQuery"
49  import="net.sf.basedb.core.ItemResultList"
50  import="net.sf.basedb.core.PermissionDeniedException"
51  import="net.sf.basedb.core.BaseException"
52  import="net.sf.basedb.core.query.Orders"
53  import="net.sf.basedb.core.query.Hql"
54  import="net.sf.basedb.clients.web.Base"
55  import="net.sf.basedb.clients.web.util.HTML"
56  import="net.sf.basedb.util.Values"
57  import="net.sf.basedb.core.Include"
58  import="net.sf.basedb.core.plugin.GuiContext"
59  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
60  import="net.sf.basedb.clients.web.extensions.JspContext"
61  import="net.sf.basedb.clients.web.extensions.edit.EditUtil"
62  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
63  import="java.util.List"
64  import="java.util.Set"
65  import="java.util.HashSet"
66%>
67<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
68<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
69<%
70final Item itemType = Item.RAWBIOASSAY;
71final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
72final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
73final String tabId = Values.getString(request.getParameter("tab"), null);
74final int itemId = cc.getId();
75final String ID = sc.getId();
76final float scale = Base.getScale(sc);
77final DbControl dc = sc.newDbControl();
78try
79{
80  String title = null;
81  RawBioAssay rawBioAssay = null;
82  String name = null;
83  boolean hasDbSpots = false;
84
85  boolean deniedPlatform = false;
86  Platform currentPlatform = null;
87  List<Platform> defaultPlatforms = null;
88  PlatformVariant currentVariant = null;
89  List<PlatformVariant> defaultVariants = null;
90 
91  boolean readCurrentBioAssay = true;
92  DerivedBioAssay currentBioAssay = null;
93  boolean readCurrentExtract = true;
94  Extract currentExtract = null;
95  boolean readCurrentProtocol = true;
96  Protocol currentProtocol = null;
97  List<Protocol> defaultProtocols = null;
98  boolean readCurrentSoftware = true;
99  Software currentSoftware = null;
100  List<Software> defaultSoftware = null;
101  boolean readCurrentArrayDesign = true;
102  ArrayDesign currentArrayDesign = null;
103  List<ArrayDesign> defaultArrayDesigns = null;
104  RawDataType currentRawDataType = null;
105  RawDataType defaultRawDataType = null;
106
107  // Load recently used items
108  List<Protocol> recentProtocols = (List<Protocol>)cc.getRecent(dc, Item.PROTOCOL);
109  List<Software> recentSoftware = (List<Software>)cc.getRecent(dc, Item.SOFTWARE);
110  List<ArrayDesign> recentArrayDesigns = (List<ArrayDesign>)cc.getRecent(dc, Item.ARRAYDESIGN);
111  List<File> recentFiles = (List<File>)cc.getRecent(dc, Item.FILE);
112  List<DerivedBioAssay> recentBioAssays = (List<DerivedBioAssay>)cc.getRecent(dc, Item.DERIVEDBIOASSAY);
113  List<Extract> recentExtracts = (List<Extract>)cc.getRecent(dc, Item.EXTRACT);
114 
115  int activeProjectId = sc.getActiveProjectId();
116  if (activeProjectId > 0)
117  {
118    Project activeProject = Project.getById(dc, activeProjectId);
119    try
120    {
121      defaultProtocols = (List<Protocol>)activeProject.findDefaultItems(dc, 
122          ItemSubtype.getById(dc, SystemItems.getId(Protocol.FEATURE_EXTRACTION)), false);
123    }
124    catch (PermissionDeniedException pdex)
125    {}
126    try
127    {
128      defaultSoftware = (List<Software>)activeProject.findDefaultItems(dc, 
129          ItemSubtype.getById(dc, SystemItems.getId(Software.FEATURE_EXTRACTION)), false);
130    }
131    catch (PermissionDeniedException pdex)
132    {}
133    try
134    {
135      defaultArrayDesigns = (List<ArrayDesign>)activeProject.findDefaultItems(dc, Item.ARRAYDESIGN, true);
136    }
137    catch (PermissionDeniedException pdex)
138    {}
139    try
140    {
141      defaultPlatforms = (List<Platform>)activeProject.findDefaultItems(dc, Item.PLATFORM, true);
142    }
143    catch (PermissionDeniedException pdex)
144    {}
145    try
146    {
147      defaultVariants = (List<PlatformVariant>)activeProject.findDefaultItems(dc, Item.PLATFORMVARIANT, true);
148    }
149    catch (PermissionDeniedException pdex)
150    {}
151    defaultRawDataType = activeProject.getDefaultRawDataType();
152  }
153  if (itemId == 0)
154  {
155    title = "Create raw bioassay";
156    cc.removeObject("item");
157   
158    int currentPlatformId = Values.getInt(cc.getPropertyValue("platform"), 0);
159    if (currentPlatformId == 0)
160    {
161      currentPlatformId = Values.getInt(cc.getRecent(Item.PLATFORM.name(), 0), 0);
162    }
163    int currentVariantId = Values.getInt(cc.getRecent(Item.PLATFORMVARIANT.name(), 0), 0);
164   
165    try
166    {
167      if (currentVariantId != 0) currentVariant = PlatformVariant.getById(dc, currentVariantId);
168      if (currentPlatformId != 0) currentPlatform = Platform.getById(dc, currentPlatformId);
169    }
170    catch (Throwable t)
171    {}
172    if (currentPlatform == null && defaultPlatforms.size() > 0) 
173    {
174      currentPlatform = defaultPlatforms.get(0);
175    }
176    if (currentVariant == null && defaultVariants.size() > 0)
177    {
178      currentVariant = defaultVariants.get(0);
179    }
180   
181    currentRawDataType = RawDataTypes.getRawDataType(cc.getPropertyValue("rawDataType"));
182    if (currentRawDataType == null)
183    {
184      currentRawDataType = RawDataTypes.getRawDataType(cc.getRecent("RawDataType", 0));
185    }
186    if (currentRawDataType == null) currentRawDataType = defaultRawDataType;
187
188   
189    int bioAssayId = Values.getInt(request.getParameter("bioassay_id"));
190    if (bioAssayId != 0)
191    {
192      currentBioAssay = DerivedBioAssay.getById(dc, bioAssayId);
193    }
194    else if (cc.getPropertyFilter("derivedBioAssay.name") != null)
195    {
196      currentBioAssay = Base.getFirstMatching(dc, DerivedBioAssay.getQuery(), "name", cc.getPropertyFilter("derivedBioAssay.name"));
197    }
198
199    if (currentBioAssay != null)
200    {
201      name = currentBioAssay.getName() + ".r" + (currentBioAssay.countRawBioAssays() + 1);
202    }
203    else
204    {
205      name = Values.getString(cc.getPropertyValue("name"), "New raw bioassay");
206    }
207
208    if (cc.getPropertyFilter("protocol.name") != null)
209    {
210      currentProtocol = Base.getFirstMatching(dc, Protocol.getQuery(), "name", cc.getPropertyFilter("protocol.name"));
211    }
212   
213    if (cc.getPropertyFilter("software.name") != null)
214    {
215      currentSoftware = Base.getFirstMatching(dc, Software.getQuery(), "name", cc.getPropertyFilter("software.name"));
216    }
217
218    if (currentBioAssay != null)
219    {
220      try
221      {
222        currentArrayDesign = currentBioAssay.getArrayDesign();
223      }
224      catch (PermissionDeniedException ex)
225      {}
226      try
227      {
228        currentExtract = currentBioAssay.getExtract();
229      }
230      catch (PermissionDeniedException ex)
231      {}
232    }
233    if (currentArrayDesign == null && cc.getPropertyFilter("arrayDesign.name") != null)
234    {
235      currentArrayDesign = Base.getFirstMatching(dc, ArrayDesign.getQuery(), "name", cc.getPropertyFilter("arrayDesign.name"));
236    }
237  }
238  else
239  {
240    rawBioAssay = RawBioAssay.getById(dc, itemId);
241    rawBioAssay.checkPermission(Permission.WRITE);
242    hasDbSpots = rawBioAssay.getNumDbSpots() > 0;
243    cc.setObject("item", rawBioAssay);
244    name = rawBioAssay.getName();
245    try
246    {
247      currentRawDataType = rawBioAssay.getRawDataType();
248    }
249    catch (Throwable t)
250    {}
251    title = "Edit raw bioassay -- " + HTML.encodeTags(rawBioAssay.getName());
252   
253    try
254    {
255      currentPlatform = rawBioAssay.getPlatform();
256      currentVariant = rawBioAssay.getVariant();
257    }
258    catch (PermissionDeniedException ex)
259    {
260      deniedPlatform = true;
261    }
262   
263    try
264    {
265      currentBioAssay = rawBioAssay.getParentBioAssay();
266    }
267    catch (PermissionDeniedException ex)
268    {
269      readCurrentBioAssay = false;
270    }
271    try
272    {
273      currentExtract = rawBioAssay.getParentExtract();
274    }
275    catch (PermissionDeniedException ex)
276    {
277      readCurrentExtract = false;
278    }
279    try
280    {
281      currentProtocol = rawBioAssay.getProtocol();
282    }
283    catch (PermissionDeniedException ex)
284    {
285      readCurrentProtocol = false;
286    }
287    try
288    {
289      currentSoftware = rawBioAssay.getSoftware();
290    }
291    catch (PermissionDeniedException ex)
292    {
293      readCurrentSoftware = false;
294    }
295    try
296    {
297      currentArrayDesign = rawBioAssay.getArrayDesign();
298    }
299    catch (PermissionDeniedException ex)
300    {
301      readCurrentArrayDesign = false;
302    }
303  }
304 
305  ItemQuery<Platform> platformQuery = Platform.getQuery();
306  platformQuery.include(Include.REMOVED, Include.NOT_REMOVED);
307  platformQuery.order(Orders.asc(Hql.property("name")));
308  platformQuery.setCacheResult(true);
309  ItemResultList<Platform> platforms = platformQuery.list(dc);
310
311  ItemQuery<PlatformVariant> variantQuery = PlatformVariant.getQuery();
312  variantQuery.include(Include.REMOVED, Include.NOT_REMOVED);
313  variantQuery.order(Orders.asc(Hql.property("name")));
314  variantQuery.setCacheResult(true);
315  ItemResultList<PlatformVariant> variants = variantQuery.list(dc);
316 
317  final String clazz = "class=\"text\"";
318  final String requiredClazz = "class=\"text required\"";
319  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), rawBioAssay);
320  ExtensionsInvoker invoker = EditUtil.useEditExtensions(jspContext);
321  %>
322  <base:page type="popup" title="<%=title%>">
323  <base:head scripts="tabcontrol.js,annotations.js,platforms.js,ajax.js,json2.js" styles="tabcontrol.css">
324    <ext:scripts context="<%=jspContext%>" />
325    <ext:stylesheets context="<%=jspContext%>" />
326    <script language="JavaScript">
327    // Validate the "RawBioAssay" tab
328    function validateRawBioAssay()
329    {
330      var frm = document.forms['rawbioassay'];
331      if (Main.trimString(frm.name.value) == '')
332      {
333        alert("You must enter a name");
334        frm.name.focus();
335        return false;
336      }
337      return true;
338    }
339
340    // Submit the form
341    function saveSettings()
342    {
343      var frm = document.forms['rawbioassay'];
344      if (TabControl.validateActiveTab('settings'))
345      {
346        if (annotationsLoaded)
347        {
348          Annotations.addModifiedAnnotationsToForm(frames.annotations, frm);
349        }
350        if (inheritedAnnotationsLoaded)
351        {
352          Annotations.addInheritedAnnotationsToForm(frames.inheritedAnnotations, frm);
353        }
354        if (dataFilesLoaded)
355        {
356          Platforms.addDataFilesToForm(frames.datafiles, frm);
357        }
358        frm.submit();
359      }
360    }
361   
362    var annotationsLoaded = false;
363    var inheritedAnnotationsLoaded = false;
364    var parentsChanged = false;
365    var protocolChanged = false;
366    var dataFilesLoaded = false;
367    var platformChanged = false;
368    function switchTab(tabControlId, tabId)
369    {
370      var frm = document.forms['rawbioassay'];
371      if (TabControl.setActiveTab(tabControlId, tabId))
372      {
373        if (tabId == 'annotations' && (protocolChanged || !annotationsLoaded))
374        {
375          Annotations.loadAnnotateFrame(frames.annotations, '<%=ID%>', '<%=itemType.name()%>', <%=rawBioAssay == null ? 0 : rawBioAssay.getId()%>, getProtocolId());
376          annotationsLoaded = true;
377          protocolChanged = false;
378        }
379        else if (tabId == 'inheritedAnnotations' && 
380          (parentsChanged || !inheritedAnnotationsLoaded))
381        {
382          Annotations.loadInheritFrame(frames.inheritedAnnotations, '<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, getParents());
383          inheritedAnnotationsLoaded = true;
384          parentsChanged = false;
385        }
386        else if (tabId == 'datafiles' && (platformChanged || !dataFilesLoaded))
387        {
388          var platform = Platforms.getSelectedPlatform(frm.platform);
389          var variant = Platforms.getSelectedVariant(frm.platform);
390          Platforms.loadDataFilesFrame(frames.datafiles, '<%=ID%>', '<%=itemType.name()%>', <%=rawBioAssay == null ? 0 : rawBioAssay.getId()%>, platform == null ? 0 : platform.id, variant == null ? 0 : variant.id);
391          dataFilesLoaded = true;
392          platformChanged = false;
393        }
394      }
395    }
396
397    function platformOnChange()
398    {
399      var frm = document.forms['rawbioassay'];
400      platformChanged = true;
401      var platform = Platforms.getSelectedPlatform(frm.platform);
402      var variant = Platforms.getSelectedVariant(frm.platform);
403      var fileOnly = (variant != null && variant.fileOnly) ||
404        (variant == null && platform.fileOnly);
405      var rawDataType = variant == null ? platform.rawDataType : variant.rawDataType;
406      if (frm.rawdatatype[frm.rawdatatype.length - 1].value == '')
407      {
408        frm.rawdatatype[frm.rawdatatype.length - 1] = null;
409      }
410      if (fileOnly)
411      {
412        frm.rawdatatype.disabled = true;
413        Main.removeClass(frm.rawdatatype, 'required');
414        frm.rawdatatype[frm.rawdatatype.length] = new Option('- file only -', '');
415        frm.rawdatatype.selectedIndex = frm.rawdatatype.length - 1;
416      }
417      else if (rawDataType)
418      {
419        frm.rawdatatype.disabled = true;
420        Main.removeClass(frm.rawdatatype, 'required');
421        Forms.selectListOption(frm.rawdatatype, rawDataType);
422      }
423      else
424      {
425        frm.rawdatatype.disabled = <%=hasDbSpots ? "true" : "false"%>;
426        Main.addClass(frm.rawdatatype, 'required');
427      }
428    }
429
430    function getProtocolId()
431    {
432      var frm = document.forms['rawbioassay'];
433      var protocolId = 0;
434      if (frm.protocol_id.length > 0 && !frm.protocol_id.disabled)
435      {
436        protocolId = Math.abs(parseInt(frm.protocol_id[frm.protocol_id.selectedIndex].value));       
437      }
438      return protocolId;
439    }
440
441    function getParents()
442    {
443      var frm = document.forms['rawbioassay'];
444      var parents = new Array();
445
446      var bioAssayId = Math.abs(parseInt(frm.bioassay_id[frm.bioassay_id.selectedIndex].value));
447      if (bioAssayId > 0) parents[parents.length] = 'DERIVEDBIOASSAY:'+bioAssayId;
448      var extractId = Math.abs(parseInt(frm.bioassay_id[frm.extract_id.selectedIndex].value));
449      if (extractId > 0) parents[parents.length] = 'EXTRACT:'+extractId;
450      if (frm.arraydesign_id)
451      {
452        var arrayDesignId = Math.abs(parseInt(frm.arraydesign_id[frm.arraydesign_id.selectedIndex].value));
453        if (arrayDesignId > 0) parents[parents.length] = 'ARRAYDESIGN:'+arrayDesignId;
454      }
455      return parents;
456    }
457
458    function selectProtocolOnClick()
459    {
460      var frm = document.forms['rawbioassay'];
461      var url = '../../admin/protocols/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&callback=setProtocolCallback';
462      if (frm.protocol_id.length > 1)
463      {
464        var id = Math.abs(parseInt(frm.protocol_id[1].value));
465        url += '&item_id='+id;
466      }
467      url += '&resetTemporary=1&tmpfilter:INT:itemSubtype=<%=SystemItems.getId(Protocol.FEATURE_EXTRACTION)%>';
468      Main.openPopup(url, 'SelectProtocol', 1000, 700);
469    }
470    function setProtocolCallback(id, name)
471    {
472      var frm = document.forms['rawbioassay'];
473      var list = frm.protocol_id;
474      if (list.length < 2 || list[1].value == '0') // >
475      {
476        Forms.addListOption(list, 1, new Option());
477      }
478      list[1].value = id;
479      list[1].text = name;
480      list.selectedIndex = 1;
481      protocolChanged = true;
482    }
483    function protocolOnChange()
484    {
485      protocolChanged = true;
486    }
487   
488    function bioAssayOnChange()
489    {
490      var frm = document.forms['rawbioassay'];
491      var selectedIndex = frm.bioassay_id.selectedIndex
492      var bioAssayId = frm.bioassay_id[selectedIndex].value;
493      if (bioAssayId > 0) updateArrayDesign(bioAssayId);
494      parentsChanged = true;
495    }
496    function selectBioAssayOnClick()
497    {
498      var frm = document.forms['rawbioassay'];
499      var url = '../derivedbioassays/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&callback=setBioAssayCallback';
500      if (frm.bioassay_id.length > 1)
501      {
502        var id = Math.abs(parseInt(frm.bioassay_id[1].value));
503        url += '&item_id='+id;
504      }
505      Main.openPopup(url, 'SelectDerivedBioAssay', 1000, 700);
506    }
507    function setBioAssayCallback(id, name)
508    {
509      var frm = document.forms['rawbioassay'];
510      var list = frm.bioassay_id;
511      if (list.length < 2 || list[1].value == '0') // >
512      {
513        Forms.addListOption(list, 1, new Option());
514      }
515      list[1].value = id;
516      list[1].text = name;
517      list.selectedIndex = 1;
518      updateArrayDesign(id)
519      parentsChanged = true;
520    }
521
522   
523    function selectSoftwareOnClick()
524    {
525      var frm = document.forms['rawbioassay'];
526      var url = '../../admin/software/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&callback=setSoftwareCallback';
527      if (frm.software_id.length > 1)
528      {
529        var id = Math.abs(parseInt(frm.software_id[1].value));       
530        url += '&item_id='+id;
531      }
532      url += '&resetTemporary=1&tmpfilter:INT:itemSubtype=<%=SystemItems.getId(Software.FEATURE_EXTRACTION)%>';
533      Main.openPopup(url, 'SelectSoftware', 1000, 700);
534    }
535    function setSoftwareCallback(id, name)
536    {
537      var frm = document.forms['rawbioassay'];
538      var list = frm.software_id;
539      if (list.length < 2 || list[1].value == '0') // >
540      {
541        Forms.addListOption(list, 1, new Option());
542      }
543      list[1].value = id;
544      list[1].text = name;
545      list.selectedIndex = 1;
546    }
547   
548    function arrayDesignOnChange()
549    {
550      parentsChanged = true;
551      <%
552      if (rawBioAssay != null && rawBioAssay.getNumDbSpots() > 0)
553      {
554        %>
555        var frm = document.forms['rawbioassay'];
556        var selectedId = frm.arraydesign_id[frm.arraydesign_id.selectedIndex].value;
557        var showFiMethod = (selectedId > 0 && selectedId != <%=currentArrayDesign == null ? 0 : currentArrayDesign.getId()%>);
558        if (showFiMethod)
559        {
560          Main.show('fiMethod');
561        }
562        else
563        {
564          Main.hide('fiMethod');
565        }
566        <%
567      }
568      %>
569    }
570    function selectArrayDesignOnClick()
571    {
572      var frm = document.forms['rawbioassay'];
573      var url = '../../lims/arraydesigns/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&callback=setArrayDesignCallback';
574      if (frm.arraydesign_id.length > 1)
575      {
576        var id = Math.abs(parseInt(frm.arraydesign_id[1].value));       
577        url += '&item_id='+id;
578      }
579      var platform = Platforms.getSelectedPlatform(frm.platform);
580      url += '&resetTemporary=1&tmpfilter:INT:platform='+platform.id;
581      Main.openPopup(url, 'SelectArrayDesign', 1000, 700);
582    }
583    function setArrayDesignCallback(id, name)
584    {
585      var frm = document.forms['rawbioassay'];
586      var list = frm.arraydesign_id;
587      if (list.length < 2 || list[1].value == '0') // >
588      {
589        Forms.addListOption(list, 1, new Option());
590      }
591      list[1].value = id;
592      list[1].text = name;
593      list.selectedIndex = 1;
594      parentsChanged = true;
595      arrayDesignOnChange();
596    }
597   
598    function updateArrayDesign(bioAssayId)
599    {
600      var request = Ajax.getXmlHttpRequest();
601      if (request != null)
602      {
603        var url = '../derivedbioassays/ajax.jsp?ID=<%=ID%>&cmd=GetArrayDesign&item_id=' + bioAssayId;
604        request.open("GET", url, true);
605        Ajax.setReadyStateHandler(request, updateArrayDesignCallback);
606        request.send(null);
607      }
608      return request != null;
609    }
610    function updateArrayDesignCallback(request)
611    {
612      var frm = document.forms['rawbioassay'];
613      var response = Ajax.parseJsonResponse(request.responseText);
614      if (response.status != 'ok')
615      {
616        alert(response.message);
617        return false;
618      }
619     
620      if (response.id)
621      {
622        var designList = frm.arraydesign_id;
623        if (designList.length < 2 || designList[1].value == '0') // >
624        {
625          Forms.addListOption(designList, 1, new Option());
626        }
627        designList[1].value = response.id;
628        designList[1].text = response.name;
629        designList.selectedIndex = 1;
630      }
631    }
632
633    function init()
634    {
635      <%
636      if (rawBioAssay == null)
637      {
638        %>
639        var frm = document.forms['rawbioassay'];
640        frm.name.focus();
641        frm.name.select();
642        <%
643      }
644      %>
645      initPlatforms(<%=currentPlatform == null ? 0 : currentPlatform.getId()%>, <%=currentVariant == null ? 0 : currentVariant.getId()%>);
646      platformOnChange();
647    }
648   
649    function initPlatforms(platformId, variantId)
650    {
651      <%
652      for (Platform p : platforms)
653      {
654        if (!p.isRemoved() || p.equals(currentPlatform))
655        {
656          RawDataType rdt = p.isFileOnly() ? null : p.getRawDataType();
657          %>
658          var p<%=p.getId()%> = new Platform(<%=p.getId()%>, '<%=HTML.javaScriptEncode(p.getExternalId())%>', '<%=HTML.javaScriptEncode(p.getName())%>', <%=p.isFileOnly()%>, '<%=rdt == null ? "" : rdt.getId()%>');
659          <%
660        }
661      }
662      for (PlatformVariant v : variants)
663      {
664        Platform p = v.getPlatform();
665        if ((!v.isRemoved() || v.equals(currentVariant)) && (!p.isRemoved() || p.equals(currentPlatform)))
666        {
667          RawDataType rdt = v.isFileOnly() ? null : v.getRawDataType();
668          %>
669          var v<%=v.getId()%> = new Variant(p<%=p.getId()%>, <%=v.getId()%>, '<%=HTML.javaScriptEncode(v.getExternalId())%>', '<%=HTML.javaScriptEncode(v.getName())%>', <%=v.isFileOnly()%>, '<%=rdt == null ? "" : rdt.getId()%>');
670          <%
671        }
672      }
673      %>
674      var frm = document.forms['rawbioassay'];
675      Platforms.populateList(frm.platform, platformId, variantId);
676    }
677    </script>
678  </base:head>
679  <base:body onload="init()">
680    <p>
681    <form action="index.jsp?ID=<%=ID%>" method="post" name="rawbioassay" onsubmit="return false;">
682    <input type="hidden" name="cmd" value="UpdateItem">
683
684    <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3>
685    <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*370)+"px;"%>" 
686      position="bottom" active="<%=tabId%>" remember="<%=tabId == null && rawBioAssay != null%>" switch="switchTab"
687      extensions="<%=invoker%>">
688    <t:tab id="info" title="Raw bioassay" validate="validateRawBioAssay()" helpid="rawbioassay.edit">
689      <table class="form" cellspacing=0>
690      <tr>
691        <td class="prompt">Name</td>
692        <td><input <%=requiredClazz%> type="text" name="name" 
693          value="<%=HTML.encodeTags(name)%>" 
694          size="40" maxlength="<%=RawBioAssay.MAX_NAME_LENGTH%>"></td>
695      </tr>
696      <tr>
697        <td class="prompt">Platform</td>
698        <td>
699          <select name="platform" onchange="platformOnChange()" class="required"
700            <%=deniedPlatform || hasDbSpots ? "disabled" : "" %>>
701          <%
702          if (deniedPlatform)
703          {
704            %>
705            <option value="-1">- denied -
706            <%
707          }
708          %>
709          </select>
710        </td>
711      </tr>
712      <tr>
713        <td class="prompt">Raw data type</td>
714        <td>
715          <select name="rawdatatype" class="required"
716            <%=hasDbSpots ? "disabled" : "" %>>
717          <%
718          for (RawDataType rdt : RawDataTypes.getSortedRawDataTypes(new RawDataTypes.NameComparator()))
719          {
720            if (rdt.isStoredInDb())
721            {
722              String selected = rdt.equals(currentRawDataType) ? "selected" : "";
723              %>
724              <option value="<%=rdt.getId()%>" <%=selected%>><%=HTML.encodeTags(rdt.getName())%>
725              <%
726            }
727          }
728          %>
729          </select>
730        </td>
731      </tr>
732      <tr>
733        <td class="prompt">Parent bioassay</td>
734        <td>
735          <base:select 
736            id="bioassay_id"
737            clazz="selectionlist"
738            required="false"
739            current="<%=currentBioAssay%>"
740            denied="<%=!readCurrentBioAssay%>"
741            recent="<%=recentBioAssays%>"
742            newitem="<%=rawBioAssay == null%>"
743            onselect="selectBioAssayOnClick()"
744            onchange="bioAssayOnChange()"
745          />
746        </td>
747      </tr>
748      <tr>
749        <td class="prompt">Parent extract</td>
750        <td>
751          <base:select 
752            id="extract_id"
753            clazz="selectionlist"
754            required="false"
755            current="<%=currentExtract%>"
756            denied="<%=!readCurrentExtract%>"
757            recent="<%=recentExtracts%>"
758            newitem="<%=rawBioAssay == null%>"
759            onselect="selectExtractOnClick()"
760            onchange="extractOnChange()"
761          />
762        </td>
763      </tr>
764      <tr>
765        <td class="prompt">Array design</td>
766        <td>
767          <base:select 
768            id="arraydesign_id"
769            clazz="selectionlist"
770            required="false"
771            current="<%=currentArrayDesign%>"
772            denied="<%=!readCurrentArrayDesign%>"
773            recent="<%=recentArrayDesigns%>"
774            defaultitems="<%=defaultArrayDesigns%>"
775            newitem="<%=rawBioAssay == null%>"
776            onselect="selectArrayDesignOnClick()"
777            onchange="arrayDesignOnChange()"
778          />
779        </td>
780      </tr>
781      <tr id="fiMethod" style="display: none;">
782        <td></td>
783        <td>
784        <select name="fiMethod">
785        <option value="">-auto- (array design decides)
786        <option value="COORDINATES">Coordinates
787        <option value="POSITION">Position
788        <option value="FEATURE_ID">Feature ID (*)
789        </select>
790        <br>
791        Select a method for feature identification. <br>
792        (*) The Feature ID method only works if the raw data is currently
793        connected to an array design which has Feature ID values.
794        </td>
795      </tr>
796      <tr>
797        <td class="prompt">Protocol</td>
798        <td>
799          <base:select 
800            id="protocol_id"
801            clazz="selectionlist"
802            required="false"
803            current="<%=currentProtocol%>"
804            denied="<%=!readCurrentProtocol%>"
805            recent="<%=recentProtocols%>"
806            defaultitems="<%=defaultProtocols%>"
807            newitem="<%=rawBioAssay == null%>"
808            onselect="selectProtocolOnClick()"
809            onchange="protocolOnChange()"
810          />
811        </td>
812      </tr>
813      <tr>
814        <td class="prompt">Software</td>
815        <td>
816          <base:select 
817            id="software_id"
818            clazz="selectionlist"
819            required="false"
820            current="<%=currentSoftware%>"
821            denied="<%=!readCurrentSoftware%>"
822            recent="<%=recentSoftware%>"
823            defaultitems="<%=defaultSoftware%>"
824            newitem="<%=rawBioAssay == null%>"
825            onselect="selectSoftwareOnClick()"
826          />
827        </td>
828      </tr>
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(rawBioAssay == null ? cc.getPropertyValue("description") : rawBioAssay.getDescription())%></textarea>
834          <a href="javascript:Main.zoom('Description', 'rawbioassay', '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></div>
840    </t:tab>
841   
842    <t:tab id="datafiles" title="Data files" helpid="datafiles.edit">
843      <iframe name="datafiles" id="idDatafiles" src="../../common/datafiles/wait.jsp" 
844        width="100%"  height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0
845        marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe>
846    </t:tab>
847
848    <t:tab id="annotations" title="Annotations &amp; parameters" 
849      helpid="annotations.edit" tooltip="Enter values for annotations and protocol parameters">
850      <iframe name="annotations" id="idAnnotations" src="../../common/annotations/wait.jsp" 
851        width="100%"  height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0
852        marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe>
853    </t:tab>
854   
855    <t:tab id="inheritedAnnotations" title="Inherited annotations" helpid="annotations.edit.inherited">
856      <iframe name="inheritedAnnotations" id="idInheritedAnnotations" src="../../common/annotations/wait.jsp" 
857        width="100%"  height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0
858        marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe>
859    </t:tab>
860    </t:tabcontrol>
861
862    <table align="center">
863    <tr>
864      <td width="50%"><base:button onclick="saveSettings()" title="Save" /></td>
865      <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td>
866    </tr>
867    </table>
868    </form>
869  </base:body>
870  </base:page>
871  <%
872}
873finally
874{
875  if (dc != null) dc.close();
876}
877%>
Note: See TracBrowser for help on using the repository browser.