1 | <%-- $Id: edit_formula.jsp 6314 2013-09-02 12:47:53Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson |
---|
4 | Copyright (C) 2007 Nicklas Nordborg |
---|
5 | |
---|
6 | This file is part of BASE - BioArray Software Environment. |
---|
7 | Available at http://base.thep.lu.se/ |
---|
8 | |
---|
9 | BASE is free software; you can redistribute it and/or |
---|
10 | modify it under the terms of the GNU General Public License |
---|
11 | as published by the Free Software Foundation; either version 3 |
---|
12 | of the License, or (at your option) any later version. |
---|
13 | |
---|
14 | BASE is distributed in the hope that it will be useful, |
---|
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | GNU General Public License for more details. |
---|
18 | |
---|
19 | You should have received a copy of the GNU General Public License |
---|
20 | along with BASE. If not, see <http://www.gnu.org/licenses/>. |
---|
21 | ------------------------------------------------------------------ |
---|
22 | |
---|
23 | |
---|
24 | @author Nicklas |
---|
25 | @version 2.0 |
---|
26 | --%> |
---|
27 | <%@ page pageEncoding="UTF-8" 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.Type" |
---|
32 | import="net.sf.basedb.core.ItemContext" |
---|
33 | import="net.sf.basedb.core.Permission" |
---|
34 | import="net.sf.basedb.core.Formula" |
---|
35 | import="net.sf.basedb.core.IntensityTransform" |
---|
36 | import="net.sf.basedb.core.Coloring" |
---|
37 | import="net.sf.basedb.core.RawDataType" |
---|
38 | import="net.sf.basedb.core.RawDataTypes" |
---|
39 | import="net.sf.basedb.core.RawDataProperty" |
---|
40 | import="net.sf.basedb.core.Project" |
---|
41 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
42 | import="net.sf.basedb.util.Values" |
---|
43 | import="net.sf.basedb.clients.web.Base" |
---|
44 | import="net.sf.basedb.clients.web.util.HTML" |
---|
45 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
46 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
47 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
48 | import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
---|
49 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
50 | import="java.util.List" |
---|
51 | %> |
---|
52 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
53 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
54 | <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
---|
55 | <% |
---|
56 | final Item itemType = Item.FORMULA; |
---|
57 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
58 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
59 | final int itemId = cc.getId(); |
---|
60 | final String ID = sc.getId(); |
---|
61 | final float scale = Base.getScale(sc); |
---|
62 | final DbControl dc = sc.newDbControl(); |
---|
63 | try |
---|
64 | { |
---|
65 | String title = null; |
---|
66 | Formula formula = null; |
---|
67 | Formula.Type currentType = null; |
---|
68 | Type currentValueType = Type.FLOAT; |
---|
69 | Formula.Parser currentParser = null; |
---|
70 | Formula.AverageMethod currentAverageMethod = null; |
---|
71 | RawDataType currentRawDataType = null; |
---|
72 | RawDataType defaultRawDataType = null; |
---|
73 | IntensityTransform currentSourceIntensityTransform = null; |
---|
74 | IntensityTransform currentResultIntensityTransform = null; |
---|
75 | List<String> expressions = null; |
---|
76 | Coloring coloring = null; |
---|
77 | |
---|
78 | int activeProjectId = sc.getActiveProjectId(); |
---|
79 | if (activeProjectId > 0) |
---|
80 | { |
---|
81 | Project activeProject = Project.getById(dc, activeProjectId); |
---|
82 | defaultRawDataType = activeProject.getDefaultRawDataType(); |
---|
83 | } |
---|
84 | if (itemId == 0) |
---|
85 | { |
---|
86 | title = "Create formula"; |
---|
87 | cc.removeObject("item"); |
---|
88 | String recentType = cc.getRecent("FormulaType", 0); |
---|
89 | String filterType = cc.getPropertyValue("type"); |
---|
90 | if (filterType != null) currentType = Formula.Type.fromValue(Values.getInt(filterType)); |
---|
91 | if (currentType == null && recentType != null) currentType = Formula.Type.valueOf(recentType); |
---|
92 | if (currentType == null) currentType = Formula.Type.COLUMN_EXPRESSION; |
---|
93 | currentParser = Formula.Parser.fromValue(Values.getInt(cc.getPropertyValue("parser"), |
---|
94 | Formula.Parser.JEP.getValue())); |
---|
95 | currentAverageMethod = Formula.AverageMethod.fromValue(Values.getInt(cc.getPropertyValue("averageMethod"), |
---|
96 | Formula.AverageMethod.ARITHMETIC_MEAN.getValue())); |
---|
97 | currentRawDataType = RawDataTypes.getRawDataType(cc.getPropertyValue("rawDataType")); |
---|
98 | if (currentRawDataType == null) |
---|
99 | { |
---|
100 | currentRawDataType = RawDataTypes.getRawDataType(cc.getRecent("RawDataType", 0)); |
---|
101 | } |
---|
102 | if (cc.getPropertyValue("sourceIntensityTransform") != null) |
---|
103 | { |
---|
104 | currentSourceIntensityTransform = IntensityTransform.fromValue(Values.getInt(cc.getPropertyValue("sourceIntensityTransform"))); |
---|
105 | } |
---|
106 | if (cc.getPropertyValue("resultIntensityTransform") != null) |
---|
107 | { |
---|
108 | currentResultIntensityTransform = IntensityTransform.fromValue(Values.getInt(cc.getPropertyValue("resultIntensityTransform"))); |
---|
109 | } |
---|
110 | coloring = new Coloring(); |
---|
111 | coloring.setUsingColors(Values.getBoolean(cc.getPropertyValue("coloring.usingColors"))); |
---|
112 | coloring.setLogarithmic(Values.getBoolean(cc.getPropertyValue("coloring.logarithmic"))); |
---|
113 | coloring.setMinValue(Values.getFloat(cc.getPropertyValue("coloring.minValue"), null)); |
---|
114 | coloring.setMidValue(Values.getFloat(cc.getPropertyValue("coloring.midValue"), null)); |
---|
115 | coloring.setMaxValue(Values.getFloat(cc.getPropertyValue("coloring.maxValue"), null)); |
---|
116 | |
---|
117 | currentRawDataType = currentRawDataType != null ? currentRawDataType : defaultRawDataType; |
---|
118 | } |
---|
119 | else |
---|
120 | { |
---|
121 | formula = Formula.getById(dc, itemId); |
---|
122 | formula.checkPermission(Permission.WRITE); |
---|
123 | currentParser = formula.getParser(); |
---|
124 | currentAverageMethod = formula.getAverageMethod(); |
---|
125 | currentType = formula.getFormulaType(); |
---|
126 | currentValueType = formula.getValueType(); |
---|
127 | currentRawDataType = formula.getRawDataType(); |
---|
128 | currentSourceIntensityTransform = formula.getSourceIntensityTransform(); |
---|
129 | currentResultIntensityTransform = formula.getResultIntensityTransform(); |
---|
130 | expressions = formula.getFormulas(); |
---|
131 | coloring = formula.getColoring(); |
---|
132 | cc.setObject("item", formula); |
---|
133 | title = "Edit formula -- " + HTML.encodeTags(formula.getName()); |
---|
134 | } |
---|
135 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), formula); |
---|
136 | ExtensionsInvoker invoker = EditUtil.useEditExtensions(jspContext); |
---|
137 | %> |
---|
138 | <base:page type="popup" title="<%=title%>" id="edit-page"> |
---|
139 | <base:head scripts="tabcontrol-2.js,~formulas.js" styles="tabcontrol.css"> |
---|
140 | <ext:scripts context="<%=jspContext%>" /> |
---|
141 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
142 | </base:head> |
---|
143 | <base:body > |
---|
144 | <h1><%=title%> <base:help tabcontrol="settings" /></h1> |
---|
145 | <form action="index.jsp?ID=<%=ID%>" method="post" name="formula"> |
---|
146 | <input type="hidden" name="cmd" value="UpdateItem"> |
---|
147 | |
---|
148 | <t:tabcontrol id="settings" |
---|
149 | subclass="content dialogtabcontrol" |
---|
150 | position="bottom" remember="<%=formula != null%>" |
---|
151 | extensions="<%=invoker%>"> |
---|
152 | <t:tab id="info" title="Formula" helpid="formula.edit"> |
---|
153 | <table class="fullform input100"> |
---|
154 | <tr> |
---|
155 | <th>Name</th> |
---|
156 | <td><input class="text required auto-init" data-auto-init="<%=formula == null ? "focus-select" : "focus" %>" |
---|
157 | type="text" name="name" |
---|
158 | value="<%=HTML.encodeTags(formula == null ? Values.getString(cc.getPropertyValue("name"), "New formula") : formula.getName())%>" |
---|
159 | maxlength="<%=Formula.MAX_NAME_LENGTH%>"></td> |
---|
160 | <td></td> |
---|
161 | </tr> |
---|
162 | <tr> |
---|
163 | <th>Type</th> |
---|
164 | <td> |
---|
165 | <select name="type" class="required" id="formulaType" style="width: 15em;"> |
---|
166 | <% |
---|
167 | for (Formula.Type type : Formula.Type.values()) |
---|
168 | { |
---|
169 | String selected = type == currentType ? "selected" : ""; |
---|
170 | Type valueType = type.getValueType(); |
---|
171 | %> |
---|
172 | <option value="<%=type.name()%>" <%=selected%> |
---|
173 | data-supports-colors="<%=type.canUseColoring() ? 1 : 0 %>" |
---|
174 | data-supports-average="<%=type.supportsAverage() ? 1 : 0 %>" |
---|
175 | data-value-type="<%=valueType == null ? "" : valueType.name() %>" |
---|
176 | ><%=HTML.encodeTags(type.toString())%> |
---|
177 | <% |
---|
178 | } |
---|
179 | %> |
---|
180 | </select> |
---|
181 | </td> |
---|
182 | <td></td> |
---|
183 | </tr> |
---|
184 | <tr> |
---|
185 | <th>Parser</th> |
---|
186 | <td> |
---|
187 | <select name="parser" class="required" style="width: 15em;"> |
---|
188 | <% |
---|
189 | for (Formula.Parser parser : Formula.Parser.values()) |
---|
190 | { |
---|
191 | String selected = parser == currentParser ? "selected" : ""; |
---|
192 | %> |
---|
193 | <option value="<%=parser.name()%>" <%=selected%>><%=HTML.encodeTags(parser.toString())%> |
---|
194 | <% |
---|
195 | } |
---|
196 | %> |
---|
197 | </select> |
---|
198 | </td> |
---|
199 | <td></td> |
---|
200 | </tr> |
---|
201 | <tr> |
---|
202 | <th>Raw data type</th> |
---|
203 | <td> |
---|
204 | <select name="rawdatatype" id="rawdatatype" style="width: 15em;"> |
---|
205 | <option value="">- none - |
---|
206 | <% |
---|
207 | for (RawDataType rdt : RawDataTypes.getSortedRawDataTypes(new RawDataTypes.NameComparator())) |
---|
208 | { |
---|
209 | String selected = rdt == currentRawDataType ? "selected" : ""; |
---|
210 | %> |
---|
211 | <option value="<%=rdt.getId()%>" <%=selected%> |
---|
212 | data-channels="<%=rdt.getChannels()%>" |
---|
213 | ><%=HTML.encodeTags(rdt.getName())%> |
---|
214 | <% |
---|
215 | } |
---|
216 | %> |
---|
217 | </select> |
---|
218 | </td> |
---|
219 | <td></td> |
---|
220 | </tr> |
---|
221 | <tr> |
---|
222 | <th>Channels</th> |
---|
223 | <td><input <%=currentRawDataType != null ? "class=\"text disabled\" disabled" : "class=\"text required\""%> |
---|
224 | type="text" name="channels" id="channels" |
---|
225 | style="width:15em;" |
---|
226 | value="<%=formula == null ? (currentRawDataType == null ? Values.getInt(cc.getPropertyValue("channels")) : currentRawDataType.getChannels()) : formula.getChannels()%>" |
---|
227 | maxlength="10" |
---|
228 | ></td> |
---|
229 | <td></td> |
---|
230 | </tr> |
---|
231 | <tr class="big"> |
---|
232 | <th>Expressions</th> |
---|
233 | <td> |
---|
234 | <table> |
---|
235 | <tr> |
---|
236 | <td> |
---|
237 | <select name="expressions" id="expressions" size="3" style="width: 26em;" |
---|
238 | multiple class="required"> |
---|
239 | <% |
---|
240 | if (expressions != null) |
---|
241 | { |
---|
242 | for (String expression : expressions) |
---|
243 | { |
---|
244 | %> |
---|
245 | <option><%=HTML.encodeTags(expression)%> |
---|
246 | <% |
---|
247 | } |
---|
248 | } |
---|
249 | %> |
---|
250 | </select> |
---|
251 | </td> |
---|
252 | <td><base:button id="btnRemoveExpression" title="Remove" /></td> |
---|
253 | <td></td> |
---|
254 | </tr> |
---|
255 | <tr> |
---|
256 | <td> |
---|
257 | <input type="text" name="expression" id="expression" class="text" style="width: 26em;" |
---|
258 | maxlength="<%=Formula.MAX_FORMULA_LENGTH%>"> |
---|
259 | </td> |
---|
260 | <td> |
---|
261 | <base:button id="btnAddExpression" title="Add" /> |
---|
262 | </td> |
---|
263 | <td> |
---|
264 | <base:button |
---|
265 | id="btnExpressionBuilder" |
---|
266 | image="expression_builder.png" |
---|
267 | title="Expression builder…" /> |
---|
268 | </td> |
---|
269 | </table> |
---|
270 | </td> |
---|
271 | <td></td> |
---|
272 | </tr> |
---|
273 | <tr> |
---|
274 | <th>Value type</th> |
---|
275 | <td> |
---|
276 | <select name="valueType" style="width: 15em;"> |
---|
277 | <option value="">- unknown - |
---|
278 | <% |
---|
279 | for (Type type : Type.values()) |
---|
280 | { |
---|
281 | String selected = type == currentValueType ? "selected" : ""; |
---|
282 | %> |
---|
283 | <option value="<%=type.name()%>" <%=selected%>><%=HTML.encodeTags(type.toString())%> |
---|
284 | <% |
---|
285 | } |
---|
286 | %> |
---|
287 | </select> |
---|
288 | </td> |
---|
289 | <td></td> |
---|
290 | </tr> |
---|
291 | <tr> |
---|
292 | <th>Avg. method</th> |
---|
293 | <td> |
---|
294 | <select name="averageMethod" class="required" style="width: 15em;"> |
---|
295 | <% |
---|
296 | for (Formula.AverageMethod method : Formula.AverageMethod.values()) |
---|
297 | { |
---|
298 | String selected = method == currentAverageMethod ? "selected" : ""; |
---|
299 | %> |
---|
300 | <option value="<%=method.name()%>" <%=selected%>><%=HTML.encodeTags(method.toString())%> |
---|
301 | <% |
---|
302 | } |
---|
303 | %> |
---|
304 | </select> |
---|
305 | </td> |
---|
306 | <td></td> |
---|
307 | </tr> |
---|
308 | <tr> |
---|
309 | <th>Intensity<br>transformation</th> |
---|
310 | <td> |
---|
311 | <b>Source</b> |
---|
312 | <select name="sourceIntensityTransform" style="width: 15em;"> |
---|
313 | <option value="">- any - |
---|
314 | <% |
---|
315 | for (IntensityTransform t : IntensityTransform.values()) |
---|
316 | { |
---|
317 | String selected = t == currentSourceIntensityTransform ? "selected" : ""; |
---|
318 | %> |
---|
319 | <option value="<%=t.name()%>" <%=selected%>><%=HTML.encodeTags(t.toString())%> |
---|
320 | <% |
---|
321 | } |
---|
322 | %> |
---|
323 | </select> |
---|
324 | <b>Result</b> |
---|
325 | <select name="resultIntensityTransform" style="width: 15em;"> |
---|
326 | <option value="">- any - |
---|
327 | <% |
---|
328 | for (IntensityTransform t : IntensityTransform.values()) |
---|
329 | { |
---|
330 | String selected = t == currentResultIntensityTransform ? "selected" : ""; |
---|
331 | %> |
---|
332 | <option value="<%=t.name()%>" <%=selected%>><%=HTML.encodeTags(t.toString())%> |
---|
333 | <% |
---|
334 | } |
---|
335 | %> |
---|
336 | </select> |
---|
337 | </td> |
---|
338 | <td></td> |
---|
339 | </tr> |
---|
340 | <tr> |
---|
341 | <th></th> |
---|
342 | <td> |
---|
343 | <input type="checkbox" name="use_colors" id="useColors" value="1" |
---|
344 | <%=coloring.isUsingColors() ? "checked" : "" %>> |
---|
345 | <label for="useColors"><b>Use colors</b></label> |
---|
346 | |
---|
347 | <input type="checkbox" name="logarithmic" id="logarithmic" value="1" |
---|
348 | <%=coloring.isLogarithmic() ? "checked" : "" %>> |
---|
349 | <label for="logarithmic"><b>Logarithmic</b></label> |
---|
350 | </td> |
---|
351 | <td></td> |
---|
352 | </tr> |
---|
353 | <tr> |
---|
354 | <th class="subprompt"></th> |
---|
355 | <td> |
---|
356 | <b>Min value</b> |
---|
357 | <input type="text" class="text" name="min_value" id="min_value" style="width: 6em;" |
---|
358 | value="<%=Values.formatNumber(coloring.getMinValue(), -1)%>" |
---|
359 | maxlength="6"> |
---|
360 | <b>Mid value</b> |
---|
361 | <input type="text" class="text" name="mid_value" id="mid_value" style="width: 6em;" |
---|
362 | value="<%=Values.formatNumber(coloring.getMidValue(), -1)%>" |
---|
363 | maxlength="6"> |
---|
364 | <b>Max value</b> |
---|
365 | <input type="text" class="text" name="max_value" id="max_value" style="width: 6em;" |
---|
366 | value="<%=Values.formatNumber(coloring.getMaxValue(), -1)%>" |
---|
367 | maxlength="6"> |
---|
368 | </td> |
---|
369 | <td></td> |
---|
370 | </tr> |
---|
371 | <tr class="dynamic"> |
---|
372 | <th>Description</th> |
---|
373 | <td> |
---|
374 | <textarea class="text" rows="4" name="description" id="description" |
---|
375 | ><%=HTML.encodeTags(formula == null ? cc.getPropertyValue("description") : formula.getDescription())%></textarea> |
---|
376 | </td> |
---|
377 | <td style="width: 20px;"> |
---|
378 | <base:zoom textarea="description" title="Description" /> |
---|
379 | </td> |
---|
380 | </tr> |
---|
381 | </table> |
---|
382 | </t:tab> |
---|
383 | </t:tabcontrol> |
---|
384 | </form> |
---|
385 | |
---|
386 | <div class="legend"> |
---|
387 | <base:icon image="required.png" />= required information |
---|
388 | </div> |
---|
389 | |
---|
390 | <base:buttongroup subclass="dialogbuttons"> |
---|
391 | <base:button id="btnSave" title="Save" /> |
---|
392 | <base:button id="close" title="Cancel" /> |
---|
393 | </base:buttongroup> |
---|
394 | </base:body> |
---|
395 | </base:page> |
---|
396 | <% |
---|
397 | } |
---|
398 | finally |
---|
399 | { |
---|
400 | if (dc != null) dc.close(); |
---|
401 | } |
---|
402 | %> |
---|