source: branches/uk_ac_ebi_Tab2MageImporter/jsp/uk/ac/ebi/nugo/plugins/mappings.jsp @ 539

Last change on this file since 539 was 532, checked in by mbayer, 14 years ago

-major expansion of system to allow for different use cases

  • now includes several new JSP pages which allow the user to make choices
File size: 8.3 KB
Line 
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="session" />
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
31function submit()
32{
33  gatherValues();
34  document.mappings.submit();
35}
36
37
38function getRoot()
39{
40  return '/base/';
41}
42
43function getScale()
44{
45  return 1.0;
46}
47
48
49//collects all the values from the file selector boxes and strings them together so they can be
50//passed on as a single parameter for plugin configuration
51function gatherValues()
52{
53  var fileList = '';
54  var subjectList = '';
55  var tissueList = '';
56  var frm = document.forms['mappings'];
57  var numElements = frm.elements.length;
58  for(var i = 0; i < numElements; i++)
59  {
60    var value = frm.elements[i].value;
61    var id = frm.elements[i].id;
62    if(id.match("fileInput"))
63    {
64      fileList += frm.elements[i].value + '\t';
65    }
66    if(id.match("subjectInput"))
67    {
68      subjectList += frm.elements[i].value + '\t';
69    }
70    if(id.match("tissueInput"))
71    {
72      tissueList += frm.elements[i].value + '\t';
73    }
74  }
75  frm.fileList.value = fileList;
76  frm.subjectList.value = subjectList;
77  frm.tissueList.value = tissueList;
78}
79
80</script>
81
82</head>
83
84<body>
85
86
87
88<form name="mappings" action="<%= request.getContextPath()%>/plugins/uk/ac/ebi/nugo/plugins/submit.jsp" method="post">
89
90<input type="hidden" name="ID" value="<%=ID%>"> 
91<input type="hidden" name="cmd" value="SetParameters"> 
92<input type="hidden" name="requestId" value="<%=requestId%>"> 
93
94<input type="hidden" id="fileList" name="fileList" value""/>
95<input type="hidden" id="subjectList" name="subjectList" value""/>
96<input type="hidden" id="tissueList" name="tissueList" value""/>
97
98
99
100<%
101
102  //first extract the factor names and the possible values
103  String expFactors = inputDataBean.getExpFactors().trim();
104  String[] rawFactors = expFactors.split("\n");
105
106  String[][] factorValues = new String[rawFactors.length][];
107  String[] factorNames = new String[rawFactors.length];
108
109  for (int i = 0; i < rawFactors.length; i++)
110  {
111    //extract the factor name
112    String factorName = rawFactors[i].substring(0, rawFactors[i].indexOf("("));
113    factorNames[i] = factorName;
114    //extract the possible values from between the parentheses
115    String allValues = rawFactors[i].substring(rawFactors[i].indexOf("(") + 1,
116        rawFactors[i].indexOf(")"));
117    String[] values = allValues.split(",");
118    factorValues[i] = values;
119  }
120
121  //here we get hold of the cartesian product of all the factor values
122  String[][] products = CartesianProduct.getCartesianProduct(factorValues);
123
124  //now inspect the content of the zip file and list all the individual files therein
125
126  //first parse the filepath from the input page 
127  String zipFilePath = inputDataBean.getPath();
128  System.out.println("zipFilePath = " + zipFilePath);
129  String zipFileDirStr = zipFilePath.substring(0, zipFilePath.lastIndexOf("/"));
130  String zipFileName = zipFilePath.substring(zipFilePath.lastIndexOf("/")+1);
131
132  //get hold of the appropriate BASE objects for this
133  DbControl dc = sc.newDbControl();
134  Directory zipFileDir = Directory.getByPath(dc, new Path(zipFileDirStr, Path.Type.DIRECTORY));
135  File zipFile = File.getFile(dc, zipFileDir, zipFileName, false);
136
137  //now inspect the file content and store the names in the List
138  Vector<String> fileNames = new Vector<String>();
139  ZipInputStream zipStream = new ZipInputStream(zipFile.getDownloadStream(0));
140  ZipEntry entry = zipStream.getNextEntry();
141  while (entry != null)
142  {
143    fileNames.add(entry.getName());
144    entry = zipStream.getNextEntry();
145  }
146 
147  String [] fileNamesArr = new String[fileNames.size()];
148  fileNames.toArray(fileNamesArr);
149  Arrays.sort(fileNamesArr);
150 
151  dc.close();
152 
153  //next get the subjectNames and make up select boxes with these
154  //they too have to be mapped to filenames
155  String [] subjectNames = inputDataBean.getSubjectNames().split("\n");
156 
157  //we also need to parse out the tissues string to produce another column of select boxes
158  String [] tissueNames = inputDataBean.getTissues().split("\n");
159%>
160
161<h1>Tab2MAGE Import Wizard -- File Mappings</h1>
162<p>
163
164The table below holds a list of all possible factor value combinations used in your experiment.
165Please select, for each combination, the appropriate file, subject and tissue from the drop down menu.</p><p>
166
167<!-- this table holds the combinations of factor values -->
168
169<table align="center" cellpadding="15">
170
171  <!-- column header row factor names -->
172
173  <tr>
174
175    <!-- file selector header -->
176    <td class="header"><h3>File</h3></td>
177    <td class="header"><h3>Subject</h3></td>
178    <td class="header"><h3>Tissue</h3></td>
179
180    <!-- factor names -->
181    <%
182      for (int i = 0; i < products[i].length; i++)
183      {
184    %>
185    <td class="header"><h3><%=factorNames[i]%></h3></td>
186    <%
187    }
188    %>
189  </tr>
190
191  <!-- now add as many rows as we have discrete combinations of factor values -->
192
193  <%
194    for (int i = 0; i < products.length; i++)
195    {
196  %>
197
198  <tr>
199
200    <!-- first we need a cell with a drop down menu where we can select a filename to match the combination of factor values-->
201
202    <td class="input" ><select id="fileInput<%=i %>">
203      <%
204          for (int k = 0; k < fileNamesArr.length; k++)
205          {
206      %>
207
208      <option><%=fileNamesArr[k]%></option>
209
210      <%
211      }
212      %>
213    </select></td>
214   
215    <!-- next  we need a cell with a drop down menu where we can select a subject name to match the combination of factor values-->
216
217    <td class="input" ><select id="subjectInput<%=i %>">
218      <%
219          for (int k = 0; k < subjectNames.length; k++)
220          {
221      %>
222
223      <option><%=subjectNames[k]%></option>
224
225      <%
226      }
227      %>
228    </select></td>
229   
230    <!-- next  we need a cell with a drop down menu where we can select a tissue name to match the combination of factor values-->
231
232    <td class="input" ><select id="tissueInput<%=i %>">
233      <%
234          for (int k = 0; k < tissueNames.length; k++)
235          {
236      %>
237
238      <option><%=tissueNames[k]%></option>
239
240      <%
241      }
242      %>
243    </select></td>
244
245<!-- now print the values of this factor value combination, each in a separate cell -->
246    <%
247        for (int j = 0; j < products[i].length; j++)
248        {
249    %>
250    <td class="border"><%=products[i][j]%></td>
251    <%
252    }
253    %>
254
255
256  </tr>
257
258  <%
259  }
260  %>
261
262</table>
263
264<p>
265
266  <table align="center" class="noBorder" cellspacing="5"  cellpadding="5">
267  <tr class="noBorder">
268    <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>
269    <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>
270  </table>
271
272
273</form>
274
275
276
277</body>
278</html>
Note: See TracBrowser for help on using the repository browser.