1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> |
---|
2 | <%@ page import="java.util.*"%> |
---|
3 | <%@ page import="java.util.zip.*"%> |
---|
4 | <%@ page import="net.sf.basedb.core.*"%> |
---|
5 | <%@ page import="net.sf.basedb.clients.web.*"%> |
---|
6 | <%@ page import="net.sf.basedb.util.*"%> |
---|
7 | <%@ page import="uk.ac.ebi.nugo.plugins.*"%> |
---|
8 | |
---|
9 | <jsp:useBean id="inputDataBean" class="uk.ac.ebi.nugo.plugins.DataBean" scope="application" /> |
---|
10 | <!-- submits the form data back to the bean assuming that each form element is matched to a variable in the bean by the same name --> |
---|
11 | <jsp:setProperty name="inputDataBean" property="*" /> |
---|
12 | |
---|
13 | <% |
---|
14 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
15 | final String ID = sc.getId(); |
---|
16 | final String requestID = request.getParameter("requestID"); |
---|
17 | %> |
---|
18 | |
---|
19 | <html> |
---|
20 | |
---|
21 | <head> |
---|
22 | |
---|
23 | <link rel="stylesheet" type="text/css" href="<%= request.getContextPath()%>/plugins/uk/ac/ebi/nugo/plugins/styles.css" /> |
---|
24 | <link rel="stylesheet" type="text/css" href="/base/include/styles/main.css"> |
---|
25 | <link rel="stylesheet" type="text/css" href="/base/include/styles/size_m.css"> |
---|
26 | |
---|
27 | <script language="JavaScript" src="<%= request.getContextPath()%>/include/scripts/main.js" type="text/javascript"></script> |
---|
28 | <script language="JavaScript" type="text/javascript"> |
---|
29 | |
---|
30 | //submits form |
---|
31 | function submit() |
---|
32 | { |
---|
33 | var frm = document.forms['mappings']; |
---|
34 | frm.submit(); |
---|
35 | } |
---|
36 | |
---|
37 | |
---|
38 | function getRoot() |
---|
39 | { |
---|
40 | return '/base/'; |
---|
41 | } |
---|
42 | |
---|
43 | function getScale() |
---|
44 | { |
---|
45 | return 1.0; |
---|
46 | } |
---|
47 | </script> |
---|
48 | |
---|
49 | </head> |
---|
50 | |
---|
51 | <body> |
---|
52 | |
---|
53 | |
---|
54 | |
---|
55 | <form name="mappings" action="<%= request.getContextPath()%>/common/plugin/index.jsp" method="post"> |
---|
56 | |
---|
57 | <input type="hidden" name="ID" value="<%=ID%>"> |
---|
58 | <input type="hidden" name="cmd" value="SetParameters"> |
---|
59 | <input type="hidden" name="requestID" value="<%=requestID%>"> |
---|
60 | <input type="hidden" id="fileStringParam" name="param:fileStringParam" value""/> |
---|
61 | |
---|
62 | <!-- these are the parameters from the previous input pages; need to pick them up individually from the bean here; ugly as hell but can't be done any other way --> |
---|
63 | |
---|
64 | <!-- inputs from experiment.jsp page --> |
---|
65 | <input type="hidden" name="parameter:domain" value="<%=inputDataBean.getDomain()%>"> |
---|
66 | <input type="hidden" name="parameter:accession" value="<%=inputDataBean.getAccession()%>"> |
---|
67 | <input type="hidden" name="parameter:qualityControl" value="<%=inputDataBean.getQualityControl()%>"> |
---|
68 | <input type="hidden" name="parameter:experimentalDesign" value="<%=inputDataBean.getExperimentalDesign()%>"> |
---|
69 | <input type="hidden" name="parameter:experimentName" value="<%=inputDataBean.getExperimentName()%>"> |
---|
70 | <input type="hidden" name="parameter:description" value="<%=inputDataBean.getDescription()%>"> |
---|
71 | <input type="hidden" name="parameter:releaseDate" value="<%=inputDataBean.getReleaseDate()%>"> |
---|
72 | <input type="hidden" name="parameter:submissionDate" value="<%=inputDataBean.getSubmissionDate()%>"> |
---|
73 | <input type="hidden" name="parameter:submitter" value="<%=inputDataBean.getSubmitter()%>"> |
---|
74 | <input type="hidden" name="parameter:organization" value="<%=inputDataBean.getOrganization()%>"> |
---|
75 | <input type="hidden" name="parameter:publicationTitle" value="<%=inputDataBean.getPublicationTitle()%>"> |
---|
76 | <input type="hidden" name="parameter:authors" value="<%=inputDataBean.getAuthors()%>"> |
---|
77 | <input type="hidden" name="parameter:journal" value="<%=inputDataBean.getJournal()%>"> |
---|
78 | <input type="hidden" name="parameter:volume" value="<%=inputDataBean.getVolume()%>"> |
---|
79 | <input type="hidden" name="parameter:issue" value="<%=inputDataBean.getIssue()%>"> |
---|
80 | <input type="hidden" name="parameter:pages" value="<%=inputDataBean.getPages()%>"> |
---|
81 | <input type="hidden" name="parameter:year" value="<%=inputDataBean.getYear()%>"> |
---|
82 | <input type="hidden" name="parameter:pubmedId" value="<%=inputDataBean.getPubmedId()%>"> |
---|
83 | <input type="hidden" name="parameter:experimentId" value="<%=inputDataBean.getExperimentId()%>"> |
---|
84 | <!-- inputs from protocols.jsp page --> |
---|
85 | <input type="hidden" name="parameter:treatmentProtocol" value="<%=inputDataBean.getTreatmentProtocol()%>"> |
---|
86 | <input type="hidden" name="parameter:extractionProtocol" value="<%=inputDataBean.getExtractionProtocol()%>"> |
---|
87 | <input type="hidden" name="parameter:labelingProtocol" value="<%=inputDataBean.getLabelingProtocol()%>"> |
---|
88 | <input type="hidden" name="parameter:hybridizationProtocol" value="<%=inputDataBean.getHybridizationProtocol()%>"> |
---|
89 | <input type="hidden" name="parameter:scanningProtocol" value="<%=inputDataBean.getScanningProtocol()%>"> |
---|
90 | <input type="hidden" name="parameter:treatmentProtocolParams" value="<%=inputDataBean.getTreatmentProtocolParams()%>"> |
---|
91 | <input type="hidden" name="parameter:extractionProtocolParams" value="<%=inputDataBean.getExtractionProtocolParams()%>"> |
---|
92 | <input type="hidden" name="parameter:labelingProtocolParams" value="<%=inputDataBean.getLabelingProtocolParams()%>"> |
---|
93 | <input type="hidden" name="parameter:hybridizationProtocolParams" value="<%=inputDataBean.getHybridizationProtocolParams()%>"> |
---|
94 | <input type="hidden" name="parameter:scanningProtocolParams" value="<%=inputDataBean.getScanningProtocolParams()%>"> |
---|
95 | <!-- inputs from hybridizations.jsp page --> |
---|
96 | <input type="hidden" name="parameter:platform" value="<%=inputDataBean.getPlatform()%>"> |
---|
97 | <input type="hidden" name="parameter:organism" value="<%=inputDataBean.getOrganism()%>"> |
---|
98 | <input type="hidden" name="parameter:numDesigns" value="<%=inputDataBean.getNumDesigns()%>"> |
---|
99 | <input type="hidden" name="parameter:dyeSwap" value="<%=inputDataBean.getDyeSwap()%>"> |
---|
100 | <input type="hidden" name="parameter:refSample" value="<%=inputDataBean.getRefSample()%>"> |
---|
101 | <input type="hidden" name="parameter:numTreatmentGroups" value="<%=inputDataBean.getNumTreatmentGroups()%>"> |
---|
102 | <input type="hidden" name="parameter:expFactors" value="<%=inputDataBean.getExpFactors()%>"> |
---|
103 | <input type="hidden" name="parameter:numReplicates" value="<%=inputDataBean.getNumReplicates()%>"> |
---|
104 | <input type="hidden" name="parameter:tissues" value="<%=inputDataBean.getTissues()%>"> |
---|
105 | <input type="hidden" name="parameter:pooling" value="<%=inputDataBean.getPooling()%>"> |
---|
106 | <input type="hidden" name="parameter:zipFile" value="<%=request.getParameter("path") %>" id="zipFile"> |
---|
107 | |
---|
108 | <% |
---|
109 | System.out.println("all parameter values for mappings.jsp:"); |
---|
110 | for (java.util.Enumeration e = request.getParameterNames(); e.hasMoreElements();) |
---|
111 | { |
---|
112 | String name = (String) e.nextElement(); |
---|
113 | String value = request.getParameter(name); |
---|
114 | System.out.println("parameter " + name + " = " + value); |
---|
115 | } |
---|
116 | |
---|
117 | //first extract the factor names and the possible values |
---|
118 | String expFactors = inputDataBean.getExpFactors().trim(); |
---|
119 | String[] rawFactors = expFactors.split("\n"); |
---|
120 | |
---|
121 | String[][] factorValues = new String[rawFactors.length][]; |
---|
122 | String[] factorNames = new String[rawFactors.length]; |
---|
123 | |
---|
124 | for (int i = 0; i < rawFactors.length; i++) |
---|
125 | { |
---|
126 | //extract the factor name |
---|
127 | String factorName = rawFactors[i].substring(0, rawFactors[i].indexOf("(")); |
---|
128 | factorNames[i] = factorName; |
---|
129 | //extract the possible values from between the parentheses |
---|
130 | String allValues = rawFactors[i].substring(rawFactors[i].indexOf("(") + 1, |
---|
131 | rawFactors[i].indexOf(")")); |
---|
132 | String[] values = allValues.split(","); |
---|
133 | factorValues[i] = values; |
---|
134 | } |
---|
135 | |
---|
136 | //here we get hold of the cartesian product of all the factor values |
---|
137 | String[][] products = CartesianProduct.getCartesianProduct(factorValues); |
---|
138 | |
---|
139 | //now inspect the content of the zip file and list all the individual files therein |
---|
140 | |
---|
141 | //first parse the filepath from the input page |
---|
142 | String zipFilePath = (String) request.getParameter("path"); |
---|
143 | String zipFileDirStr = zipFilePath.substring(0, zipFilePath.lastIndexOf("/")); |
---|
144 | String zipFileName = zipFilePath.substring(zipFilePath.lastIndexOf("/")+1); |
---|
145 | |
---|
146 | //get hold of the appropriate BASE objects for this |
---|
147 | DbControl dc = sc.newDbControl(); |
---|
148 | Directory zipFileDir = Directory.getByPath(dc, new Path(zipFileDirStr, Path.Type.DIRECTORY)); |
---|
149 | File zipFile = File.getFile(dc, zipFileDir, zipFileName, false); |
---|
150 | |
---|
151 | //now inspect the file content and store the names in the List |
---|
152 | Vector<String> fileNames = new Vector<String>(); |
---|
153 | ZipInputStream zipStream = new ZipInputStream(zipFile.getDownloadStream(0)); |
---|
154 | ZipEntry entry = zipStream.getNextEntry(); |
---|
155 | while (entry != null) |
---|
156 | { |
---|
157 | fileNames.add(entry.getName()); |
---|
158 | entry = zipStream.getNextEntry(); |
---|
159 | } |
---|
160 | |
---|
161 | String [] fileNamesArr = new String[fileNames.size()]; |
---|
162 | fileNames.toArray(fileNamesArr); |
---|
163 | Arrays.sort(fileNamesArr); |
---|
164 | |
---|
165 | dc.close(); |
---|
166 | %> |
---|
167 | |
---|
168 | <h1>Tab2MAGE Importer -- File Mappings</h1> |
---|
169 | Page 4 of 4 |
---|
170 | <p> |
---|
171 | |
---|
172 | The table below holds a list of all possible factor value combinations used in your experiment. |
---|
173 | Please select, for each combination, the appropriate file name from the drop down menu.</p><p> |
---|
174 | |
---|
175 | <!-- this table holds the combinations of factor values --> |
---|
176 | |
---|
177 | <table align="center" cellpadding="15"> |
---|
178 | |
---|
179 | <!-- column header row factor names --> |
---|
180 | |
---|
181 | <tr> |
---|
182 | |
---|
183 | <!-- file selector header --> |
---|
184 | <td class="header"><h3>File</h3></td> |
---|
185 | |
---|
186 | <!-- factor names --> |
---|
187 | <% |
---|
188 | for (int i = 0; i < products[i].length; i++) |
---|
189 | { |
---|
190 | %> |
---|
191 | <td class="header"><h3><%=factorNames[i]%></h3></td> |
---|
192 | <% |
---|
193 | } |
---|
194 | %> |
---|
195 | </tr> |
---|
196 | |
---|
197 | <!-- now add as many rows as we have discrete combinations of factor values --> |
---|
198 | |
---|
199 | <% |
---|
200 | for (int i = 0; i < products.length; i++) |
---|
201 | { |
---|
202 | %> |
---|
203 | |
---|
204 | <tr> |
---|
205 | |
---|
206 | <!-- first we need a cell with a drop down menu where we can select a filename to match the combination of factor values--> |
---|
207 | |
---|
208 | <td class="input" ><select id="fileinput<%=i %>"> |
---|
209 | <% |
---|
210 | for (int k = 0; k < fileNamesArr.length; k++) |
---|
211 | { |
---|
212 | %> |
---|
213 | |
---|
214 | <option><%=fileNamesArr[k]%></option> |
---|
215 | |
---|
216 | <% |
---|
217 | } |
---|
218 | %> |
---|
219 | </select></td> |
---|
220 | |
---|
221 | <!-- now print the values of this factor value combination, each in a separate cell --> |
---|
222 | <% |
---|
223 | for (int j = 0; j < products[i].length; j++) |
---|
224 | { |
---|
225 | %> |
---|
226 | <td class="border"><%=products[i][j]%></td> |
---|
227 | <% |
---|
228 | } |
---|
229 | %> |
---|
230 | |
---|
231 | |
---|
232 | </tr> |
---|
233 | |
---|
234 | <% |
---|
235 | } |
---|
236 | %> |
---|
237 | |
---|
238 | </table> |
---|
239 | |
---|
240 | <p> |
---|
241 | |
---|
242 | <table align="center" class="noBorder" cellspacing="5" cellpadding="5"> |
---|
243 | <tr class="noBorder"> |
---|
244 | <td id="next" width="50%" style="border-style: none;"><div class="buttons" onmouseover="this.className='buttons_hover';" onmouseout="this.className='buttons';" onclick="submit()"><div class="buttons_inner"><table class="noBorder" cellspacing="0" cellpadding="0"><tr class="noBorder"><td style="border-style: none;"><img src="/base/images/gonext.gif" border="0"></td><td style="border-style: none;">Start Import</td></tr></table></div></div></td> |
---|
245 | <td id="close" width="50%" style="border-style: none;"><div class="buttons" onmouseover="this.className='buttons_hover';" onmouseout="this.className='buttons';" onclick="window.close()"><div class="buttons_inner"><table class="noBorder" cellspacing="0" cellpadding="0"><tr class="noBorder"><td style="border-style: none;"><img src="/base/images/cancel.gif" border="0"></td><td style="border-style: none;">Cancel</td></tr></table></div></div></td> </tr> |
---|
246 | </table> |
---|
247 | |
---|
248 | |
---|
249 | </form> |
---|
250 | |
---|
251 | <script language="JavaScript" type="text/javascript"> |
---|
252 | //collects all the values from the file selector boxes and strings them together so they can be |
---|
253 | //passed on as a single parameter for plugin configuration |
---|
254 | { |
---|
255 | var fileString = ''; |
---|
256 | var frm = document.forms['mappings']; |
---|
257 | var numElements = frm.elements.length; |
---|
258 | document.write(numElements); |
---|
259 | document.write("<br />"); |
---|
260 | for(var i = 0; i < numElements; i++) |
---|
261 | { |
---|
262 | var value = frm.elements[i].value; |
---|
263 | var id = frm.elements[i].id; |
---|
264 | |
---|
265 | if(id.match("fileinput")) |
---|
266 | { |
---|
267 | document.write("id = " + id); |
---|
268 | document.write("<br />"); |
---|
269 | document.write("value = " + value); |
---|
270 | document.write("<br />"); |
---|
271 | fileString += frm.elements[i].value + '\t'; |
---|
272 | } |
---|
273 | } |
---|
274 | document.write('combined output = ' + fileString); |
---|
275 | frm.fileStringParam.value = fileString; |
---|
276 | document.write('value of hidden input = ' + frm.fileStringParam.value); |
---|
277 | } |
---|
278 | </script> |
---|
279 | |
---|
280 | </body> |
---|
281 | </html> |
---|