1 | <%@ page |
---|
2 | pageEncoding="UTF-8" |
---|
3 | session="false" |
---|
4 | import="net.sf.basedb.core.User" |
---|
5 | import="net.sf.basedb.core.DbControl" |
---|
6 | import="net.sf.basedb.core.SessionControl" |
---|
7 | import="net.sf.basedb.core.Application" |
---|
8 | import="net.sf.basedb.clients.web.Base" |
---|
9 | import="net.sf.basedb.clients.web.util.HTML" |
---|
10 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
11 | %> |
---|
12 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
13 | <%@ taglib prefix="p" uri="/WEB-INF/path.tld" %> |
---|
14 | <% |
---|
15 | final SessionControl sc = Base.getExistingSessionControl(request, true); |
---|
16 | final String ID = sc.getId(); |
---|
17 | final float scale = Base.getScale(sc); |
---|
18 | final String home = ExtensionsControl.getHomeUrl("net.sf.basedb.reggie"); |
---|
19 | DbControl dc = null; |
---|
20 | try |
---|
21 | { |
---|
22 | dc = sc.newDbControl(); |
---|
23 | final User user = User.getById(dc, sc.getLoggedInUserId()); |
---|
24 | %> |
---|
25 | <base:page type="default" > |
---|
26 | <base:head scripts="ajax.js" styles="path.css"> |
---|
27 | <link rel="stylesheet" type="text/css" href="../css/reggie.css"> |
---|
28 | <script language="JavaScript" src="../reggie.js" type="text/javascript" charset="UTF-8"></script> |
---|
29 | |
---|
30 | <script language="JavaScript"> |
---|
31 | var debug = true; |
---|
32 | var currentStep = 1; |
---|
33 | |
---|
34 | var pdfIsValid = false; |
---|
35 | var mrnaDateIsValid = false; |
---|
36 | |
---|
37 | function init() |
---|
38 | { |
---|
39 | var frm = document.forms['reggie']; |
---|
40 | var bioplates = getMRnaBioPlates(); |
---|
41 | |
---|
42 | // Load existing mRNA plates not yet registered |
---|
43 | var plates = frm.bioplate; |
---|
44 | if (bioplates != null && bioplates.length > 0) |
---|
45 | { |
---|
46 | for (var i=0; i < bioplates.length; i++) |
---|
47 | { |
---|
48 | var bioplate = bioplates[i]; |
---|
49 | var option = new Option(bioplate.name, bioplate.id); |
---|
50 | plates.options[plates.length] = option; |
---|
51 | } |
---|
52 | bioplateIsValid = true; |
---|
53 | setInputStatus('bioplate', '', 'valid'); |
---|
54 | } |
---|
55 | else |
---|
56 | { |
---|
57 | var msg = 'No mRNA bioplates available for processing.'; |
---|
58 | setFatalError(msg); |
---|
59 | return; |
---|
60 | } |
---|
61 | |
---|
62 | // Load mRNA protocols |
---|
63 | var mrnaProtocols = getProtocols('MRNA_PROTOCOL'); |
---|
64 | for (var i = 0; i < mrnaProtocols.length; i++) |
---|
65 | { |
---|
66 | var protocol = mrnaProtocols[i]; |
---|
67 | frm.mrnaProtocol[frm.mrnaProtocol.length] = new Option(protocol.name, protocol.id, protocol.isDefault); |
---|
68 | setInputStatus('mrnaProtocol', '', 'valid'); |
---|
69 | } |
---|
70 | if (frm.mrnaProtocol.length == 0) |
---|
71 | { |
---|
72 | frm.mrnaProtocol[0] = new Option('- none -', ''); |
---|
73 | } |
---|
74 | |
---|
75 | // All is ok |
---|
76 | frm['pdf.path'].focus(); |
---|
77 | Main.show('gocreate'); |
---|
78 | } |
---|
79 | |
---|
80 | function getMRnaBioPlates() |
---|
81 | { |
---|
82 | var frm = document.forms['reggie']; |
---|
83 | |
---|
84 | var request = Ajax.getXmlHttpRequest(); |
---|
85 | try |
---|
86 | { |
---|
87 | showLoadingAnimation('Loading histology work lists...'); |
---|
88 | var url = '../MRna.servlet?ID=<%=ID%>&cmd=GetUnprocessedPlates&plateType=MRNA'; |
---|
89 | request.open("GET", url, false); |
---|
90 | request.send(null); |
---|
91 | } |
---|
92 | finally |
---|
93 | { |
---|
94 | hideLoadingAnimation(); |
---|
95 | } |
---|
96 | |
---|
97 | if (debug) Main.debug(request.responseText); |
---|
98 | var response = JSON.parse(request.responseText); |
---|
99 | if (response.status != 'ok') |
---|
100 | { |
---|
101 | setFatalError(response.message); |
---|
102 | return false; |
---|
103 | } |
---|
104 | return response.bioplates; |
---|
105 | } |
---|
106 | |
---|
107 | function getProtocols(subtype) |
---|
108 | { |
---|
109 | var request = Ajax.getXmlHttpRequest(); |
---|
110 | try |
---|
111 | { |
---|
112 | showLoadingAnimation('Loading ' + subtype + ' protocols...'); |
---|
113 | var url = '../Protocol.servlet?ID=<%=ID%>&cmd=GetProtocols&subtype='+subtype; |
---|
114 | request.open("GET", url, false); |
---|
115 | request.send(null); |
---|
116 | } |
---|
117 | finally |
---|
118 | { |
---|
119 | hideLoadingAnimation(); |
---|
120 | } |
---|
121 | |
---|
122 | if (debug) Main.debug(request.responseText); |
---|
123 | var response = JSON.parse(request.responseText); |
---|
124 | if (response.status != 'ok') |
---|
125 | { |
---|
126 | setFatalError(response.message); |
---|
127 | return false; |
---|
128 | } |
---|
129 | return response.protocols; |
---|
130 | } |
---|
131 | |
---|
132 | |
---|
133 | function browseOnClick(extension) |
---|
134 | { |
---|
135 | var frm = document.forms['reggie']; |
---|
136 | if (frm[extension+'.path'].disabled) return; |
---|
137 | |
---|
138 | var url = getRoot() + 'filemanager/index.jsp?ID=<%=ID%>&cmd=SelectOne&callback=setFileCallback'; |
---|
139 | url += '&resetTemporary=1&tmpfilter:STRING:name='+escape('%.' + extension.substr(0, 3)); |
---|
140 | lastExtension = extension; |
---|
141 | Main.openPopup(url, 'SelectFile', 1000, 700); |
---|
142 | } |
---|
143 | |
---|
144 | function setFileCallback(id, path) |
---|
145 | { |
---|
146 | var frm = document.forms['reggie']; |
---|
147 | frm[lastExtension+'.id'].value = id; |
---|
148 | frm[lastExtension+'.path'].value = path; |
---|
149 | setInputStatus(lastExtension, '', 'valid'); |
---|
150 | if (lastExtension == 'pdf') |
---|
151 | { |
---|
152 | pdfIsValid = true; |
---|
153 | } |
---|
154 | } |
---|
155 | |
---|
156 | function pdfFileOnChange() |
---|
157 | { |
---|
158 | var frm = document.forms['reggie']; |
---|
159 | if (!frm['pdf.id'].value) |
---|
160 | { |
---|
161 | pdfIsValid = false; |
---|
162 | if (!frm['pdf.path'].value) |
---|
163 | { |
---|
164 | setInputStatus('pdf', 'Missing', 'invalid'); |
---|
165 | } |
---|
166 | else |
---|
167 | { |
---|
168 | setInputStatus('pdf', 'Use the Browse button to select a file', 'invalid'); |
---|
169 | } |
---|
170 | } |
---|
171 | } |
---|
172 | |
---|
173 | function mrnaDateOnChange() |
---|
174 | { |
---|
175 | var frm = document.forms['reggie']; |
---|
176 | mrnaDateIsValid = false; |
---|
177 | setInputStatus('mrnaDate', '', ''); |
---|
178 | |
---|
179 | var mrnaDate = frm.mrnaDate.value; |
---|
180 | |
---|
181 | if (mrnaDate == '') |
---|
182 | { |
---|
183 | setInputStatus('mrnaDate', 'Missing', 'invalid'); |
---|
184 | return; |
---|
185 | } |
---|
186 | |
---|
187 | // Auto-fill the date if it's only given with 4(MMdd) or 6(yyMMdd) digits. |
---|
188 | mrnaDate = autoFillDate(mrnaDate); |
---|
189 | frm.mrnaDate.value = mrnaDate; |
---|
190 | |
---|
191 | if (!Dates.isDate(mrnaDate, 'yyyyMMdd')) |
---|
192 | { |
---|
193 | setInputStatus('mrnaDate', 'Not a valid date', 'invalid'); |
---|
194 | return; |
---|
195 | } |
---|
196 | |
---|
197 | setInputStatus('mrnaDate', '', 'valid'); |
---|
198 | mrnaDateIsValid = true; |
---|
199 | } |
---|
200 | |
---|
201 | function goRegister() |
---|
202 | { |
---|
203 | if (!mrnaDateIsValid || !pdfIsValid) return; |
---|
204 | |
---|
205 | var frm = document.forms['reggie']; |
---|
206 | var pdfId = parseInt(frm['pdf.id'].value, 10); |
---|
207 | |
---|
208 | Main.hide('goimport'); |
---|
209 | |
---|
210 | frm['pdf.path'].disabled = true; |
---|
211 | Main.addClass(document.getElementById('btnPdf'), 'disabled'); |
---|
212 | frm.mrnaOperator.disabled = true; |
---|
213 | frm.mrnaProtocol.disabled = true; |
---|
214 | frm.mrnaDate.disabled = true; |
---|
215 | frm.bioplate.disabled = true; |
---|
216 | frm.comments.disabled = true; |
---|
217 | |
---|
218 | var submitInfo = {}; |
---|
219 | submitInfo.bioplate = parseInt(frm.bioplate.value, 10); |
---|
220 | submitInfo.mrnaProtocol = parseInt(frm.mrnaProtocol.value, 10); |
---|
221 | submitInfo.pdf = pdfId; |
---|
222 | submitInfo.mrnaDate = frm.mrnaDate.value; |
---|
223 | submitInfo.mrnaOperator = frm.mrnaOperator.value; |
---|
224 | submitInfo.comments = frm.comments.value; |
---|
225 | |
---|
226 | if (debug) Main.debug(JSON.stringify(submitInfo)); |
---|
227 | var url = '../MRna.servlet?ID=<%=ID%>&cmd=ImportMRnaQCResults'; |
---|
228 | |
---|
229 | var request = Ajax.getXmlHttpRequest(); |
---|
230 | try |
---|
231 | { |
---|
232 | showLoadingAnimation('Importing...'); |
---|
233 | request.open("POST", url, false); |
---|
234 | request.send(JSON.stringify(submitInfo)); |
---|
235 | } |
---|
236 | finally |
---|
237 | { |
---|
238 | hideLoadingAnimation(); |
---|
239 | } |
---|
240 | |
---|
241 | if (debug) Main.debug(request.responseText); |
---|
242 | var response = JSON.parse(request.responseText); |
---|
243 | |
---|
244 | if (response.messages && response.messages.length > 0) |
---|
245 | { |
---|
246 | var msg = '<ul>'; |
---|
247 | for (var i = 0; i < response.messages.length; i++) |
---|
248 | { |
---|
249 | var msgLine = response.messages[i]; |
---|
250 | if (msgLine.indexOf('[Warning]') >= 0) |
---|
251 | { |
---|
252 | msg += '<li class="warning">' + msgLine.replace('[Warning]', ''); |
---|
253 | } |
---|
254 | else |
---|
255 | { |
---|
256 | msg += '<li>' + msgLine; |
---|
257 | } |
---|
258 | } |
---|
259 | msg += '</ul>'; |
---|
260 | setInnerHTML('messages', msg); |
---|
261 | Main.show('messages'); |
---|
262 | } |
---|
263 | |
---|
264 | if (response.status != 'ok') |
---|
265 | { |
---|
266 | Main.addClass(document.getElementById('messages'), 'failure'); |
---|
267 | setFatalError(response.message); |
---|
268 | return false; |
---|
269 | } |
---|
270 | |
---|
271 | Main.show('done'); |
---|
272 | Main.show('gorestart'); |
---|
273 | |
---|
274 | } |
---|
275 | |
---|
276 | |
---|
277 | </script> |
---|
278 | |
---|
279 | </base:head> |
---|
280 | <base:body onload="init()"> |
---|
281 | |
---|
282 | <p:path><p:pathelement |
---|
283 | title="Reggie" href="<%="../index.jsp?ID="+ID%>" |
---|
284 | /><p:pathelement title="Lab tracking protocol for mRNA and cDNA preparation" |
---|
285 | /></p:path> |
---|
286 | |
---|
287 | <div class="content"> |
---|
288 | <% |
---|
289 | if (sc.getActiveProjectId() == 0) |
---|
290 | { |
---|
291 | %> |
---|
292 | <div class="messagecontainer note" style="width: 950px; margin-left: 20px; margin-bottom: 20px; margin-right: 0px; font-weight: bold; color: #cc0000;"> |
---|
293 | No project has been selected. You may proceed with the registration but |
---|
294 | created items will not be shared. |
---|
295 | </div> |
---|
296 | <% |
---|
297 | } |
---|
298 | %> |
---|
299 | |
---|
300 | <form name="reggie" onsubmit="return false;"> |
---|
301 | <input type="hidden" name="pdf.id" value=""> |
---|
302 | |
---|
303 | <table class="stepform"> |
---|
304 | <tr> |
---|
305 | <td rowspan="3" class="stepno">1</td> |
---|
306 | <td class="steptitle">Select mRNA bioplate</td> |
---|
307 | </tr> |
---|
308 | <tr> |
---|
309 | <td class="stepfields"> |
---|
310 | <table> |
---|
311 | <tr valign="top"> |
---|
312 | <td class="prompt">mRNA bioplate</td> |
---|
313 | <td class="input"><select class="required" style="width:90%" |
---|
314 | name="bioplate" id="bioplate"></select> |
---|
315 | </td> |
---|
316 | <td class="status" id="bioplate.status"></td> |
---|
317 | <td class="help"><span id="bioplate.message" class="message" style="display: none;"></span> |
---|
318 | Select an existing mRNA bioplate. The list contain all mRNA bioplates that |
---|
319 | has not yet been processed (determined by the absence of a 'creation' date). |
---|
320 | </td> |
---|
321 | </tr> |
---|
322 | <tr valign="top"> |
---|
323 | <td class="prompt">PDF file</td> |
---|
324 | <td class="input"> |
---|
325 | <table> |
---|
326 | <tr> |
---|
327 | <td><input class="text required" type="text" |
---|
328 | name="pdf.path" value="" |
---|
329 | size="50" onkeypress="doOnEnter(event, function(){document.getElementById('btnPdf').click()})" |
---|
330 | onblur="pdfFileOnChange()" |
---|
331 | ></td> |
---|
332 | <td style="padding-left: 4px;"><base:button |
---|
333 | title="Browse…" |
---|
334 | onclick="browseOnClick('pdf')" |
---|
335 | id="btnPdf" |
---|
336 | /> |
---|
337 | </td> |
---|
338 | </tr> |
---|
339 | </table> |
---|
340 | </td> |
---|
341 | <td class="status" id="pdf.status"></td> |
---|
342 | <td class="help"><span id="pdf.message" class="message" style="display: none;"></span> |
---|
343 | Select the PDF file that contains a printout with diagrams and other |
---|
344 | useful documentation. |
---|
345 | </td> |
---|
346 | </tr> |
---|
347 | <tr valign="top"> |
---|
348 | <td class="prompt">Date</td> |
---|
349 | <td class="input"> |
---|
350 | <input type="text" class="required" name="mrnaDate" value="" size="12" maxlength="10" |
---|
351 | onblur="mrnaDateOnChange()" onkeypress="focusOnEnter(event, 'mrnaProtocol')"> |
---|
352 | </td> |
---|
353 | <td class="status" id="mrnaDate.status"></td> |
---|
354 | <td class="help"> |
---|
355 | <span id="mrnaDate.message" class="message" style="display: none;"></span>(YYYYMMDD or MMDD) |
---|
356 | </td> |
---|
357 | </tr> |
---|
358 | <tr valign="top"> |
---|
359 | <td class="prompt">Protocol</td> |
---|
360 | <td class="input"><select style="width:90%" name="mrnaProtocol" id="mrnaProtocol" |
---|
361 | onkeypress="focusOnEnter(event, 'mrnaOperator')"></select></td> |
---|
362 | <td class="status" id="mrnaProtocol.status"></td> |
---|
363 | <td class="help"><span id="mrnaProtocol.message" class="message" style="display: none;"></span> |
---|
364 | Select the protocol which was used in the mRNA step. |
---|
365 | </td> |
---|
366 | </tr> |
---|
367 | <tr valign="top"> |
---|
368 | <td class="prompt">Operator</td> |
---|
369 | <td class="input"> |
---|
370 | <input type="text" name="mrnaOperator" value="<%=HTML.encodeTags(user.getName()) %>" |
---|
371 | size="50" maxlength="255" onkeypress="focusOnEnter(event, 'comments')"> |
---|
372 | </td> |
---|
373 | <td class="status" id="mrnaOperator.status"></td> |
---|
374 | <td class="help"> |
---|
375 | <span id="mrnaOperator.message" class="message" style="display: none;"></span> |
---|
376 | </td> |
---|
377 | </tr> |
---|
378 | <tr valign="top"> |
---|
379 | <td class="prompt">Comments</td> |
---|
380 | <td class="input"><textarea rows="4" cols="50" name="comments" value=""></textarea></td> |
---|
381 | <td class="status"></td> |
---|
382 | <td class="help">Comments about the mRNA processing.</td> |
---|
383 | </tr> |
---|
384 | </table> |
---|
385 | </td> |
---|
386 | </tr> |
---|
387 | </table> |
---|
388 | |
---|
389 | <div class="loading" id="loading" style="display: none;"><table><tr><td><img src="images/loading.gif"></td><td id="loading.msg">Please wait...</td></tr></table></div> |
---|
390 | |
---|
391 | <div class="messagecontainer error" id="errorMessage" style="display: none; width: 950px; margin-left: 20px; margin-bottom: 0px;"></div> |
---|
392 | |
---|
393 | <div id="messages" class="success" style="display: none; width: 950px; margin-left: 20px; margin-top: 20px;"></div> |
---|
394 | |
---|
395 | <table style="margin-left: 20px; margin-top: 10px;" class="navigation"> |
---|
396 | <tr> |
---|
397 | <td><base:button id="goimport" title="Register" image="<%=home+"/images/import.png"%>" onclick="goRegister()"/></td> |
---|
398 | <td><base:button id="gorestart" title="Restart" image="<%=home+"/images/goback.png"%>" onclick="goRestart(true)" style="display: none;"/></td> |
---|
399 | <td id="gonext.message" class="message"></td> |
---|
400 | </tr> |
---|
401 | </table> |
---|
402 | |
---|
403 | </form> |
---|
404 | </div> |
---|
405 | |
---|
406 | </base:body> |
---|
407 | </base:page> |
---|
408 | <% |
---|
409 | } |
---|
410 | finally |
---|
411 | { |
---|
412 | if (dc != null) dc.close(); |
---|
413 | } |
---|
414 | %> |
---|