source: trunk/www/views/rawbioassays/edit_rawbioassay.jsp @ 6256

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

References #1729 and #1730. Use lazy loading for the 'Data files' frame in the edit dialogs. Inline scipts has also been removed from the edit file dialog and view and download file links.

  • 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 6256 2013-03-25 09:48:46Z 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<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
70<%
71final Item itemType = Item.RAWBIOASSAY;
72final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
73final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
74final String tabId = Values.getString(request.getParameter("tab"), null);
75final int itemId = cc.getId();
76final String ID = sc.getId();
77final float scale = Base.getScale(sc);
78final DbControl dc = sc.newDbControl();
79try
80{
81  String title = null;
82  RawBioAssay rawBioAssay = null;
83  String name = null;
84  boolean hasDbSpots = false;
85
86  boolean deniedPlatform = false;
87  Platform currentPlatform = null;
88  List<Platform> defaultPlatforms = null;
89  PlatformVariant currentVariant = null;
90  List<PlatformVariant> defaultVariants = null;
91 
92  boolean readCurrentBioAssay = true;
93  DerivedBioAssay currentBioAssay = null;
94  boolean readCurrentExtract = true;
95  Extract currentExtract = null;
96  boolean readCurrentProtocol = true;
97  Protocol currentProtocol = null;
98  List<Protocol> defaultProtocols = null;
99  boolean readCurrentSoftware = true;
100  Software currentSoftware = null;
101  List<Software> defaultSoftware = null;
102  boolean readCurrentArrayDesign = true;
103  ArrayDesign currentArrayDesign = null;
104  List<ArrayDesign> defaultArrayDesigns = null;
105  RawDataType currentRawDataType = null;
106  RawDataType defaultRawDataType = null;
107
108  // Load recently used items
109  List<Protocol> recentProtocols = (List<Protocol>)cc.getRecent(dc, Item.PROTOCOL);
110  List<Software> recentSoftware = (List<Software>)cc.getRecent(dc, Item.SOFTWARE);
111  List<ArrayDesign> recentArrayDesigns = (List<ArrayDesign>)cc.getRecent(dc, Item.ARRAYDESIGN);
112  List<File> recentFiles = (List<File>)cc.getRecent(dc, Item.FILE);
113  List<DerivedBioAssay> recentBioAssays = (List<DerivedBioAssay>)cc.getRecent(dc, Item.DERIVEDBIOASSAY);
114  List<Extract> recentExtracts = (List<Extract>)cc.getRecent(dc, Item.EXTRACT);
115 
116  int activeProjectId = sc.getActiveProjectId();
117  if (activeProjectId > 0)
118  {
119    Project activeProject = Project.getById(dc, activeProjectId);
120    try
121    {
122      defaultProtocols = (List<Protocol>)activeProject.findDefaultItems(dc, 
123          ItemSubtype.getById(dc, SystemItems.getId(Protocol.FEATURE_EXTRACTION)), false);
124    }
125    catch (PermissionDeniedException pdex)
126    {}
127    try
128    {
129      defaultSoftware = (List<Software>)activeProject.findDefaultItems(dc, 
130          ItemSubtype.getById(dc, SystemItems.getId(Software.FEATURE_EXTRACTION)), false);
131    }
132    catch (PermissionDeniedException pdex)
133    {}
134    try
135    {
136      defaultArrayDesigns = (List<ArrayDesign>)activeProject.findDefaultItems(dc, Item.ARRAYDESIGN, true);
137    }
138    catch (PermissionDeniedException pdex)
139    {}
140    try
141    {
142      defaultPlatforms = (List<Platform>)activeProject.findDefaultItems(dc, Item.PLATFORM, true);
143    }
144    catch (PermissionDeniedException pdex)
145    {}
146    try
147    {
148      defaultVariants = (List<PlatformVariant>)activeProject.findDefaultItems(dc, Item.PLATFORMVARIANT, true);
149    }
150    catch (PermissionDeniedException pdex)
151    {}
152    defaultRawDataType = activeProject.getDefaultRawDataType();
153  }
154  if (itemId == 0)
155  {
156    title = "Create raw bioassay";
157    cc.removeObject("item");
158   
159    int currentPlatformId = Values.getInt(cc.getPropertyValue("platform"), 0);
160    if (currentPlatformId == 0)
161    {
162      currentPlatformId = Values.getInt(cc.getRecent(Item.PLATFORM.name(), 0), 0);
163    }
164    int currentVariantId = Values.getInt(cc.getRecent(Item.PLATFORMVARIANT.name(), 0), 0);
165   
166    try
167    {
168      if (currentVariantId != 0) currentVariant = PlatformVariant.getById(dc, currentVariantId);
169      if (currentPlatformId != 0) currentPlatform = Platform.getById(dc, currentPlatformId);
170    }
171    catch (Throwable t)
172    {}
173    if (currentPlatform == null && defaultPlatforms != null && defaultPlatforms.size() > 0) 
174    {
175      currentPlatform = defaultPlatforms.get(0);
176    }
177    if (currentVariant == null && defaultVariants != null && defaultVariants.size() > 0)
178    {
179      currentVariant = defaultVariants.get(0);
180    }
181   
182    currentRawDataType = RawDataTypes.getRawDataType(cc.getPropertyValue("rawDataType"));
183    if (currentRawDataType == null)
184    {
185      currentRawDataType = RawDataTypes.getRawDataType(cc.getRecent("RawDataType", 0));
186    }
187    if (currentRawDataType == null) currentRawDataType = defaultRawDataType;
188
189   
190    int bioAssayId = Values.getInt(request.getParameter("bioassay_id"));
191    if (bioAssayId != 0)
192    {
193      currentBioAssay = DerivedBioAssay.getById(dc, bioAssayId);
194    }
195    else if (cc.getPropertyFilter("parentBioAssay.name") != null)
196    {
197      currentBioAssay = Base.getFirstMatching(dc, DerivedBioAssay.getQuery(), "name", cc.getPropertyFilter("parentBioAssay.name"));
198    }
199   
200    int extractId = Values.getInt(request.getParameter("extract_id"));
201    if (extractId != 0)
202    {
203      currentExtract = Extract.getById(dc, extractId);
204    }
205    else if (cc.getPropertyFilter("parentExtract.name") != null)
206    {
207      currentExtract = Base.getFirstMatching(dc, Extract.getQuery(), "name", cc.getPropertyFilter("parentExtract.name"));
208    }
209
210    if (currentBioAssay != null)
211    {
212      name = currentBioAssay.getName() + ".r" + (currentBioAssay.countRawBioAssays() + 1);
213    }
214    else
215    {
216      name = Values.getString(cc.getPropertyValue("name"), "New raw bioassay");
217    }
218
219    if (cc.getPropertyFilter("protocol.name") != null)
220    {
221      currentProtocol = Base.getFirstMatching(dc, Protocol.getQuery(), "name", cc.getPropertyFilter("protocol.name"));
222    }
223   
224    if (cc.getPropertyFilter("software.name") != null)
225    {
226      currentSoftware = Base.getFirstMatching(dc, Software.getQuery(), "name", cc.getPropertyFilter("software.name"));
227    }
228
229    if (currentBioAssay != null)
230    {
231      try
232      {
233        currentArrayDesign = currentBioAssay.getArrayDesign();
234      }
235      catch (PermissionDeniedException ex)
236      {}
237      try
238      {
239        currentExtract = currentBioAssay.getExtract();
240      }
241      catch (PermissionDeniedException ex)
242      {}
243    }
244    if (currentArrayDesign == null && cc.getPropertyFilter("arrayDesign.name") != null)
245    {
246      currentArrayDesign = Base.getFirstMatching(dc, ArrayDesign.getQuery(), "name", cc.getPropertyFilter("arrayDesign.name"));
247    }
248  }
249  else
250  {
251    rawBioAssay = RawBioAssay.getById(dc, itemId);
252    rawBioAssay.checkPermission(Permission.WRITE);
253    hasDbSpots = rawBioAssay.getNumDbSpots() > 0;
254    cc.setObject("item", rawBioAssay);
255    name = rawBioAssay.getName();
256    try
257    {
258      currentRawDataType = rawBioAssay.getRawDataType();
259    }
260    catch (Throwable t)
261    {}
262    title = "Edit raw bioassay -- " + HTML.encodeTags(rawBioAssay.getName());
263   
264    try
265    {
266      currentPlatform = rawBioAssay.getPlatform();
267      currentVariant = rawBioAssay.getVariant();
268    }
269    catch (PermissionDeniedException ex)
270    {
271      deniedPlatform = true;
272    }
273   
274    try
275    {
276      currentBioAssay = rawBioAssay.getParentBioAssay();
277    }
278    catch (PermissionDeniedException ex)
279    {
280      readCurrentBioAssay = false;
281    }
282    try
283    {
284      currentExtract = rawBioAssay.getParentExtract();
285    }
286    catch (PermissionDeniedException ex)
287    {
288      readCurrentExtract = false;
289    }
290    try
291    {
292      currentProtocol = rawBioAssay.getProtocol();
293    }
294    catch (PermissionDeniedException ex)
295    {
296      readCurrentProtocol = false;
297    }
298    try
299    {
300      currentSoftware = rawBioAssay.getSoftware();
301    }
302    catch (PermissionDeniedException ex)
303    {
304      readCurrentSoftware = false;
305    }
306    try
307    {
308      currentArrayDesign = rawBioAssay.getArrayDesign();
309    }
310    catch (PermissionDeniedException ex)
311    {
312      readCurrentArrayDesign = false;
313    }
314  }
315 
316  ItemQuery<Platform> platformQuery = Platform.getQuery();
317  platformQuery.include(Include.REMOVED, Include.NOT_REMOVED);
318  platformQuery.order(Orders.asc(Hql.property("name")));
319  platformQuery.setCacheResult(true);
320  ItemResultList<Platform> platforms = platformQuery.list(dc);
321
322  ItemQuery<PlatformVariant> variantQuery = PlatformVariant.getQuery();
323  variantQuery.include(Include.REMOVED, Include.NOT_REMOVED);
324  variantQuery.order(Orders.asc(Hql.property("name")));
325  variantQuery.setCacheResult(true);
326  ItemResultList<PlatformVariant> variants = variantQuery.list(dc);
327 
328 
329 
330  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), rawBioAssay);
331  ExtensionsInvoker invoker = EditUtil.useEditExtensions(jspContext);
332  %>
333  <base:page type="popup" title="<%=title%>">
334  <base:head scripts="tabcontrol.js,platforms.js" styles="tabcontrol.css">
335    <ext:scripts context="<%=jspContext%>" />
336    <ext:stylesheets context="<%=jspContext%>" />
337    <script>
338    // Validate the "RawBioAssay" tab
339    function validateRawBioAssay()
340    {
341      var frm = document.forms['rawbioassay'];
342      if (Main.trimString(frm.name.value) == '')
343      {
344        Forms.showNotification(frm.name, 'You must enter a name');
345        return false;
346      }
347      return true;
348    }
349
350    // Submit the form
351    function saveSettings()
352    {
353      var frm = document.forms['rawbioassay'];
354      if (TabControl.validateActiveTab('settings'))
355      {
356        Annotations.saveModifiedAnnotationsToForm(frm);
357        Annotations.saveInheritedAnnotationsToForm(frm);
358        DataFiles.writeFileActionsToForm(frm);
359        frm.submit();
360      }
361    }
362   
363    function loadAnnotationsFrame()
364    {
365      Annotations.autoLoadEditFrame(getProtocolId());
366    }
367   
368    function loadInheritedAnnotationsFrame()
369    {
370      Annotations.autoLoadInheritFrame(getParents());
371    }
372 
373    function loadDataFilesFrame()
374    {
375      var frm = document.forms['rawbioassay'];
376      var platform = Platforms.getSelectedPlatform(frm.platform);
377      var variant = Platforms.getSelectedVariant(frm.platform);
378      DataFiles.autoLoadEditFrame(platform ? platform.id : 0, variant ? variant.id : 0, 0);
379    }
380   
381    function platformOnChange()
382    {
383      var frm = document.forms['rawbioassay'];
384      var platform = Platforms.getSelectedPlatform(frm.platform);
385      var variant = Platforms.getSelectedVariant(frm.platform);
386      var fileOnly = (variant != null && variant.fileOnly) ||
387        (variant == null && platform.fileOnly);
388      var rawDataType = variant == null ? platform.rawDataType : variant.rawDataType;
389      if (frm.rawdatatype[frm.rawdatatype.length - 1].value == '')
390      {
391        frm.rawdatatype[frm.rawdatatype.length - 1] = null;
392      }
393      if (fileOnly)
394      {
395        frm.rawdatatype.disabled = true;
396        Main.removeClass(frm.rawdatatype, 'required');
397        frm.rawdatatype[frm.rawdatatype.length] = new Option('- file only -', '');
398        frm.rawdatatype.selectedIndex = frm.rawdatatype.length - 1;
399      }
400      else if (rawDataType)
401      {
402        frm.rawdatatype.disabled = true;
403        Main.removeClass(frm.rawdatatype, 'required');
404        Forms.selectListOption(frm.rawdatatype, rawDataType);
405      }
406      else
407      {
408        frm.rawdatatype.disabled = <%=hasDbSpots ? "true" : "false"%>;
409        Main.addClass(frm.rawdatatype, 'required');
410      }
411    }
412
413    function getProtocolId()
414    {
415      var frm = document.forms['rawbioassay'];
416      var protocolId = 0;
417      if (frm.protocol_id.length > 0 && !frm.protocol_id.disabled)
418      {
419        protocolId = Math.abs(parseInt(frm.protocol_id[frm.protocol_id.selectedIndex].value));       
420      }
421      return protocolId;
422    }
423
424    function getParents()
425    {
426      var frm = document.forms['rawbioassay'];
427      var parents = new Array();
428
429      var bioAssayId = Math.abs(parseInt(frm.bioassay_id[frm.bioassay_id.selectedIndex].value));
430      if (bioAssayId > 0) parents[parents.length] = 'DERIVEDBIOASSAY:'+bioAssayId;
431      var extractId = Math.abs(parseInt(frm.extract_id[frm.extract_id.selectedIndex].value));
432      if (extractId > 0) parents[parents.length] = 'EXTRACT:'+extractId;
433      if (frm.arraydesign_id)
434      {
435        var arrayDesignId = Math.abs(parseInt(frm.arraydesign_id[frm.arraydesign_id.selectedIndex].value));
436        if (arrayDesignId > 0) parents[parents.length] = 'ARRAYDESIGN:'+arrayDesignId;
437      }
438      return parents;
439    }
440
441    function selectProtocolOnClick()
442    {
443      var frm = document.forms['rawbioassay'];
444      var url = '../../admin/protocols/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&callback=setProtocolCallback';
445      if (frm.protocol_id.length > 1)
446      {
447        var id = Math.abs(parseInt(frm.protocol_id[1].value));
448        url += '&item_id='+id;
449      }
450      url += '&resetTemporary=1&tmpfilter:INT:itemSubtype=<%=SystemItems.getId(Protocol.FEATURE_EXTRACTION)%>';
451      Main.openPopup(url, 'SelectProtocol', 1050, 700);
452    }
453    function setProtocolCallback(id, name)
454    {
455      var frm = document.forms['rawbioassay'];
456      var list = frm.protocol_id;
457      if (list.length < 2 || list[1].value == '0') // >
458      {
459        Forms.addListOption(list, 1, new Option());
460      }
461      list[1].value = id;
462      list[1].text = name;
463      list.selectedIndex = 1;
464    }
465   
466    function bioAssayOnChange()
467    {
468      var frm = document.forms['rawbioassay'];
469      var selectedIndex = frm.bioassay_id.selectedIndex
470      var bioAssayId = Math.abs(frm.bioassay_id[frm.bioassay_id.selectedIndex].value);
471      if (bioAssayId > 0) updateArrayDesign(bioAssayId);
472    }
473    function selectBioAssayOnClick()
474    {
475      var frm = document.forms['rawbioassay'];
476      var url = '../derivedbioassays/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&callback=setBioAssayCallback';
477      if (frm.bioassay_id.length > 1)
478      {
479        var id = Math.abs(parseInt(frm.bioassay_id[1].value));
480        url += '&item_id='+id;
481      }
482      Main.openPopup(url, 'SelectDerivedBioAssay', 1050, 700);
483    }
484    function setBioAssayCallback(id, name)
485    {
486      var frm = document.forms['rawbioassay'];
487      var list = frm.bioassay_id;
488      if (list.length < 2 || list[1].value == '0') // >
489      {
490        Forms.addListOption(list, 1, new Option());
491      }
492      list[1].value = id;
493      list[1].text = name;
494      list.selectedIndex = 1;
495      bioAssayOnChange();
496    }
497
498    function selectExtractOnClick()
499    {
500      var frm = document.forms['rawbioassay'];
501     
502      var relatedExtractIds = null;
503      var bioAssayId = Math.abs(frm.bioassay_id[frm.bioassay_id.selectedIndex].value);
504      if (bioAssayId > 0)
505      {
506        var request = Ajax.getXmlHttpRequest();
507        var url = '../derivedbioassays/ajax.jsp?ID=<%=ID%>&cmd=GetAllExtractIds';
508        url += '&bioassay_ids=' + bioAssayId;
509        request.open("GET", url, false);
510        request.send(null);
511                   
512        var response = JSON.parse(request.responseText);
513        if (response.status != 'ok')
514        {
515          alert(response.message);
516          return null;
517        }
518        relatedExtractIds = response.allExtractIds;
519      }
520     
521      var url = '../../biomaterials/extracts/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone'
522      url += '&callback=setExtractCallback&resetTemporary=1';
523      if (relatedExtractIds)
524      {
525        url += '&tmpfilter:INT:id='+relatedExtractIds.join('|');
526      }
527      if (frm.extract_id.length > 1)
528      {
529        var id = Math.abs(parseInt(frm.extract_id[1].value));
530        url += '&item_id='+id;
531      }
532      Main.openPopup(url, 'SelectExtract', 1050, 700);
533    }
534    function setExtractCallback(id, name)
535    {
536      var frm = document.forms['rawbioassay'];
537      var list = frm.extract_id;
538      if (list.length < 2 || list[1].value == '0') // >
539      {
540        Forms.addListOption(list, 1, new Option());
541      }
542      list[1].value = id;
543      list[1].text = name;
544      list.selectedIndex = 1;
545    }
546   
547    function selectSoftwareOnClick()
548    {
549      var frm = document.forms['rawbioassay'];
550      var url = '../../admin/software/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&callback=setSoftwareCallback';
551      if (frm.software_id.length > 1)
552      {
553        var id = Math.abs(parseInt(frm.software_id[1].value));       
554        url += '&item_id='+id;
555      }
556      url += '&resetTemporary=1&tmpfilter:INT:itemSubtype=<%=SystemItems.getId(Software.FEATURE_EXTRACTION)%>';
557      Main.openPopup(url, 'SelectSoftware', 1050, 700);
558    }
559    function setSoftwareCallback(id, name)
560    {
561      var frm = document.forms['rawbioassay'];
562      var list = frm.software_id;
563      if (list.length < 2 || list[1].value == '0') // >
564      {
565        Forms.addListOption(list, 1, new Option());
566      }
567      list[1].value = id;
568      list[1].text = name;
569      list.selectedIndex = 1;
570    }
571   
572    function arrayDesignOnChange()
573    {
574      <%
575      if (rawBioAssay != null && rawBioAssay.getNumDbSpots() > 0)
576      {
577        %>
578        var frm = document.forms['rawbioassay'];
579        var selectedId = frm.arraydesign_id[frm.arraydesign_id.selectedIndex].value;
580        var showFiMethod = (selectedId > 0 && selectedId != <%=currentArrayDesign == null ? 0 : currentArrayDesign.getId()%>);
581        if (showFiMethod)
582        {
583          Main.show('fiMethod');
584        }
585        else
586        {
587          Main.hide('fiMethod');
588        }
589        <%
590      }
591      %>
592    }
593    function selectArrayDesignOnClick()
594    {
595      var frm = document.forms['rawbioassay'];
596      var url = '../../lims/arraydesigns/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&callback=setArrayDesignCallback';
597      if (frm.arraydesign_id.length > 1)
598      {
599        var id = Math.abs(parseInt(frm.arraydesign_id[1].value));       
600        url += '&item_id='+id;
601      }
602      var platform = Platforms.getSelectedPlatform(frm.platform);
603      url += '&resetTemporary=1&tmpfilter:INT:platform='+platform.id;
604      Main.openPopup(url, 'SelectArrayDesign', 1050, 700);
605    }
606    function setArrayDesignCallback(id, name)
607    {
608      var frm = document.forms['rawbioassay'];
609      var list = frm.arraydesign_id;
610      if (list.length < 2 || list[1].value == '0') // >
611      {
612        Forms.addListOption(list, 1, new Option());
613      }
614      list[1].value = id;
615      list[1].text = name;
616      list.selectedIndex = 1;
617      arrayDesignOnChange();
618    }
619   
620    function updateArrayDesign(bioAssayId)
621    {
622      if (!bioAssayId) return;
623      var request = Ajax.getXmlHttpRequest();
624      var url = '../derivedbioassays/ajax.jsp?ID=<%=ID%>&cmd=GetArrayDesign&item_id=' + bioAssayId;
625      request.open("GET", url, false);
626      request.send(null);
627
628      var response = JSON.parse(request.responseText);
629      if (response.status != 'ok')
630      {
631        alert(response.message);
632        return null;
633      }
634     
635      var frm = document.forms['rawbioassay'];
636      if (response.id)
637      {
638        var designList = frm.arraydesign_id;
639        if (designList.length < 2 || designList[1].value == '0') // >
640        {
641          Forms.addListOption(designList, 1, new Option());
642        }
643        designList[1].value = response.id;
644        designList[1].text = response.name;
645        designList.selectedIndex = 1;
646      }
647    }
648
649
650    function init()
651    {
652      <%
653      if (rawBioAssay == null)
654      {
655        %>
656        var frm = document.forms['rawbioassay'];
657        frm.name.focus();
658        frm.name.select();
659        <%
660      }
661      %>
662      initPlatforms(<%=currentPlatform == null ? 0 : currentPlatform.getId()%>, <%=currentVariant == null ? 0 : currentVariant.getId()%>);
663      platformOnChange();
664    }
665   
666    function initPlatforms(platformId, variantId)
667    {
668      <%
669      for (Platform p : platforms)
670      {
671        if (!p.isRemoved() || p.equals(currentPlatform))
672        {
673          RawDataType rdt = p.isFileOnly() ? null : p.getRawDataType();
674          %>
675          var p<%=p.getId()%> = new Platform(<%=p.getId()%>, '<%=HTML.javaScriptEncode(p.getExternalId())%>', '<%=HTML.javaScriptEncode(p.getName())%>', <%=p.isFileOnly()%>, '<%=rdt == null ? "" : rdt.getId()%>');
676          <%
677        }
678      }
679      for (PlatformVariant v : variants)
680      {
681        Platform p = v.getPlatform();
682        if ((!v.isRemoved() || v.equals(currentVariant)) && (!p.isRemoved() || p.equals(currentPlatform)))
683        {
684          RawDataType rdt = v.isFileOnly() ? null : v.getRawDataType();
685          %>
686          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()%>');
687          <%
688        }
689      }
690      %>
691      var frm = document.forms['rawbioassay'];
692      Platforms.populateList(frm.platform, platformId, variantId);
693    }
694    </script>
695  </base:head>
696  <base:body onload="init()">
697    <h1><%=title%> <base:help tabcontrol="settings" /></h1>
698    <form action="index.jsp?ID=<%=ID%>" method="post" name="rawbioassay">
699    <input type="hidden" name="cmd" value="UpdateItem">
700
701    <t:tabcontrol id="settings" 
702      subclass="content dialogtabcontrol"
703      position="bottom" active="<%=tabId%>" 
704      remember="<%=tabId == null && rawBioAssay != null%>" 
705      extensions="<%=invoker%>">
706    <t:tab id="info" title="Raw bioassay" validate="validateRawBioAssay()" helpid="rawbioassay.edit">
707      <table class="fullform input100">
708      <tr>
709        <th>Name</th>
710        <td><input class="text required" type="text" name="name" 
711          value="<%=HTML.encodeTags(name)%>" 
712          maxlength="<%=RawBioAssay.MAX_NAME_LENGTH%>"></td>
713        <td></td>
714      </tr>
715      <tr>
716        <th>Platform</th>
717        <td>
718          <select name="platform" onchange="platformOnChange()" class="required"
719            <%=deniedPlatform || hasDbSpots ? "disabled" : "" %>>
720          <%
721          if (deniedPlatform)
722          {
723            %>
724            <option value="-1">- denied -
725            <%
726          }
727          %>
728          </select>
729        </td>
730        <td></td>
731      </tr>
732      <tr>
733        <th>Raw data type</th>
734        <td>
735          <select name="rawdatatype" class="required"
736            <%=hasDbSpots ? "disabled" : "" %>>
737          <%
738          for (RawDataType rdt : RawDataTypes.getSortedRawDataTypes(new RawDataTypes.NameComparator()))
739          {
740            if (rdt.isStoredInDb())
741            {
742              String selected = rdt.equals(currentRawDataType) ? "selected" : "";
743              %>
744              <option value="<%=rdt.getId()%>" <%=selected%>><%=HTML.encodeTags(rdt.getName())%>
745              <%
746            }
747          }
748          %>
749          </select>
750        </td>
751        <td></td>
752      </tr>
753      <tr>
754        <th>Parent bioassay</th>
755        <td>
756          <base:select 
757            id="bioassay_id"
758            clazz="selectionlist"
759            required="false"
760            current="<%=currentBioAssay%>"
761            denied="<%=!readCurrentBioAssay%>"
762            recent="<%=recentBioAssays%>"
763            newitem="<%=rawBioAssay == null%>"
764            selectrecent="<%=currentExtract == null %>"
765            onselect="selectBioAssayOnClick()"
766            onchange="bioAssayOnChange()"
767          />
768        </td>
769        <td></td>
770      </tr>
771      <tr>
772        <th>Parent extract</th>
773        <td>
774          <base:select 
775            id="extract_id"
776            clazz="selectionlist"
777            required="false"
778            current="<%=currentExtract%>"
779            denied="<%=!readCurrentExtract%>"
780            recent="<%=recentExtracts%>"
781            newitem="<%=rawBioAssay == null%>"
782            selectrecent="false"
783            onselect="selectExtractOnClick()"
784          />
785        </td>
786        <td></td>
787      </tr>
788      <tr>
789        <th>Array design</th>
790        <td>
791          <base:select 
792            id="arraydesign_id"
793            clazz="selectionlist"
794            required="false"
795            current="<%=currentArrayDesign%>"
796            denied="<%=!readCurrentArrayDesign%>"
797            recent="<%=recentArrayDesigns%>"
798            defaultitems="<%=defaultArrayDesigns%>"
799            newitem="<%=rawBioAssay == null%>"
800            onselect="selectArrayDesignOnClick()"
801            onchange="arrayDesignOnChange()"
802          />
803        </td>
804        <td></td>
805      </tr>
806      <tr id="fiMethod" style="display: none;">
807        <th></th>
808        <td>
809        <select name="fiMethod">
810        <option value="">-auto- (array design decides)
811        <option value="COORDINATES">Coordinates
812        <option value="POSITION">Position
813        <option value="FEATURE_ID">Feature ID (*)
814        </select>
815        <br>
816        Select a method for feature identification. <br>
817        (*) The Feature ID method only works if the raw data is currently
818        connected to an array design which has Feature ID values.
819        </td>
820        <td></td>
821      </tr>
822      <tr>
823        <th>Protocol</th>
824        <td>
825          <base:select 
826            id="protocol_id"
827            clazz="selectionlist"
828            required="false"
829            current="<%=currentProtocol%>"
830            denied="<%=!readCurrentProtocol%>"
831            recent="<%=recentProtocols%>"
832            defaultitems="<%=defaultProtocols%>"
833            newitem="<%=rawBioAssay == null%>"
834            onselect="selectProtocolOnClick()"
835          />
836        </td>
837        <td></td>
838      </tr>
839      <tr>
840        <th>Software</th>
841        <td>
842          <base:select 
843            id="software_id"
844            clazz="selectionlist"
845            required="false"
846            current="<%=currentSoftware%>"
847            denied="<%=!readCurrentSoftware%>"
848            recent="<%=recentSoftware%>"
849            defaultitems="<%=defaultSoftware%>"
850            newitem="<%=rawBioAssay == null%>"
851            onselect="selectSoftwareOnClick()"
852          />
853        </td>
854        <td></td>
855      </tr>
856      <tr class="dynamic">
857        <th>Description</th>
858        <td>
859          <textarea class="text" rows="6" name="description" id="description"
860            ><%=HTML.encodeTags(rawBioAssay == null ? cc.getPropertyValue("description") : rawBioAssay.getDescription())%></textarea>
861        </td>
862        <td style="width: 20px;">
863          <base:zoom textarea="description" title="Description" />
864        </td>
865      </tr>
866      </table>
867    </t:tab>
868   
869    <t:tab id="datafiles" title="Data files" helpid="datafiles.edit" activate="loadDataFilesFrame()">
870      <jsp:include page="../../common/datafiles/select_frameset.jsp">
871        <jsp:param name="item_type" value="<%=itemType.name()%>" />
872        <jsp:param name="item_id" value="<%=itemId%>" />
873        <jsp:param name="ID" value="<%=ID%>" />
874      </jsp:include>
875    </t:tab>
876
877    <t:tab id="annotations" title="Annotations &amp; parameters" helpid="annotations.edit" activate="loadAnnotationsFrame()">
878      <jsp:include page="../../common/annotations/annotate_frameset.jsp">
879        <jsp:param name="item_type" value="<%=itemType.name()%>" />
880        <jsp:param name="item_id" value="<%=itemId%>" />
881        <jsp:param name="ID" value="<%=ID%>" />
882      </jsp:include>
883    </t:tab>
884   
885    <t:tab id="inheritedAnnotations" title="Inherited annotations" 
886      helpid="annotations.edit.inherited" activate="loadInheritedAnnotationsFrame()">
887      <jsp:include page="../../common/annotations/inherit_frameset.jsp">
888        <jsp:param name="item_type" value="<%=itemType.name()%>" />
889        <jsp:param name="item_id" value="<%=itemId%>" />
890        <jsp:param name="ID" value="<%=ID%>" />
891      </jsp:include>
892    </t:tab>
893    </t:tabcontrol>
894    </form>
895
896    <div class="legend">
897      <base:icon image="required.png" />= required information
898    </div>
899
900    <base:buttongroup subclass="dialogbuttons">
901      <base:button onclick="saveSettings()" title="Save" />
902      <base:button onclick="window.close()" title="Cancel" />
903    </base:buttongroup>
904  </base:body>
905  </base:page>
906  <%
907}
908finally
909{
910  if (dc != null) dc.close();
911}
912%>
Note: See TracBrowser for help on using the repository browser.