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