SlicDiagWeb/src/main/webapp
diff -u -r1.1 -r1.2
--- dbSelect.jsp 24 Sep 2007 17:07:50 -0000 1.1
+++ dbSelect.jsp 12 Nov 2007 20:07:36 -0000 1.2
@@ -13,29 +13,216 @@
<title>DB Select</title>
<base target="_top">
<link type="text/css" href="css/displaytag.css" rel="stylesheet">
- <SCRIPT TYPE="text/javascript">
+ <SCRIPT type="text/javascript" src="utils.js">
+ </SCRIPT>
+ <SCRIPT TYPE="text/JavaScript">
+
+ var emptyString = /^\s*$/ ;
+ var separator = " ";
+ var doIt = true;
+
+ function trim(str) {
+ return str.replace(/^\s+|\s+$/g, '');
+ }
+
+ function resetForm(theForm) {
+ doIt = false;
+ var i = 0;
+ theForm.slicId.selectedIndex = i;
+ theForm.geant4Id.selectedIndex = i;
+ theForm.detectorId.selectedIndex = i;
+ theForm.typeId.selectedIndex = i;
+ theForm.plistId.selectedIndex = i;
+ theForm.selectedFileId.selectedIndex = i;
+ theForm.selectedRefId.selectedIndex = i;
+
+ doIt = true;
+ resetSelection(theForm.detectorId);
+ theForm.where_selection.value = "";
+ //theForm.submit();
+ return true;
+ }
+
function selectType(el) {
+ //alert(doIt)
+ if (doIt == false) return;
var theForm = el.form;
- var index = el.selectedIndex;
- var text = el.options[index].text;
+
+ var detector = theForm.detectorId.options[theForm.detectorId.selectedIndex].text;
+ var geant4 = theForm.geant4Id.options[theForm.geant4Id.selectedIndex].text;
+ var slic = theForm.slicId.options[theForm.slicId.selectedIndex].text;
+ var type = theForm.typeId.options[theForm.typeId.selectedIndex].text;
+ var plist = theForm.plistId.options[theForm.plistId.selectedIndex].text;
+
+ var tmp = "";
+ tmp = tmp + "\n ** detector="+detector;
+ tmp = tmp + "\n ** geant4="+geant4;
+ tmp = tmp + "\n ** slic="+slic;
+ tmp = tmp + "\n ** type="+type;
+ tmp = tmp + "\n ** plist="+plist;
+
+ // Re-fill selectedFileId and selectedRefId
theForm.selectedFileId.options.length = 0;
theForm.selectedRefId.options.length = 0;
theForm.selectedRefId.options[0] = new Option(theForm.no_selection.value, theForm.no_selection.value);
var n = 0;
- var tmp = "";
+ var sel = "";
for (var i=0; i<theForm.allFiles.options.length; i++) {
- tmp = tmp + "\n ** "+i+" "+theForm.allTypes.options[i].text;
- if (text == theForm.full_selection.value || theForm.allTypes.options[i].text == text) {
+ var pass = 1;
+ var name = theForm.allFiles.options[i].text
+ if (detector != theForm.full_selection.value && name.indexOf(detector) < 0 ) {
+ pass = -1;
+ }
+ if (geant4 != theForm.full_selection.value && name.indexOf("geant4-"+geant4) < 0) {
+ pass = -1;
+ }
+ if (slic != theForm.full_selection.value && name.indexOf("SLIC-"+slic) < 0) {
+ pass = -1;
+ }
+ if (type != theForm.full_selection.value && name.indexOf(type) < 0) {
+ pass = -1;
+ }
+ if (plist != theForm.full_selection.value && name.indexOf(plist) < 0) {
+ pass = -1;
+ }
+ if (pass > 0) {
theForm.selectedFileId.options[n] = new Option(theForm.allFiles.options[i].text, theForm.allFiles.options[i].text);
theForm.selectedRefId.options[n+1] = new Option(theForm.allFiles.options[i].text, theForm.allFiles.options[i].text);
+ var sep = " or ";
+ if (n == 0) sep = " ";
+ sel = sel + sep + "id = " + theForm.allIds.options[i].text;
+ n++;
+ }
+ }
+ //alert(tmp);
+
+ // Now re-fill all other forms
+ if (sel != "") sel = "where " + sel;
+ //alert(sel);
+ theForm.where_selection.value = sel;
+ //theForm.submit();
+ }
+
+
+ function resetSelection(el) {
+ //alert(doIt)
+ if (doIt == false) return;
+ doIt = false;
+ var theForm = el.form;
+
+ var all = theForm.full_selection.value;
+ var detector = theForm.detectorId.options[theForm.detectorId.selectedIndex].text;
+ var geant4 = theForm.geant4Id.options[theForm.geant4Id.selectedIndex].text;
+ var slic = theForm.slicId.options[theForm.slicId.selectedIndex].text;
+ var type = theForm.typeId.options[theForm.typeId.selectedIndex].text;
+ var plist = theForm.plistId.options[theForm.plistId.selectedIndex].text;
+
+ //alert("det: "+detector);
+
+ // Empty all visible "select" fields
+ theForm.slicId.options.length = 0;
+ theForm.geant4Id.options.length = 0;
+ theForm.detectorId.options.length = 0;
+ theForm.typeId.options.length = 0;
+ theForm.plistId.options.length = 0;
+ theForm.selectedFileId.options.length = 0;
+ theForm.selectedRefId.options.length = 0;
+
+ // fill default selections
+ theForm.slicId.options[0] = new Option(all, all);
+ theForm.geant4Id.options[0] = new Option(all, all);
+ theForm.detectorId.options[0] = new Option(all, all);
+ theForm.typeId.options[0] = new Option(all, all);
+ theForm.plistId.options[0] = new Option(all, all);
+ theForm.selectedRefId.options[0] = new Option(theForm.no_selection.value, theForm.no_selection.value);
+
+ // selected index
+ var indSlic = 0;
+ var indGeant = 0;
+ var indDet = 0;
+ var indType = 0;
+ var indPlist = 0;
+
+
+ // Fill other options (if needed)
+ var n = 0;
+ var sel = "";
+ for (var i=0; i<theForm.all.options.length; i++) {
+ var val = theForm.all.options[i].text
+ var fields = val.split(separator);
+
+ var tmpId = trim(fields[0]);
+ var tmpFile = trim(fields[1]);
+ var tmpSlic = trim(fields[2]);
+ var tmpGeant4 = trim(fields[3]);
+ var tmpDetector = trim(fields[4]);
+ var tmpEvType = trim(fields[5]);
+ var tmpPList = trim(fields[5]);
+
+ var pass = 1;
+ if (slic != all && slic != tmpSlic) { pass = -1;}
+ if (geant4 != all && geant4 != tmpGeant4) { pass = -1; }
+ if (detector != all && detector != tmpDetector) { pass = -1; }
+ if (type != all && type != tmpEvType) { pass = -1; }
+ if (plist != all && plist != tmpPList) { pass = -1; }
+
+ if (pass > 0) {
+
+ theForm.selectedFileId.options[n] = new Option(tmpFile, tmpFile);
+ theForm.selectedRefId.options[n+1] = new Option(tmpFile, tmpFile);
+ theForm.slicId.options[n+1] = new Option(tmpSlic, tmpSlic);
+ theForm.geant4Id.options[n+1] = new Option(tmpGeant4, tmpGeant4);
+ theForm.detectorId.options[n+1] = new Option(tmpDetector, tmpDetector);
+ theForm.typeId.options[n+1] = new Option(tmpEvType, tmpEvType);
+ theForm.plistId.options[n+1] = new Option(tmpPList, tmpPList);
+
+ if (slic == tmpSlic) { indSlic = n+1;}
+ if (geant4 == tmpGeant4) { indGeant = n+1; }
+ if (detector == tmpDetector) { indDet = n+1; }
+ if (type == tmpEvType) { indType = n+1; }
+ if (plist == tmpPList) { indPlist = n+1; }
+
+ var sep = " or ";
+ if (n == 0) sep = " ";
+ sel = sel + sep + "id = " + theForm.allIds.options[i].text;
n++;
}
- }
- //alert("el.value="+text+"\n **** "+tmp);
+ }
+ //alert(tmp);
+
+ // Set selected index
+ theForm.slicId.selectedIndex = indSlic;
+ theForm.geant4Id.selectedIndex = indGeant;
+ theForm.detectorId.selectedIndex = indDet;
+ theForm.typeId.selectedIndex = indType;
+ theForm.plistId.selectedIndex = indPlist;
+
+ // purge fields
+ purgeList(theForm.slicId);
+ purgeList(theForm.geant4Id);
+ purgeList(theForm.detectorId);
+ purgeList(theForm.typeId);
+ purgeList(theForm.plistId);
+
+
+ // sort fields
+ sortList(theForm.slicId, true);
+ sortList(theForm.geant4Id, true);
+ sortList(theForm.detectorId, true);
+ sortList(theForm.typeId, true);
+ sortList(theForm.plistId, true);
+
+
+ // Now create selection for ID field
+ if (sel != "") sel = "where " + sel;
+ //alert(sel);
+ theForm.where_selection.value = sel;
+ doIt = true;
}
- </SCRIPT>
- </head>
+
+ </SCRIPT>
+ </head>
<body>
<a href="index.html">SLIC Test Home</a><br>
@@ -44,32 +231,102 @@
<sql:query var="type">select distinct event_type from SlicData</sql:query>
- <form name="dataSelectForm" action="topFrame.jsp">
+ <form name="dataSelectForm" action="topFrame.jsp" onReset="return resetForm(this)">
<TABLE>
<TR>
<TD>
- <button style="background-color: orange;" type="submit">Update</button>
+ <button style="background-color: orange;" type="reset">Reset</button>
+ </TD>
+ <TD>
+ <button style="background-color: orange;" type="submit"><b>Update</b></button>
+ </TD>
+ <TD>
+ Geant4:
+ </TD>
+ <TD>
+ <SELECT name="geant4Id" onchange="resetSelection(this)">
+ <OPTION>${initParam.full_selection}</OPTION>
+ <c:set var="g4List" value="${aida:createList(data.rows, \"geant4_version\", true)}"/>
+ ${aida:sortList(g4List, false)}
+ <c:forEach var="gobj" items="${g4List}">
+ <OPTION <c:if test="${geant4Id == gobj}"> selected</c:if> >
+ <c:out value="${gobj}"/>
+ </OPTION>
+ </c:forEach>
+ </SELECT>
+ </TD>
+ <TD>
+ Type:
+ </TD>
+ <TD>
+ <SELECT name="typeId" onchange="resetSelection(this)">
+ <OPTION>${initParam.full_selection}</OPTION>
+ <c:set var="typeList" value="${aida:createList(data.rows, \"event_type\", true)}"/>
+ ${aida:sortList(typeList, true)}
+ <c:forEach var="tobj" items="${typeList}">
+ <OPTION <c:if test="${typeId == tobj}"> selected</c:if> >
+ <c:out value="${tobj}"/>
+ </OPTION>
+ </c:forEach>
+ </SELECT>
</TD>
<TD>
File:
</TD>
<TD>
<SELECT name="selectedFileId">
- <c:forEach var="rowObject" items="${data.rows}">
- <OPTION <c:if test="${selectedFileId == rowObject.file_url}"> selected</c:if> >
- <c:out value="${rowObject.file_url}"/>
+ <c:forEach var="fobj" items="${data.rows}">
+ <OPTION <c:if test="${selectedFileId == fobj.file_url}"> selected</c:if> >
+ <c:out value="${fobj.file_url}"/>
</OPTION>
</c:forEach>
</SELECT>
</TD>
</TR>
+
+ <!-- second row -->
<TR>
<TD>
- <SELECT name="typeId" onchange="selectType(this)">
+ Detector:
+ </TD>
+ <TD>
+ <SELECT name="detectorId" onchange="resetSelection(this)">
<OPTION>${initParam.full_selection}</OPTION>
- <c:forEach var="typeObject" items="${type.rows}">
- <OPTION <c:if test="${selectedTypeId == typeObject.event_type}"> selected</c:if> >
- <c:out value="${typeObject.event_type}"/>
+ <c:set var="detList" value="${aida:createList(data.rows, \"detector\", true)}"/>
+ ${aida:sortList(detList, true)}
+ <c:forEach var="dobj" items="${detList}">
+ <OPTION <c:if test="${detectorId == dobj}"> selected</c:if> >
+ <c:out value="${dobj}"/>
+ </OPTION>
+ </c:forEach>
+ </SELECT>
+ </TD>
+ <TD>
+ SLIC:
+ </TD>
+ <TD>
+ <SELECT name="slicId" onchange="resetSelection(this)">
+ <OPTION>${initParam.full_selection}</OPTION>
+ <c:set var="slicList" value="${aida:createList(data.rows, \"slic_version\", true)}"/>
+ ${aida:sortList(slicList, false)}
+ <c:forEach var="sobj" items="${slicList}">
+ <OPTION <c:if test="${slicId == sobj}"> selected</c:if> >
+ <c:out value="${sobj}"/>
+ </OPTION>
+ </c:forEach>
+ </SELECT>
+ </TD>
+ <TD>
+ P.List:
+ </TD>
+ <TD>
+ <SELECT name="plistId" onchange="resetSelection(this)">
+ <OPTION>${initParam.full_selection}</OPTION>
+ <c:set var="pidList" value="${aida:createList(data.rows, \"event_type\", true)}"/>
+ ${aida:sortList(pidList, true)}
+ <c:forEach var="pobj" items="${pidList}">
+ <OPTION <c:if test="${plistId == pobj}"> selected</c:if> >
+ <c:out value="${pobj}"/>
</OPTION>
</c:forEach>
</SELECT>
@@ -80,26 +337,36 @@
<TD>
<SELECT name="selectedRefId">
<OPTION>${initParam.no_selection}</OPTION>
- <c:forEach var="rowObject" items="${data.rows}">
- <OPTION <c:if test="${selectedRefId == rowObject.file_url}"> selected</c:if> >
- <c:out value="${rowObject.file_url}"/>
+ <c:forEach var="robj" items="${data.rows}">
+ <OPTION <c:if test="${selectedRefId == robj.file_url}"> selected</c:if> >
+ <c:out value="${robj.file_url}"/>
</OPTION>
</c:forEach>
</SELECT>
- </TD>
+ </TD>
</TR>
<SELECT name="allFiles" style="display: none;">
- <c:forEach var="rowObject" items="${data.rows}">
- <OPTION>${rowObject.file_url}
+ <c:forEach var="aobj" items="${data.rows}">
+ <OPTION>
+ ${aobj.file_url}
</OPTION>
</c:forEach>
</SELECT>
- <SELECT name="allTypes" style="display: none;">
- <c:forEach var="rowObject" items="${data.rows}">
- <OPTION>${rowObject.event_type}
+ <SELECT name="allIds" style="display: none;">
+ <c:forEach var="iobj" items="${data.rows}">
+ <OPTION>
+ ${iobj.id}
+ </OPTION>
+ </c:forEach>
+ </SELECT>
+ <SELECT name="all" style="display: none;">
+ <c:forEach var="ao" items="${data.rows}">
+ <OPTION>
+ ${ao.id} ${ao.file_url} ${ao.slic_version} ${ao.geant4_version} ${ao.detector} ${ao.event_type}
</OPTION>
</c:forEach>
</SELECT>
+ <input type="hidden" name="where_selection" value="${where_selection}"/>
<input type="hidden" name="no_selection" value="${initParam.no_selection}"/>
<input type="hidden" name="full_selection" value="${initParam.full_selection}"/>
</TD>
SlicDiagWeb/src/main/webapp/WEB-INF
diff -u -r1.2 -r1.3
--- web.xml 28 Sep 2007 21:37:48 -0000 1.2
+++ web.xml 12 Nov 2007 20:07:37 -0000 1.3
@@ -21,10 +21,10 @@
<context-param>
<param-name>slic_file_base</param-name>
- <param-value>/nfs/slac/g/lcd/public_data/SlicDiagWebData</param-value>
+ <param-value>C:/work/Data/slicdiag_test</param-value>
<!--
- <param-value>C:/work/Data/slicdiag_test</param-value>
- <param-value>/afs/slac.stanford.edu/u/ey/jeremym/public_html/download/slicdiag_test</param-value>
+ <param-value>/nfs/slac/g/lcd/public_data/SlicDiagWebData</param-value>
+ <param-value>/afs/slac.stanford.edu/u/ey/jeremym/public_html/download/slicdiag_test</param-value>
-->
<description>Directory where to look for the files with plots</description>
</context-param>
@@ -55,7 +55,7 @@
<filter-class>org.freehep.webutil.filter.RequestParameterCashFilter</filter-class>
<init-param>
<param-name>attributeList</param-name>
- <param-value>selectedFileId, selectedRefId, aidaDataFile, aidaRefFile, showPlotStyle, showStatistics, showLegend</param-value>
+ <param-value>selectedFileId, selectedRefId, geant4Id, detectorId, typeId, slicId, plistId, where_selection, aidaDataFile, aidaRefFile, showPlotStyle, showStatistics, showLegend</param-value>
<description>Comma separated list of attributes that need cashing</description>
</init-param>
</filter>