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

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

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

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 27.7 KB
Line 
1<%-- $Id: edit_rawbioassay.jsp 6254 2013-03-22 07:28:26Z 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        if (dataFilesLoaded)
359        {
360          frames.datafiles.writeFileActionsToForm(frm);
361        }
362        frm.submit();
363      }
364    }
365   
366    function loadAnnotationsFrame()
367    {
368      Annotations.autoLoadEditFrame(getProtocolId());
369    }
370   
371    function loadInheritedAnnotationsFrame()
372    {
373      Annotations.autoLoadInheritFrame(getParents());
374    }
375 
376    var dataFilesLoaded = false;
377    var platformChanged = false;
378
379    function loadDataFilesFrame()
380    {
381      var frm = document.forms['rawbioassay'];
382      if (platformChanged || !dataFilesLoaded)
383      {
384        var platform = Platforms.getSelectedPlatform(frm.platform);
385        var variant = Platforms.getSelectedVariant(frm.platform);
386        Platforms.loadDataFilesFrame(frames.datafiles, '<%=ID%>', '<%=itemType.name()%>', <%=rawBioAssay == null ? 0 : rawBioAssay.getId()%>, platform == null ? 0 : platform.id, variant == null ? 0 : variant.id);
387        dataFilesLoaded = true;
388        platformChanged = false;
389      }
390    }
391   
392    function platformOnChange()
393    {
394      var frm = document.forms['rawbioassay'];
395      platformChanged = true;
396      var platform = Platforms.getSelectedPlatform(frm.platform);
397      var variant = Platforms.getSelectedVariant(frm.platform);
398      var fileOnly = (variant != null && variant.fileOnly) ||
399        (variant == null && platform.fileOnly);
400      var rawDataType = variant == null ? platform.rawDataType : variant.rawDataType;
401      if (frm.rawdatatype[frm.rawdatatype.length - 1].value == '')
402      {
403        frm.rawdatatype[frm.rawdatatype.length - 1] = null;
404      }
405      if (fileOnly)
406      {
407        frm.rawdatatype.disabled = true;
408        Main.removeClass(frm.rawdatatype, 'required');
409        frm.rawdatatype[frm.rawdatatype.length] = new Option('- file only -', '');
410        frm.rawdatatype.selectedIndex = frm.rawdatatype.length - 1;
411      }
412      else if (rawDataType)
413      {
414        frm.rawdatatype.disabled = true;
415        Main.removeClass(frm.rawdatatype, 'required');
416        Forms.selectListOption(frm.rawdatatype, rawDataType);
417      }
418      else
419      {
420        frm.rawdatatype.disabled = <%=hasDbSpots ? "true" : "false"%>;
421        Main.addClass(frm.rawdatatype, 'required');
422      }
423    }
424
425    function getProtocolId()
426    {
427      var frm = document.forms['rawbioassay'];
428      var protocolId = 0;
429      if (frm.protocol_id.length > 0 && !frm.protocol_id.disabled)
430      {
431        protocolId = Math.abs(parseInt(frm.protocol_id[frm.protocol_id.selectedIndex].value));       
432      }
433      return protocolId;
434    }
435
436    function getParents()
437    {
438      var frm = document.forms['rawbioassay'];
439      var parents = new Array();
440
441      var bioAssayId = Math.abs(parseInt(frm.bioassay_id[frm.bioassay_id.selectedIndex].value));
442      if (bioAssayId > 0) parents[parents.length] = 'DERIVEDBIOASSAY:'+bioAssayId;
443      var extractId = Math.abs(parseInt(frm.extract_id[frm.extract_id.selectedIndex].value));
444      if (extractId > 0) parents[parents.length] = 'EXTRACT:'+extractId;
445      if (frm.arraydesign_id)
446      {
447        var arrayDesignId = Math.abs(parseInt(frm.arraydesign_id[frm.arraydesign_id.selectedIndex].value));
448        if (arrayDesignId > 0) parents[parents.length] = 'ARRAYDESIGN:'+arrayDesignId;
449      }
450      return parents;
451    }
452
453    function selectProtocolOnClick()
454    {
455      var frm = document.forms['rawbioassay'];
456      var url = '../../admin/protocols/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&callback=setProtocolCallback';
457      if (frm.protocol_id.length > 1)
458      {
459        var id = Math.abs(parseInt(frm.protocol_id[1].value));
460        url += '&item_id='+id;
461      }
462      url += '&resetTemporary=1&tmpfilter:INT:itemSubtype=<%=SystemItems.getId(Protocol.FEATURE_EXTRACTION)%>';
463      Main.openPopup(url, 'SelectProtocol', 1050, 700);
464    }
465    function setProtocolCallback(id, name)
466    {
467      var frm = document.forms['rawbioassay'];
468      var list = frm.protocol_id;
469      if (list.length < 2 || list[1].value == '0') // >
470      {
471        Forms.addListOption(list, 1, new Option());
472      }
473      list[1].value = id;
474      list[1].text = name;
475      list.selectedIndex = 1;
476    }
477   
478    function bioAssayOnChange()
479    {
480      var frm = document.forms['rawbioassay'];
481      var selectedIndex = frm.bioassay_id.selectedIndex
482      var bioAssayId = Math.abs(frm.bioassay_id[frm.bioassay_id.selectedIndex].value);
483      if (bioAssayId > 0) updateArrayDesign(bioAssayId);
484    }
485    function selectBioAssayOnClick()
486    {
487      var frm = document.forms['rawbioassay'];
488      var url = '../derivedbioassays/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&callback=setBioAssayCallback';
489      if (frm.bioassay_id.length > 1)
490      {
491        var id = Math.abs(parseInt(frm.bioassay_id[1].value));
492        url += '&item_id='+id;
493      }
494      Main.openPopup(url, 'SelectDerivedBioAssay', 1050, 700);
495    }
496    function setBioAssayCallback(id, name)
497    {
498      var frm = document.forms['rawbioassay'];
499      var list = frm.bioassay_id;
500      if (list.length < 2 || list[1].value == '0') // >
501      {
502        Forms.addListOption(list, 1, new Option());
503      }
504      list[1].value = id;
505      list[1].text = name;
506      list.selectedIndex = 1;
507      bioAssayOnChange();
508    }
509
510    function selectExtractOnClick()
511    {
512      var frm = document.forms['rawbioassay'];
513     
514      var relatedExtractIds = null;
515      var bioAssayId = Math.abs(frm.bioassay_id[frm.bioassay_id.selectedIndex].value);
516      if (bioAssayId > 0)
517      {
518        var request = Ajax.getXmlHttpRequest();
519        var url = '../derivedbioassays/ajax.jsp?ID=<%=ID%>&cmd=GetAllExtractIds';
520        url += '&bioassay_ids=' + bioAssayId;
521        request.open("GET", url, false);
522        request.send(null);
523                   
524        var response = JSON.parse(request.responseText);
525        if (response.status != 'ok')
526        {
527          alert(response.message);
528          return null;
529        }
530        relatedExtractIds = response.allExtractIds;
531      }
532     
533      var url = '../../biomaterials/extracts/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone'
534      url += '&callback=setExtractCallback&resetTemporary=1';
535      if (relatedExtractIds)
536      {
537        url += '&tmpfilter:INT:id='+relatedExtractIds.join('|');
538      }
539      if (frm.extract_id.length > 1)
540      {
541        var id = Math.abs(parseInt(frm.extract_id[1].value));
542        url += '&item_id='+id;
543      }
544      Main.openPopup(url, 'SelectExtract', 1050, 700);
545    }
546    function setExtractCallback(id, name)
547    {
548      var frm = document.forms['rawbioassay'];
549      var list = frm.extract_id;
550      if (list.length < 2 || list[1].value == '0') // >
551      {
552        Forms.addListOption(list, 1, new Option());
553      }
554      list[1].value = id;
555      list[1].text = name;
556      list.selectedIndex = 1;
557    }
558   
559    function selectSoftwareOnClick()
560    {
561      var frm = document.forms['rawbioassay'];
562      var url = '../../admin/software/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&callback=setSoftwareCallback';
563      if (frm.software_id.length > 1)
564      {
565        var id = Math.abs(parseInt(frm.software_id[1].value));       
566        url += '&item_id='+id;
567      }
568      url += '&resetTemporary=1&tmpfilter:INT:itemSubtype=<%=SystemItems.getId(Software.FEATURE_EXTRACTION)%>';
569      Main.openPopup(url, 'SelectSoftware', 1050, 700);
570    }
571    function setSoftwareCallback(id, name)
572    {
573      var frm = document.forms['rawbioassay'];
574      var list = frm.software_id;
575      if (list.length < 2 || list[1].value == '0') // >
576      {
577        Forms.addListOption(list, 1, new Option());
578      }
579      list[1].value = id;
580      list[1].text = name;
581      list.selectedIndex = 1;
582    }
583   
584    function arrayDesignOnChange()
585    {
586      <%
587      if (rawBioAssay != null && rawBioAssay.getNumDbSpots() > 0)
588      {
589        %>
590        var frm = document.forms['rawbioassay'];
591        var selectedId = frm.arraydesign_id[frm.arraydesign_id.selectedIndex].value;
592        var showFiMethod = (selectedId > 0 && selectedId != <%=currentArrayDesign == null ? 0 : currentArrayDesign.getId()%>);
593        if (showFiMethod)
594        {
595          Main.show('fiMethod');
596        }
597        else
598        {
599          Main.hide('fiMethod');
600        }
601        <%
602      }
603      %>
604    }
605    function selectArrayDesignOnClick()
606    {
607      var frm = document.forms['rawbioassay'];
608      var url = '../../lims/arraydesigns/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&callback=setArrayDesignCallback';
609      if (frm.arraydesign_id.length > 1)
610      {
611        var id = Math.abs(parseInt(frm.arraydesign_id[1].value));       
612        url += '&item_id='+id;
613      }
614      var platform = Platforms.getSelectedPlatform(frm.platform);
615      url += '&resetTemporary=1&tmpfilter:INT:platform='+platform.id;
616      Main.openPopup(url, 'SelectArrayDesign', 1050, 700);
617    }
618    function setArrayDesignCallback(id, name)
619    {
620      var frm = document.forms['rawbioassay'];
621      var list = frm.arraydesign_id;
622      if (list.length < 2 || list[1].value == '0') // >
623      {
624        Forms.addListOption(list, 1, new Option());
625      }
626      list[1].value = id;
627      list[1].text = name;
628      list.selectedIndex = 1;
629      arrayDesignOnChange();
630    }
631   
632    function updateArrayDesign(bioAssayId)
633    {
634      if (!bioAssayId) return;
635      var request = Ajax.getXmlHttpRequest();
636      var url = '../derivedbioassays/ajax.jsp?ID=<%=ID%>&cmd=GetArrayDesign&item_id=' + bioAssayId;
637      request.open("GET", url, false);
638      request.send(null);
639
640      var response = JSON.parse(request.responseText);
641      if (response.status != 'ok')
642      {
643        alert(response.message);
644        return null;
645      }
646     
647      var frm = document.forms['rawbioassay'];
648      if (response.id)
649      {
650        var designList = frm.arraydesign_id;
651        if (designList.length < 2 || designList[1].value == '0') // >
652        {
653          Forms.addListOption(designList, 1, new Option());
654        }
655        designList[1].value = response.id;
656        designList[1].text = response.name;
657        designList.selectedIndex = 1;
658      }
659    }
660
661
662    function init()
663    {
664      <%
665      if (rawBioAssay == null)
666      {
667        %>
668        var frm = document.forms['rawbioassay'];
669        frm.name.focus();
670        frm.name.select();
671        <%
672      }
673      %>
674      initPlatforms(<%=currentPlatform == null ? 0 : currentPlatform.getId()%>, <%=currentVariant == null ? 0 : currentVariant.getId()%>);
675      platformOnChange();
676    }
677   
678    function initPlatforms(platformId, variantId)
679    {
680      <%
681      for (Platform p : platforms)
682      {
683        if (!p.isRemoved() || p.equals(currentPlatform))
684        {
685          RawDataType rdt = p.isFileOnly() ? null : p.getRawDataType();
686          %>
687          var p<%=p.getId()%> = new Platform(<%=p.getId()%>, '<%=HTML.javaScriptEncode(p.getExternalId())%>', '<%=HTML.javaScriptEncode(p.getName())%>', <%=p.isFileOnly()%>, '<%=rdt == null ? "" : rdt.getId()%>');
688          <%
689        }
690      }
691      for (PlatformVariant v : variants)
692      {
693        Platform p = v.getPlatform();
694        if ((!v.isRemoved() || v.equals(currentVariant)) && (!p.isRemoved() || p.equals(currentPlatform)))
695        {
696          RawDataType rdt = v.isFileOnly() ? null : v.getRawDataType();
697          %>
698          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()%>');
699          <%
700        }
701      }
702      %>
703      var frm = document.forms['rawbioassay'];
704      Platforms.populateList(frm.platform, platformId, variantId);
705    }
706    </script>
707  </base:head>
708  <base:body onload="init()">
709    <h1><%=title%> <base:help tabcontrol="settings" /></h1>
710    <form action="index.jsp?ID=<%=ID%>" method="post" name="rawbioassay">
711    <input type="hidden" name="cmd" value="UpdateItem">
712
713    <t:tabcontrol id="settings" 
714      subclass="content dialogtabcontrol"
715      position="bottom" active="<%=tabId%>" 
716      remember="<%=tabId == null && rawBioAssay != null%>" 
717      extensions="<%=invoker%>">
718    <t:tab id="info" title="Raw bioassay" validate="validateRawBioAssay()" helpid="rawbioassay.edit">
719      <table class="fullform input100">
720      <tr>
721        <th>Name</th>
722        <td><input class="text required" type="text" name="name" 
723          value="<%=HTML.encodeTags(name)%>" 
724          maxlength="<%=RawBioAssay.MAX_NAME_LENGTH%>"></td>
725        <td></td>
726      </tr>
727      <tr>
728        <th>Platform</th>
729        <td>
730          <select name="platform" onchange="platformOnChange()" class="required"
731            <%=deniedPlatform || hasDbSpots ? "disabled" : "" %>>
732          <%
733          if (deniedPlatform)
734          {
735            %>
736            <option value="-1">- denied -
737            <%
738          }
739          %>
740          </select>
741        </td>
742        <td></td>
743      </tr>
744      <tr>
745        <th>Raw data type</th>
746        <td>
747          <select name="rawdatatype" class="required"
748            <%=hasDbSpots ? "disabled" : "" %>>
749          <%
750          for (RawDataType rdt : RawDataTypes.getSortedRawDataTypes(new RawDataTypes.NameComparator()))
751          {
752            if (rdt.isStoredInDb())
753            {
754              String selected = rdt.equals(currentRawDataType) ? "selected" : "";
755              %>
756              <option value="<%=rdt.getId()%>" <%=selected%>><%=HTML.encodeTags(rdt.getName())%>
757              <%
758            }
759          }
760          %>
761          </select>
762        </td>
763        <td></td>
764      </tr>
765      <tr>
766        <th>Parent bioassay</th>
767        <td>
768          <base:select 
769            id="bioassay_id"
770            clazz="selectionlist"
771            required="false"
772            current="<%=currentBioAssay%>"
773            denied="<%=!readCurrentBioAssay%>"
774            recent="<%=recentBioAssays%>"
775            newitem="<%=rawBioAssay == null%>"
776            selectrecent="<%=currentExtract == null %>"
777            onselect="selectBioAssayOnClick()"
778            onchange="bioAssayOnChange()"
779          />
780        </td>
781        <td></td>
782      </tr>
783      <tr>
784        <th>Parent extract</th>
785        <td>
786          <base:select 
787            id="extract_id"
788            clazz="selectionlist"
789            required="false"
790            current="<%=currentExtract%>"
791            denied="<%=!readCurrentExtract%>"
792            recent="<%=recentExtracts%>"
793            newitem="<%=rawBioAssay == null%>"
794            selectrecent="false"
795            onselect="selectExtractOnClick()"
796          />
797        </td>
798        <td></td>
799      </tr>
800      <tr>
801        <th>Array design</th>
802        <td>
803          <base:select 
804            id="arraydesign_id"
805            clazz="selectionlist"
806            required="false"
807            current="<%=currentArrayDesign%>"
808            denied="<%=!readCurrentArrayDesign%>"
809            recent="<%=recentArrayDesigns%>"
810            defaultitems="<%=defaultArrayDesigns%>"
811            newitem="<%=rawBioAssay == null%>"
812            onselect="selectArrayDesignOnClick()"
813            onchange="arrayDesignOnChange()"
814          />
815        </td>
816        <td></td>
817      </tr>
818      <tr id="fiMethod" style="display: none;">
819        <th></th>
820        <td>
821        <select name="fiMethod">
822        <option value="">-auto- (array design decides)
823        <option value="COORDINATES">Coordinates
824        <option value="POSITION">Position
825        <option value="FEATURE_ID">Feature ID (*)
826        </select>
827        <br>
828        Select a method for feature identification. <br>
829        (*) The Feature ID method only works if the raw data is currently
830        connected to an array design which has Feature ID values.
831        </td>
832        <td></td>
833      </tr>
834      <tr>
835        <th>Protocol</th>
836        <td>
837          <base:select 
838            id="protocol_id"
839            clazz="selectionlist"
840            required="false"
841            current="<%=currentProtocol%>"
842            denied="<%=!readCurrentProtocol%>"
843            recent="<%=recentProtocols%>"
844            defaultitems="<%=defaultProtocols%>"
845            newitem="<%=rawBioAssay == null%>"
846            onselect="selectProtocolOnClick()"
847          />
848        </td>
849        <td></td>
850      </tr>
851      <tr>
852        <th>Software</th>
853        <td>
854          <base:select 
855            id="software_id"
856            clazz="selectionlist"
857            required="false"
858            current="<%=currentSoftware%>"
859            denied="<%=!readCurrentSoftware%>"
860            recent="<%=recentSoftware%>"
861            defaultitems="<%=defaultSoftware%>"
862            newitem="<%=rawBioAssay == null%>"
863            onselect="selectSoftwareOnClick()"
864          />
865        </td>
866        <td></td>
867      </tr>
868      <tr class="dynamic">
869        <th>Description</th>
870        <td>
871          <textarea class="text" rows="6" name="description" id="description"
872            ><%=HTML.encodeTags(rawBioAssay == null ? cc.getPropertyValue("description") : rawBioAssay.getDescription())%></textarea>
873        </td>
874        <td style="width: 20px;">
875          <base:zoom textarea="description" title="Description" />
876        </td>
877      </tr>
878      </table>
879    </t:tab>
880   
881    <t:tab id="datafiles" title="Data files" helpid="datafiles.edit" activate="loadDataFilesFrame()"><iframe 
882      name="datafiles" id="idDatafiles" src="../../common/datafiles/wait.jsp" 
883      class="absolutefull" style="width: 100%; height: 100%;"></iframe></t:tab>
884
885    <t:tab id="annotations" title="Annotations &amp; parameters" helpid="annotations.edit" activate="loadAnnotationsFrame()">
886      <jsp:include page="../../common/annotations/annotate_frameset.jsp">
887        <jsp:param name="item_type" value="<%=itemType.name()%>" />
888        <jsp:param name="item_id" value="<%=itemId%>" />
889        <jsp:param name="ID" value="<%=ID%>" />
890      </jsp:include>
891    </t:tab>
892   
893    <t:tab id="inheritedAnnotations" title="Inherited annotations" 
894      helpid="annotations.edit.inherited" activate="loadInheritedAnnotationsFrame()">
895      <jsp:include page="../../common/annotations/inherit_frameset.jsp">
896        <jsp:param name="item_type" value="<%=itemType.name()%>" />
897        <jsp:param name="item_id" value="<%=itemId%>" />
898        <jsp:param name="ID" value="<%=ID%>" />
899      </jsp:include>
900    </t:tab>
901    </t:tabcontrol>
902    </form>
903
904    <div class="legend">
905      <base:icon image="required.png" />= required information
906    </div>
907
908    <base:buttongroup subclass="dialogbuttons">
909      <base:button onclick="saveSettings()" title="Save" />
910      <base:button onclick="window.close()" title="Cancel" />
911    </base:buttongroup>
912  </base:body>
913  </base:page>
914  <%
915}
916finally
917{
918  if (dc != null) dc.close();
919}
920%>
Note: See TracBrowser for help on using the repository browser.