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 cdnaDateIsValid = false; |
---|
35 | |
---|
36 | function init() |
---|
37 | { |
---|
38 | var frm = document.forms['reggie']; |
---|
39 | var bioplates = getCDnaBioPlates(); |
---|
40 | |
---|
41 | // Load existing cDNA plates not yet registered |
---|
42 | var plates = frm.bioplate; |
---|
43 | if (bioplates != null && bioplates.length > 0) |
---|
44 | { |
---|
45 | for (var i=0; i < bioplates.length; i++) |
---|
46 | { |
---|
47 | var bioplate = bioplates[i]; |
---|
48 | var option = new Option(bioplate.name, bioplate.id); |
---|
49 | plates.options[plates.length] = option; |
---|
50 | } |
---|
51 | bioplateIsValid = true; |
---|
52 | setInputStatus('bioplate', '', 'valid'); |
---|
53 | } |
---|
54 | else |
---|
55 | { |
---|
56 | var msg = 'No cDNA bioplates available for processing.'; |
---|
57 | setFatalError(msg); |
---|
58 | return; |
---|
59 | } |
---|
60 | |
---|
61 | // Load cDNA protocols |
---|
62 | var cdnaProtocols = getProtocols('CDNA_PROTOCOL'); |
---|
63 | for (var i = 0; i < cdnaProtocols.length; i++) |
---|
64 | { |
---|
65 | var protocol = cdnaProtocols[i]; |
---|
66 | frm.cdnaProtocol[frm.cdnaProtocol.length] = new Option(protocol.name, protocol.id, protocol.isDefault); |
---|
67 | setInputStatus('cdnaProtocol', '', 'valid'); |
---|
68 | } |
---|
69 | if (frm.cdnaProtocol.length == 0) |
---|
70 | { |
---|
71 | frm.cdnaProtocol[0] = new Option('- none -', ''); |
---|
72 | } |
---|
73 | |
---|
74 | frm.cdnaDate.focus(); |
---|
75 | Main.show('gocreate'); |
---|
76 | } |
---|
77 | |
---|
78 | function getCDnaBioPlates() |
---|
79 | { |
---|
80 | var frm = document.forms['reggie']; |
---|
81 | |
---|
82 | var request = Ajax.getXmlHttpRequest(); |
---|
83 | try |
---|
84 | { |
---|
85 | showLoadingAnimation('Loading histology work lists...'); |
---|
86 | var url = '../MRna.servlet?ID=<%=ID%>&cmd=GetUnprocessedPlates&plateType=CDNA'; |
---|
87 | request.open("GET", url, false); |
---|
88 | request.send(null); |
---|
89 | } |
---|
90 | finally |
---|
91 | { |
---|
92 | hideLoadingAnimation(); |
---|
93 | } |
---|
94 | |
---|
95 | if (debug) Main.debug(request.responseText); |
---|
96 | var response = JSON.parse(request.responseText); |
---|
97 | if (response.status != 'ok') |
---|
98 | { |
---|
99 | setFatalError(response.message); |
---|
100 | return false; |
---|
101 | } |
---|
102 | return response.bioplates; |
---|
103 | } |
---|
104 | |
---|
105 | function getProtocols(subtype) |
---|
106 | { |
---|
107 | var request = Ajax.getXmlHttpRequest(); |
---|
108 | try |
---|
109 | { |
---|
110 | showLoadingAnimation('Loading ' + subtype + ' protocols...'); |
---|
111 | var url = '../Protocol.servlet?ID=<%=ID%>&cmd=GetProtocols&subtype='+subtype; |
---|
112 | request.open("GET", url, false); |
---|
113 | request.send(null); |
---|
114 | } |
---|
115 | finally |
---|
116 | { |
---|
117 | hideLoadingAnimation(); |
---|
118 | } |
---|
119 | |
---|
120 | if (debug) Main.debug(request.responseText); |
---|
121 | var response = JSON.parse(request.responseText); |
---|
122 | if (response.status != 'ok') |
---|
123 | { |
---|
124 | setFatalError(response.message); |
---|
125 | return false; |
---|
126 | } |
---|
127 | return response.protocols; |
---|
128 | } |
---|
129 | |
---|
130 | |
---|
131 | |
---|
132 | function cdnaDateOnChange() |
---|
133 | { |
---|
134 | var frm = document.forms['reggie']; |
---|
135 | cdnaDateIsValid = false; |
---|
136 | setInputStatus('cdnaDate', '', ''); |
---|
137 | |
---|
138 | var cdnaDate = frm.cdnaDate.value; |
---|
139 | |
---|
140 | if (cdnaDate == '') |
---|
141 | { |
---|
142 | setInputStatus('cdnaDate', 'Missing', 'invalid'); |
---|
143 | return; |
---|
144 | } |
---|
145 | |
---|
146 | // Auto-fill the date if it's only given with 4(MMdd) or 6(yyMMdd) digits. |
---|
147 | cdnaDate = autoFillDate(cdnaDate); |
---|
148 | frm.cdnaDate.value = cdnaDate; |
---|
149 | |
---|
150 | if (!Dates.isDate(cdnaDate, 'yyyyMMdd')) |
---|
151 | { |
---|
152 | setInputStatus('cdnaDate', 'Not a valid date', 'invalid'); |
---|
153 | return; |
---|
154 | } |
---|
155 | |
---|
156 | setInputStatus('cdnaDate', '', 'valid'); |
---|
157 | cdnaDateIsValid = true; |
---|
158 | } |
---|
159 | |
---|
160 | function goRegister() |
---|
161 | { |
---|
162 | if (!cdnaDateIsValid) return; |
---|
163 | |
---|
164 | var frm = document.forms['reggie']; |
---|
165 | |
---|
166 | Main.hide('goimport'); |
---|
167 | |
---|
168 | frm.cdnaOperator.disabled = true; |
---|
169 | frm.cdnaProtocol.disabled = true; |
---|
170 | frm.cdnaDate.disabled = true; |
---|
171 | frm.bioplate.disabled = true; |
---|
172 | frm.comments.disabled = true; |
---|
173 | |
---|
174 | var submitInfo = {}; |
---|
175 | submitInfo.bioplate = parseInt(frm.bioplate.value, 10); |
---|
176 | submitInfo.cdnaProtocol = parseInt(frm.cdnaProtocol.value, 10); |
---|
177 | submitInfo.cdnaDate = frm.cdnaDate.value; |
---|
178 | submitInfo.cdnaOperator = frm.cdnaOperator.value; |
---|
179 | submitInfo.comments = frm.comments.value; |
---|
180 | |
---|
181 | if (debug) Main.debug(JSON.stringify(submitInfo)); |
---|
182 | var url = '../MRna.servlet?ID=<%=ID%>&cmd=ImportCDnaResults'; |
---|
183 | |
---|
184 | var request = Ajax.getXmlHttpRequest(); |
---|
185 | try |
---|
186 | { |
---|
187 | showLoadingAnimation('Importing...'); |
---|
188 | request.open("POST", url, false); |
---|
189 | request.send(JSON.stringify(submitInfo)); |
---|
190 | } |
---|
191 | finally |
---|
192 | { |
---|
193 | hideLoadingAnimation(); |
---|
194 | } |
---|
195 | |
---|
196 | if (debug) Main.debug(request.responseText); |
---|
197 | var response = JSON.parse(request.responseText); |
---|
198 | |
---|
199 | if (response.messages && response.messages.length > 0) |
---|
200 | { |
---|
201 | var msg = '<ul>'; |
---|
202 | for (var i = 0; i < response.messages.length; i++) |
---|
203 | { |
---|
204 | var msgLine = response.messages[i]; |
---|
205 | if (msgLine.indexOf('[Warning]') >= 0) |
---|
206 | { |
---|
207 | msg += '<li class="warning">' + msgLine.replace('[Warning]', ''); |
---|
208 | } |
---|
209 | else |
---|
210 | { |
---|
211 | msg += '<li>' + msgLine; |
---|
212 | } |
---|
213 | } |
---|
214 | msg += '</ul>'; |
---|
215 | setInnerHTML('messages', msg); |
---|
216 | Main.show('messages'); |
---|
217 | } |
---|
218 | |
---|
219 | if (response.status != 'ok') |
---|
220 | { |
---|
221 | Main.addClass(document.getElementById('messages'), 'failure'); |
---|
222 | setFatalError(response.message); |
---|
223 | return false; |
---|
224 | } |
---|
225 | |
---|
226 | Main.show('done'); |
---|
227 | Main.show('gorestart'); |
---|
228 | |
---|
229 | } |
---|
230 | |
---|
231 | |
---|
232 | </script> |
---|
233 | |
---|
234 | </base:head> |
---|
235 | <base:body onload="init()"> |
---|
236 | |
---|
237 | <p:path><p:pathelement |
---|
238 | title="Reggie" href="<%="../index.jsp?ID="+ID%>" |
---|
239 | /><p:pathelement title="cDNA registration" |
---|
240 | /></p:path> |
---|
241 | |
---|
242 | <div class="content"> |
---|
243 | <% |
---|
244 | if (sc.getActiveProjectId() == 0) |
---|
245 | { |
---|
246 | %> |
---|
247 | <div class="messagecontainer note" style="width: 950px; margin-left: 20px; margin-bottom: 20px; margin-right: 0px; font-weight: bold; color: #cc0000;"> |
---|
248 | No project has been selected. You may proceed with the registration but |
---|
249 | created items will not be shared. |
---|
250 | </div> |
---|
251 | <% |
---|
252 | } |
---|
253 | %> |
---|
254 | |
---|
255 | <form name="reggie" onsubmit="return false;"> |
---|
256 | |
---|
257 | <table class="stepform"> |
---|
258 | <tr> |
---|
259 | <td rowspan="3" class="stepno">1</td> |
---|
260 | <td class="steptitle">Select cDNA bioplate</td> |
---|
261 | </tr> |
---|
262 | <tr> |
---|
263 | <td class="stepfields"> |
---|
264 | <table> |
---|
265 | <tr valign="top"> |
---|
266 | <td class="prompt">cDNA bioplate</td> |
---|
267 | <td class="input"><select class="required" style="width:90%" |
---|
268 | name="bioplate" id="bioplate"></select> |
---|
269 | </td> |
---|
270 | <td class="status" id="bioplate.status"></td> |
---|
271 | <td class="help"><span id="bioplate.message" class="message" style="display: none;"></span> |
---|
272 | Select an existing cDNA bioplate. The list contain all cDNA bioplates that |
---|
273 | has not yet been processed (determined by the absence of a 'creation' date). |
---|
274 | </td> |
---|
275 | </tr> |
---|
276 | <tr valign="top"> |
---|
277 | <td class="prompt">Date</td> |
---|
278 | <td class="input"> |
---|
279 | <input type="text" class="required" name="cdnaDate" value="" size="12" maxlength="10" |
---|
280 | onblur="cdnaDateOnChange()" onkeypress="focusOnEnter(event, 'cdnaProtocol')"> |
---|
281 | </td> |
---|
282 | <td class="status" id="cdnaDate.status"></td> |
---|
283 | <td class="help"> |
---|
284 | <span id="cdnaDate.message" class="message" style="display: none;"></span>(YYYYMMDD or MMDD) |
---|
285 | </td> |
---|
286 | </tr> |
---|
287 | <tr valign="top"> |
---|
288 | <td class="prompt">Protocol</td> |
---|
289 | <td class="input"><select style="width:90%" name="cdnaProtocol" id="cdnaProtocol" |
---|
290 | onkeypress="focusOnEnter(event, 'cdnaOperator')"></select></td> |
---|
291 | <td class="status" id="cdnaProtocol.status"></td> |
---|
292 | <td class="help"><span id="cdnaProtocol.message" class="message" style="display: none;"></span> |
---|
293 | Select the protocol which was used in the cDNA step. |
---|
294 | </td> |
---|
295 | </tr> |
---|
296 | <tr valign="top"> |
---|
297 | <td class="prompt">Operator</td> |
---|
298 | <td class="input"> |
---|
299 | <input type="text" name="cdnaOperator" value="<%=HTML.encodeTags(user.getName()) %>" |
---|
300 | size="50" maxlength="255" onkeypress="focusOnEnter(event, 'comments')"> |
---|
301 | </td> |
---|
302 | <td class="status" id="cdnaOperator.status"></td> |
---|
303 | <td class="help"> |
---|
304 | <span id="cdnaOperator.message" class="message" style="display: none;"></span> |
---|
305 | </td> |
---|
306 | </tr> |
---|
307 | <tr valign="top"> |
---|
308 | <td class="prompt">Comments</td> |
---|
309 | <td class="input"><textarea rows="4" cols="50" name="comments" value=""></textarea></td> |
---|
310 | <td class="status"></td> |
---|
311 | <td class="help">Comments about the cDNA processing.</td> |
---|
312 | </tr> |
---|
313 | </table> |
---|
314 | </td> |
---|
315 | </tr> |
---|
316 | </table> |
---|
317 | |
---|
318 | <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> |
---|
319 | |
---|
320 | <div class="messagecontainer error" id="errorMessage" style="display: none; width: 950px; margin-left: 20px; margin-bottom: 0px;"></div> |
---|
321 | |
---|
322 | <div id="messages" class="success" style="display: none; width: 950px; margin-left: 20px; margin-top: 20px;"></div> |
---|
323 | |
---|
324 | <table style="margin-left: 20px; margin-top: 10px;" class="navigation"> |
---|
325 | <tr> |
---|
326 | <td><base:button id="goimport" title="Register" image="<%=home+"/images/import.png"%>" onclick="goRegister()"/></td> |
---|
327 | <td><base:button id="gorestart" title="Restart" image="<%=home+"/images/goback.png"%>" onclick="goRestart(true)" style="display: none;"/></td> |
---|
328 | <td id="gonext.message" class="message"></td> |
---|
329 | </tr> |
---|
330 | </table> |
---|
331 | |
---|
332 | </form> |
---|
333 | </div> |
---|
334 | |
---|
335 | </base:body> |
---|
336 | </base:page> |
---|
337 | <% |
---|
338 | } |
---|
339 | finally |
---|
340 | { |
---|
341 | if (dc != null) dc.close(); |
---|
342 | } |
---|
343 | %> |
---|