|
[HepData-svn] r1295 - in trunk/hepdata-webapp/src/main: java/cedar/hepdata/webapp/pages resources/cedar/hepdata/webapp/pagesblackhole at projects.hepforge.org blackhole at projects.hepforge.orgFri Oct 2 09:22:30 BST 2009
Author: whalley Date: Fri Oct 2 09:22:30 2009 New Revision: 1295 Log: changes in Browsing code Added: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/Browse.java trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/Browsing.java trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/Browsing.tml Modified: trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/Browse.tml trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/Index.tml Added: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/Browse.java ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/Browse.java Fri Oct 2 09:22:30 2009 (r1295) @@ -0,0 +1,17 @@ +package cedar.hepdata.webapp.pages; + +import cedar.hepdata.model.*; +import cedar.hepdata.xml.*; +import cedar.hepdata.db.*; + +import org.apache.tapestry5.annotations.*; +import org.apache.tapestry5.ioc.annotations.*; +import org.apache.tapestry5.services.*; + +import org.hibernate.*; +import org.hibernate.criterion.*; +import java.util.*; + + +public class Browse{ +} Added: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/Browsing.java ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/Browsing.java Fri Oct 2 09:22:30 2009 (r1295) @@ -0,0 +1,164 @@ +package cedar.hepdata.webapp.pages; + +import cedar.hepdata.model.*; +import cedar.hepdata.xml.*; +import cedar.hepdata.db.*; + +import org.apache.tapestry5.annotations.*; +import org.apache.tapestry5.ioc.annotations.*; +import org.apache.tapestry5.services.*; + +import org.hibernate.*; +import org.hibernate.criterion.*; +import java.util.*; + + +public class Browsing{ + + @Inject + private RequestGlobals _reqGlobals; + + @Inject + private org.hibernate.Session _session; + + + public String getQueryParam(String param){ + return _reqGlobals.getRequest().getParameter(param); + } + public String getQueryValue(){ + return _reqGlobals.getRequest().getParameter("value"); + } + public String getQueryPos(){ + return _reqGlobals.getRequest().getParameter("pos"); + } + public String getPosUp(){ + int ip = Integer.parseInt(getQueryPos()); + return Integer.toString(ip-1); + } + public String getPosDn(){ + int ip = Integer.parseInt(getQueryPos()); + return Integer.toString(ip+1); + } + public String getQueryKeyword(){ + return _reqGlobals.getRequest().getParameter("keyword"); + } + public String getBrowseName(){ + if(getQueryParam("keyword").equals("is")){ + return "Initial State Particles"; + } + else if(getQueryParam("keyword").equals("fs")){ + return "Final State Particles"; + } + else if(getQueryParam("keyword").equals("obs")){ + return "Observables"; + } + else if(getQueryParam("keyword").equals("reac")){ + return "Reactions"; + } + else if(getQueryParam("keyword").equals("exp")){ + return "Experiments"; + } + else if(getQueryParam("keyword").equals("de")){ + return "Detectors"; + } + else if(getQueryParam("keyword").equals("auth")){ + return "Authors"; + } + else if(getQueryParam("keyword").equals("ref")){ + return "References"; + } + else{ + return "Nothing"; + } + } + public String getSearchName(){ + if(getQueryParam("keyword").equals("is")){ + return "re"; + } + else if(getQueryParam("keyword").equals("fs")){ + return "fsp"; + } + else if(getQueryParam("keyword").equals("obs")){ + return "obs"; + } + else if(getQueryParam("keyword").equals("reac")){ + return "reac"; + } + else if(getQueryParam("keyword").equals("exp")){ + return "exp"; + } + else if(getQueryParam("keyword").equals("de")){ + return "exp"; + } + else if(getQueryParam("keyword").equals("auth")){ + return "auth"; + } + else if(getQueryParam("keyword").equals("ref")){ + return "ref"; + } + else{ + return "Nothing"; + } + } + + private String _name; + public String getName() { return _name; } + public void setName(String name){ _name = name; } + public List <String> getNames(){ + Query q = null; + if(getQueryParam("keyword").equals("is")){ + q = _session.createSQLQuery("select distinct ParticleName from InitialStates"); + } + else if (getQueryParam("keyword").equals("fs")){ + q = _session.createSQLQuery("select distinct ParticleName from FinalStates"); + } + else if (getQueryParam("keyword").equals("obs")){ +// q = _session.createSQLQuery("select distinct dsobs.DsObservables as dsname from DsObservables dsobs order by dsname").addScalar("dsname", Hibernate.STRING); + q = _session.createSQLQuery("select distinct ya.Observable as dsname from YAxes ya order by dsname").addScalar("dsname", Hibernate.STRING); + } + else if (getQueryParam("keyword").equals("reac")){ + q = _session.createSQLQuery("select distinct dsreac.DsReactions as dsname from DsReactions dsreac order by dsname").addScalar("dsname", Hibernate.STRING); + } + else if (getQueryParam("keyword").equals("exp")){ + q = _session.createSQLQuery("select distinct ExptName from PaperExpts order by ExptName"); + } + else if (getQueryParam("keyword").equals("de")){ + q = _session.createSQLQuery("select distinct InformalName from PaperExpts order by InformalName"); + } + else if (getQueryParam("keyword").equals("auth")){ + q = _session.createSQLQuery("select distinct element from PaperAuthors order by element"); + } + else if (getQueryParam("keyword").equals("ref")){ + q = _session.createSQLQuery("select distinct Description from PaperRefs order by Description"); + } + List <String> templist = new ArrayList(); + templist = q.list(); + int n = templist.size(); + int m = -1; + String val = getQueryValue().toUpperCase(); + for (int i=0; i<n; i++){ + if(templist.get(i) != null && templist.get(i).startsWith(val) && m == -1){ + m = i; + } + } + + if(m == -1) { + val = val.substring(0,1); + for (int i=0; i<n; i++){ + if(templist.get(i) != null && templist.get(i).startsWith(val) && m == -1){ + m = i; + } + } + } + if(m == -1) { m = 0; } + int ipos = Integer.parseInt(getQueryPos()); + int offset = ipos*19; + + int min = offset + m - 10; + if(min < 0) { min = 0; } + int max = min+20; + if(max > n) { max = n; } + System.out.println("max and min are " + max + " " + min); + return templist.subList(min,max); + } +} Modified: trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/Browse.tml ============================================================================== --- trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/Browse.tml Thu Oct 1 14:06:10 2009 (r1294) +++ trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/Browse.tml Fri Oct 2 09:22:30 2009 (r1295) @@ -46,11 +46,11 @@ <p/> Choose the index you wish to browse and enter the value. -Select an index:<br> -<!--<form method=GET action=http://h3:8080/hepdata-webapp/browse>--> -<form method=GET action=http://hepdata.cedar.ac.uk/hepdata/browse> +Select an index:<br/> +<form method="GET" action="http://h3:8080/browsing"> +<!--<form method="GET" action="http://hepdata.cedar.ac.uk/hepdata/browse">--> -<select name=keyword> +<select name="keyword"> <option value="is">Initial State Particle (beam)</option> <option value="fs">Final State Particle (fsp)</option> <option value="obs">Observable (obs)</option> @@ -60,11 +60,11 @@ <option value="auth">First Author on Publication (auth)</option> <option value="ref">Reference (ref)</option> </select> -Enter Value:<input type=text name=value size=6/> +Enter Value:<input type="text" name="value" size="6"/> <p/> <input type="submit" value="Browse" /> <input type="submit" value="Clear" /> -<input type="hidden" name="pos" value="0"> +<input type="hidden" name="pos" value="0" /> </form> </td> @@ -75,7 +75,7 @@ <div class="navbar_lower"> HepData also maintains the UK mirrors of: <a href="http://durpdg.dur.ac.uk/spires/hep">SPIRES_HEP</a> -& +& <a href="http://durpdg.dur.ac.uk/lbl/">PDG</a> </div> @@ -84,4 +84,4 @@ </body> - +</html> Added: trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/Browsing.tml ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/Browsing.tml Fri Oct 2 09:22:30 2009 (r1295) @@ -0,0 +1,55 @@ +<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"> + <head> + <title>HepData Reaction Database Browsing</title> +<!-- <link rel="stylesheet" type="text/css" href="${asset:context:/test.css}" />--> + </head> + <body bgcolor="#ffffdd"> + +<div> +<!-- +<h2> +<a href="http://www.dur.ac.uk/"><img alt="DurhamUniv" align="bottom" src="${asset:context:/logounidurham-new.gif}" width="100"/></a> + The Durham HepData Project +<a href="http://www.ippp.dur.ac.uk/"><img alt="IPPP" align="bottom" src="${asset:context:/ippp_transparent-small.png}" width="100"/></a> +</h2> +--> +</div> + +<p/> + +<div class="navbar"> +<a id="nav-reaction" href="http://durpdg.dur.ac.uk/hepdata/new_reac.shtml">Reaction Database</a> +<a id="nav-review" href="http://durpdg.dur.ac.uk/hepdata/reviews.shtml">Data Reviews</a> +<a id="nav-pdf" href="http://durpdg.dur.ac.uk/hepdata/pdf.html">Parton Density Functions</a> +</div> + +<table> +<tr> +<td> + <h2> Browsing ${getBrowseName()} </h2> + +<br/> + <a href="browsing?keyword=${getQueryKeyword()}&value=${getQueryValue()}&pos=${getPosUp()}">browse upwards</a> + <br/> + <t:loop source="names" value="name"> + <br/> + <a href="reactionquery?string=${getSearchName()}+${getName()}&plength=10&start=1"> ${getName()}</a> + </t:loop> + <p/> + + <a href="browsing?keyword=${getQueryKeyword()}&value=${getQueryValue()}&pos=${getPosDn()}">browse downwards</a> + <p/><a href="http://durpdg.dur.ac.uk/hepdata/new_reac.shtml">Back</a> +</td> +</tr> +</table> + +<div class="navbar_lower"> +HepData also maintains the UK mirrors of: +<a href="http://durpdg.dur.ac.uk/spires/hep">SPIRES_HEP</a> +& +<a href="http://durpdg.dur.ac.uk/lbl/">PDG</a> +</div> + +<!-- <t:Credits /> --> + </body> +</html> Modified: trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/Index.tml ============================================================================== --- trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/Index.tml Thu Oct 1 14:06:10 2009 (r1294) +++ trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/Index.tml Fri Oct 2 09:22:30 2009 (r1295) @@ -24,7 +24,7 @@ <a href="#" t:type="pagelink" t:page="search" t:context="literal:exp_cern">exp cern</a> <br/> <a href="#" t:type="pagelink" t:page="searchhelp">Search Help</a>, – - <a href="browse.shtml">Browse keywords</a> – + <a href="#" t:type="pagelink" t:page="browse">Browse Keywords</a>, – <!-- <a href="new_reacform.shtml">Form search</a> – --> <a href="#" t:type="pagelink" t:page="outputhelp">Output Help</a>, – </span>
More information about the HepData-svn mailing list |