source: trunk/www/plugins/net/sf/basedb/plugins/jep_intensity_transformer.jsp @ 2978

Last change on this file since 2978 was 2978, checked in by Nicklas Nordborg, 17 years ago

Added session="false" to all jsp pages so we no longer generate unneeded cookies

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 9.3 KB
Line 
1<%-- $Id: jep_intensity_transformer.jsp 2978 2006-11-30 07:27:42Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) Authors contributing to this file.
4
5  This file is part of BASE - BioArray Software Environment.
6  Available at http://base.thep.lu.se/
7
8  BASE is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License
10  as published by the Free Software Foundation; either version 2
11  of the License, or (at your option) any later version.
12
13  BASE is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA  02111-1307, USA.
22  ------------------------------------------------------------------
23
24  @author Nicklas
25  @version 2.0
26--%>
27<%@ page session="false"
28  import="net.sf.basedb.core.SessionControl"
29  import="net.sf.basedb.core.DbControl"
30  import="net.sf.basedb.core.Item"
31  import="net.sf.basedb.core.ItemContext"
32  import="net.sf.basedb.core.RawDataType"
33  import="net.sf.basedb.core.BioAssaySet"
34  import="net.sf.basedb.core.Formula"
35  import="net.sf.basedb.core.Job"
36  import="net.sf.basedb.core.ItemQuery"
37  import="net.sf.basedb.core.ItemResultList"
38  import="net.sf.basedb.core.Include"
39  import="net.sf.basedb.core.PluginConfigurationRequest"
40  import="net.sf.basedb.core.RequestInformation"
41  import="net.sf.basedb.core.query.Orders"
42  import="net.sf.basedb.core.query.Hql"
43  import="net.sf.basedb.clients.web.Base"
44  import="net.sf.basedb.clients.web.WebException"
45  import="net.sf.basedb.clients.web.util.HTML"
46  import="net.sf.basedb.util.Values"
47  import="java.util.List"
48%>
49<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
50<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
51<%
52final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
53final String ID = sc.getId();
54final ItemContext cc = sc.getCurrentContext(Item.BIOASSAYSET);
55DbControl dc = null;
56try
57{
58  String errorMessage = (String)sc.getSessionSetting("plugin.configure.errors.message");
59  List<Throwable> errors = (List<Throwable>)sc.getSessionSetting("plugin.configure.errors.list");
60 
61  PluginConfigurationRequest pcRequest = (PluginConfigurationRequest)sc.getSessionSetting("plugin.configure.request");
62  RequestInformation info = pcRequest.getRequestInformation();
63 
64  dc = sc.newDbControl();
65  Job job = (Job)sc.getSessionSetting("plugin.configure.job");
66  dc.reattachItem(job);
67  BioAssaySet source = null;
68  source = (BioAssaySet)job.getParameterValue("source");
69  if (source == null && cc.getId() != 0) source = BioAssaySet.getById(dc, cc.getId());
70  if (source == null) throw new WebException("popup", "No current bioassay set", 
71    "Could not find any current bioassay set. Please select a bioassay set before trying again");
72
73  RawDataType rdt = source.getRawDataType();
74 
75  // Current parameter values
76  String childName = Values.getString((String)job.getParameterValue("childName"), source.getName());
77  String childDescription = (String)job.getParameterValue("childDescription");
78  String transformationName = (String)job.getParameterValue("transformationName");
79 
80  // Predefined formulas
81  ItemQuery<Formula> formulaQuery = Formula.getQuery(Formula.Type.INTENSITY_TRANSFORMATION, rdt);
82  formulaQuery.order(Orders.asc(Hql.property("name")));
83  formulaQuery.include(Include.MINE, Include.SHARED, Include.IN_PROJECT, Include.OTHERS);
84  ItemResultList<Formula> formulas = formulaQuery.list(dc);
85  %>
86  <base:page type="popup" title="Transform intensities">
87  <base:head styles="parameters.css">
88    <script language="JavaScript">
89    function hideErrorList()
90    {
91      Main.hide('errorlist');
92      Main.show('showerrorlist');
93    }
94    function showErrorList()
95    {
96      Main.show('errorlist');
97      Main.hide('showerrorlist');
98    }
99    function presetOnChange()
100    {
101      var frm = document.forms['transformation'];
102      var formulaId = frm.presets[frm.presets.selectedIndex].value;
103      frm['parameter:transformationName'].value = frm.presets[frm.presets.selectedIndex].text;
104      for (var ch = 1; ch <= <%=rdt.getChannels()%>; ch++)
105      {
106        frm['parameter:ch'+ch+'.expression'].value = formulas[formulaId+'.'+ch];
107      }
108      frm.presets.selectedIndex = 0;
109    }
110    function openExpressionBuilder(title, inputName)
111    {
112      Main.expressionBuilder('<%=ID%>', title, 'transformation', inputName, 'INTENSITY_TRANSFORMATION', '<%=rdt.getId()%>', <%=rdt.getChannels()%>, false);
113    }
114    function validate()
115    {
116      var frm = document.forms['transformation'];
117      for (var ch = 1; ch <= <%=rdt.getChannels()%>; ch++)
118      {
119        var inputName = 'parameter:ch'+ch+'.expression';
120        if (Main.trimString(frm[inputName].value) == '')
121        {
122          alert('You must enter an expression for channel ' + ch);
123          frm[inputName].focus();
124          return false;
125        }
126      }
127      return true;
128    }
129    function doNext()
130    {
131      if (validate())
132      {
133        var frm = document.forms['transformation'];
134        frm.submit();
135      }
136    }
137   
138    var formulas = new Array();
139    function init()
140    {
141      <%
142      for (Formula f : formulas)
143      {
144        for (int ch = 1; ch <= rdt.getChannels(); ++ch)
145        {
146          %>
147          formulas['<%=f.getId()%>.<%=ch%>'] = '<%=HTML.javaScriptEncode(f.getFormula(ch-1))%>';
148          <%
149        }
150      }
151      %>
152    }
153    </script>
154  </base:head>
155  <base:body onload="init()">
156    <form name="transformation" action="index.jsp" method="get" onsubmit="return false;">
157    <input type="hidden" name="ID" value="<%=ID%>">
158    <input type="hidden" name="cmd" value="SetParameters">
159    <input type="hidden" name="parameter:source" value="<%=source.getId()%>">
160   
161    <h3 class="docked">Transform intensities <base:help helpid="jepintensitytransformer.options"/></h3>
162    <div class="boxed">
163    <%
164    if (errorMessage != null || (errors != null && errors.size() > 0))
165    {
166      %>
167      <div id="errors" style="margin-bottom: 12px;" class="parameterhelp">
168        <div class="error" style="margin: 0px;">
169        <%=errorMessage %>
170        </div>
171        <%
172        if (errors != null && errors.size() > 0)
173        {
174          %>
175          <div id="showerrorlist" style="display: none;">
176            <base:icon image="bullet.gif" /><a href="javascript:showErrorList()">Show details</a>
177          </div>
178          <div id="errorlist">
179          <ol>
180          <%
181          for (Throwable t : errors)
182          {
183            %>
184            <li><%=t.getMessage()%><br>
185            <%
186          }
187          %>
188          </ol>
189          <base:icon image="bullet.gif" /><a href="javascript:hideErrorList()">Hide details</a>
190          </div>
191          <%
192        }
193        %>
194      </div>
195      <%
196    }
197    %>
198
199      <table class="form" width="100%">
200      <tr valign="top">
201        <td class="prompt">Source bioassay set</td>
202        <td><%=HTML.encodeTags(source.getName())%></td>
203      </tr>     
204      <tr>
205        <td class="prompt" colspan="2">Child bioassay set</td>
206      </tr>
207      <tr>
208        <td style="text-align: right">Name</td>
209        <td>
210          <input type="text" class="text required" size="50" maxlength="255" name="parameter:childName" 
211            value="<%=HTML.encodeTags(childName)%>"></td>
212      </tr>
213      <tr valign="top">
214        <td style="text-align: right">Description</td>
215        <td nowrap>
216          <textarea class="text" rows="4" cols="50" name="parameter:childDescription" wrap="virtual"
217            ><%=HTML.encodeTags(childDescription)%></textarea>
218          <a href="javascript:Main.zoom('Description', 'transformation', 'parameter:childDescription')"
219            title="Edit in larger window"><base:icon image="zoom.gif" /></a>
220        </td>
221      </tr>
222      <tr>
223        <td class="prompt">Transformation</td>
224        <td>
225        <%
226        if (formulas.size() > 0)
227        {
228          %>
229          <select name="presets" style="width: 32em;"
230            onchange="presetOnChange()" 
231            >
232            <option value="">- select from list or enter formula below -
233            <%
234            for (Formula f : formulas)
235            {
236              %>
237              <option value="<%=f.getId()%>" title="<%=HTML.encodeTags(f.getDescription())%>"
238                ><%=HTML.encodeTags(f.getName())%>
239              <%
240            }
241            %>
242          </select>
243          <%
244        }
245        %>
246        </td>
247      </tr>
248      <tr>
249        <td style="text-align: right">Name</td>
250        <td>
251          <input type="text" class="text" size="50" maxlength="255" name="parameter:transformationName" 
252            value="<%=HTML.encodeTags(transformationName)%>"></td>
253      </tr>
254     
255      <%
256      for (int ch = 1; ch <= rdt.getChannels(); ++ch)
257      {
258        String inputName = "parameter:ch" + ch + ".expression";
259        String value = (String)job.getParameterValue("ch"+ch+".expression");
260        if (value == null) value = (String)info.getParameter("ch"+ch+".expression").getParameterType().getDefaultValue();
261        %>
262        <tr valign="top">
263          <td style="text-align: right">Ch <%=ch%></td>
264          <td>
265            <table border="0" cellspacing="0" cellpadding="0">
266            <tr valign="top">
267            <td>
268              <input type="text" class="text required" name="<%=inputName%>"
269                size="50" 
270                value="<%=HTML.encodeTags(value)%>">&nbsp;
271            </td>
272            <td><base:button onclick="<%="openExpressionBuilder('Ch "+ch+" expression', '"+inputName+"')"%>" 
273              title=""
274              image="expression_builder.gif"
275              tooltip="A simple utility for building expressions" />
276            </td>
277            </tr>
278            </table>
279          </td>
280        </tr>
281        <%
282      }
283      %>
284      </table>
285    </div>
286    </form>
287 
288    <table align="center">
289    <tr>
290      <td width="50%"><base:button onclick="doNext();" title="Next" /></td>
291      <td width="50%"><base:button onclick="window.close();" title="Cancel" /></td>
292    </tr>
293    </table>
294  </base:body>
295  </base:page>
296  <%
297}
298finally
299{
300  if (dc != null) dc.close();
301}%>
Note: See TracBrowser for help on using the repository browser.