[HepData-svn] r1296 - in trunk/hepdata-webapp/src/main: java/cedar/hepdata/webapp/components java/cedar/hepdata/webapp/pages resources/cedar/hepdata/webapp/pages

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Fri Oct 2 17:31:35 BST 2009


Author: whalley
Date: Fri Oct  2 17:31:35 2009
New Revision: 1296

Log:
adding code for easysearch and fixes for browse

Added:
   trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/WriteDsObservables.java
   trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/EasySearch1.java
   trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/EasySearch2.java
   trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/EasySearch3.java
   trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/EasySearch1.tml
   trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/EasySearch2.tml
   trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/EasySearch3.tml
Modified:
   trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/Browsing.java
   trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/Browsing.tml

Added: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/WriteDsObservables.java
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/WriteDsObservables.java	Fri Oct  2 17:31:35 2009	(r1296)
@@ -0,0 +1,95 @@
+package cedar.hepdata.webapp.components;
+
+import org.apache.tapestry5.MarkupWriter;
+import org.apache.tapestry5.annotations.*;
+import org.apache.tapestry5.ioc.annotations.*;
+import org.apache.tapestry5.services.*;
+
+import cedar.hepdata.model.*;
+import cedar.hepdata.webapp.pages.*;
+
+import java.text.*;
+import java.util.*;
+import java.util.List;
+import java.io.InputStream;
+import java.net.URLEncoder;
+import java.math.BigInteger;
+
+import org.hibernate.*;
+
+public class WriteDsObservables {
+
+    @Inject
+    private RequestGlobals _reqGlobals;
+
+    @Inject
+    private org.hibernate.Session _session;
+
+    public String getQueryParam(String param){
+       return _reqGlobals.getRequest().getParameter(param);
+    }
+
+
+    @BeginRender
+    void renderMessage(MarkupWriter writer) {
+
+        List <String> _dsobservables = new ArrayList();            
+        List <BigInteger> _counts = new ArrayList();            
+
+ 
+//        String dsreaction = getQueryParam("dsreaction");
+        String dsreaction = getQueryParam("initial") + " --> " + getQueryParam("final");
+        int j = dsreaction.lastIndexOf("(");
+        if(j>0) {dsreaction = dsreaction.substring(0,j-1);}
+        System.out.println(dsreaction);
+        String dsreactionURL = "";
+        try{
+            dsreactionURL = URLEncoder.encode(dsreaction,"UTF-8");
+        } catch (Exception ex) {dsreactionURL = "failed";};
+ 
+        Query q = null;
+        StringBuffer b = new StringBuffer();
+        b.append("select do.DsObservables from DsObservables do,DsReactions dr where do.DATASET_ID=dr.DATASET_ID and dr.DsReactions like '");
+        b.append(dsreaction);
+        b.append("' group by do.DsObservables order by do.DsObservables"); 
+        q = _session.createSQLQuery(b.toString());
+
+        Query qc = null;
+        StringBuffer bc = new StringBuffer();
+        bc.append("select count(*) from DsObservables do,DsReactions dr where do.DATASET_ID=dr.DATASET_ID and dr.DsReactions like '");
+        bc.append(dsreaction);
+        bc.append("' group by do.DsObservables order by do.DsObservables"); 
+        qc = _session.createSQLQuery(bc.toString());
+ 
+ 
+        _dsobservables = q.list();
+        _counts = qc.list();
+        
+        int total = _dsobservables.size();
+        int length = total/4;
+      
+        int count=0;
+        writer.element("table cellpadding='10' border=1");
+        writer.element("tr");
+        writer.element("td valign='top'");
+        int nc=-1;
+        for ( String dsobs : _dsobservables ){
+            nc += 1;
+            count += 1;
+            writer.element("a href='ReactionQuery?dsreaction=" + dsreactionURL + "&amp;dsobservable=" + dsobs + "&amp;plength=10&amp;start=1'");
+            writer.write(dsobs);
+            writer.end();
+            writer.write(" (" + _counts.get(nc) + ")");
+            writer.element("br");writer.end();
+            if(count > length) {
+                writer.end();
+                writer.element("td valign='top'");
+                count = 0;
+            }
+        }
+        writer.end();  // end of final td
+        writer.end();  // end of tr
+        writer.end();  // end of table
+
+    }
+}

Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/Browsing.java
==============================================================================
--- trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/Browsing.java	Fri Oct  2 09:22:30 2009	(r1295)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/Browsing.java	Fri Oct  2 17:31:35 2009	(r1296)
@@ -101,9 +101,25 @@
        }
     }
  
+    private String _namereal;
+    public String getNameReal(){
+        return _namereal;
+    }
+    public void setNameReal(String namereal){
+        _namereal = namereal;
+    }
+
     private String _name;
-    public String getName() { return _name; }
-    public void setName(String name){ _name = name; }
+    public String getName() {return _name;}
+    public void setName(String name){ 
+       _name = name; 
+       _namereal = name.replace("$0028","#").replace('#','(');
+       _namereal = _namereal.replace("$0029","#").replace('#',')');
+       _namereal = _namereal.replace("$002b","#").replace('#','+'); 
+       _namereal = _namereal.replace("$003d","#").replace('#','='); 
+       _namereal = _namereal.replace("$002a","#").replace('#','*'); 
+       _namereal = _namereal.replace("$002f","#").replace('#','/'); 
+    } 
     public List <String> getNames(){
        Query q = null;
        if(getQueryParam("keyword").equals("is")){
@@ -131,24 +147,39 @@
        else if (getQueryParam("keyword").equals("ref")){
            q = _session.createSQLQuery("select distinct Description from PaperRefs order by Description");
        }
+       List <String> templist0 = new ArrayList();
+       templist0 = q.list();
+
        List <String> templist = new ArrayList();
-       templist = q.list();
+       for (int i=0; i<templist0.size(); i++){
+          if(templist0.get(i) != null && templist0.get(i).matches("^[A-Z].*$")){
+//              String temp = templist0.get(i);
+              String temp = templist0.get(i).replace('+','#').replace("#","$002b");
+              temp = temp.replace('(','#').replace("#","$0028");
+              temp = temp.replace(')','#').replace("#","$0029");
+              temp = temp.replace('=','#').replace("#","$003d");
+              temp = temp.replace('*','#').replace("#","$002a");
+              temp = temp.replace('/','#').replace("#","$002f");
+//              System.out.println(" temp -- " + i);
+              templist.add(temp);
+         }
+       }
+
        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(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;
-	     }
-	  }	  
+	   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());

Added: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/EasySearch1.java
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/EasySearch1.java	Fri Oct  2 17:31:35 2009	(r1296)
@@ -0,0 +1,173 @@
+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.*;
+
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.math.BigInteger;
+
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.Link;
+import org.apache.tapestry5.MarkupWriter;
+import org.apache.tapestry5.StreamResponse;
+//import org.apache.tapestry5.annotations.Inject;
+//import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.ioc.services.TypeCoercer;
+import org.apache.tapestry5.dom.Element;
+import org.apache.tapestry5.services.Response;
+
+
+public class EasySearch1{
+
+    @Inject
+    private org.hibernate.Session _session;
+
+   
+
+//DsReaction 
+    private static String _dsreaction;
+    public String getDsReaction() {  return _dsreaction; }
+    public void setDsReaction(String dsreaction) {  _dsreaction = dsreaction; }
+
+//    private static String _count;
+    public String getCount() { 
+        Query q = null;
+        StringBuffer b = new StringBuffer("select count(*) from DsReactions where DsReactions like '");
+        b.append(_dsreaction);
+        b.append("%'"); 
+        q = _session.createSQLQuery(b.toString());
+        String _count = q.uniqueResult().toString();
+        System.out.println("count is " + _count + " from dsreaction " + _dsreaction);
+        return _count;
+    }
+    public String getCount2() {
+        int j = _initialstates.indexOf(_dsreaction);
+        BigInteger _count2 = _countsis.get(j);
+        return _count2.toString();
+    }
+    
+
+    private List <String> _dsreactions = new ArrayList();
+    private List <BigInteger> _countsre = new ArrayList();
+    private List <BigInteger> _countsis = new ArrayList();
+    private List <String> _initialstates = new ArrayList();
+    public List <String> getDsReactions(){
+        Query q = null;
+        StringBuffer b = new StringBuffer();
+        b.append("select DsReactions from DsReactions group by DsReactions order by DsReactions"); 
+        q = _session.createSQLQuery(b.toString());
+        _dsreactions = q.list();
+        Query qc = null;
+        StringBuffer bc = new StringBuffer();
+        bc.append("select count(*) from DsReactions group by DsReactions order by DsReactions"); 
+        qc = _session.createSQLQuery(bc.toString());
+        _countsre = qc.list();
+        Iterator it = _dsreactions.iterator();
+        Iterator itc = _countsre.iterator();
+        _countsis.clear();
+        _initialstates.clear();
+        while (it.hasNext()){
+            String _dsreac = (String) it.next();
+            BigInteger _countre = (BigInteger) itc.next();
+            int i = _dsreac.indexOf("-->");
+            if(i > 0 ) {
+                String _initialstate = _dsreac.substring(0,i);
+                if( _initialstate.split(" ").length == 2){
+                    String beam = _initialstate.split(" ")[0];
+                    String target = _initialstate.split(" ")[1];
+                    if( !beam.startsWith("AL") && !target.startsWith("AL") &&
+                        !beam.startsWith("AR") && !target.startsWith("AR") &&
+                        !beam.equals("AIR")    && !target.equals("AIR") &&
+                        !beam.startsWith("AG") && !target.startsWith("AG") &&
+                        !beam.startsWith("AU") && !target.startsWith("AU") &&
+                        !beam.startsWith("BE") && !target.startsWith("BE") &&
+                        !beam.startsWith("BOR") && !target.startsWith("BOR") &&
+                        !beam.startsWith("BI") && !target.startsWith("BI") &&
+                        !beam.startsWith("BR") && !target.startsWith("BR") &&
+                        !beam.startsWith("CA") && !target.startsWith("CA") &&
+                        !beam.equals("C")      && !target.equals("C") &&
+                        !beam.startsWith("C1") && !target.startsWith("C1") &&
+                        !beam.startsWith("CE") && !target.startsWith("CE") &&
+                        !beam.startsWith("CD") && !target.startsWith("CD") &&
+                        !beam.startsWith("CO") && !target.startsWith("CO") &&
+                        !beam.startsWith("CR") && !target.startsWith("CR") &&
+                        !beam.startsWith("CL") && !target.startsWith("CL") &&
+                        !beam.startsWith("CU") && !target.startsWith("CU") &&
+                        !beam.startsWith("IN") && !target.startsWith("IN") &&
+                        !beam.startsWith("KK") && !target.startsWith("KK") &&
+                        !beam.startsWith("KR") && !target.startsWith("KR") &&
+                        !beam.startsWith("LA") && !target.startsWith("LA") &&
+                        !beam.startsWith("LI") && !target.startsWith("LI") &&
+                        !beam.startsWith("FE") && !target.startsWith("FE") &&
+                        !beam.startsWith("FL") && !target.startsWith("FL") &&
+                        !beam.startsWith("GD") && !target.startsWith("GD") &&
+                        !beam.startsWith("GE") && !target.startsWith("GE") &&
+                        !beam.startsWith("HF") && !target.startsWith("HF") &&
+                        !beam.startsWith("HO") && !target.startsWith("HO") &&
+                        !beam.startsWith("MG") && !target.startsWith("MG") &&
+                        !beam.startsWith("MO") && !target.startsWith("MO") &&
+                        !beam.startsWith("MN") && !target.startsWith("MN") &&
+                        !beam.startsWith("NA") && !target.startsWith("NA") &&
+                        !beam.startsWith("NB") && !target.startsWith("NB") &&
+                        !beam.startsWith("NE") && !target.startsWith("NE") &&
+                        !beam.startsWith("NI") && !target.startsWith("NI") &&
+                        !beam.startsWith("O")  && !target.startsWith("O")  &&
+                        !beam.startsWith("PB") && !target.startsWith("PB") &&
+                        !beam.startsWith("PD") && !target.startsWith("PD") &&
+                        !beam.startsWith("PH") && !target.startsWith("PH") &&
+                        !beam.startsWith("PT") && !target.startsWith("PT") &&
+                        !beam.startsWith("RB") && !target.startsWith("RB") &&
+                        !beam.startsWith("RU") && !target.startsWith("RU") &&
+                        !beam.startsWith("SC") && !target.startsWith("SC") &&
+                        !beam.startsWith("SI") && !target.startsWith("SI") &&
+                        !beam.startsWith("SM") && !target.startsWith("SM") &&
+                        !beam.startsWith("SN") && !target.startsWith("SN") &&
+                        !beam.startsWith("SR") && !target.startsWith("SR") &&
+                        !beam.startsWith("S") && !target.startsWith("S") &&
+                        !beam.startsWith("TA") && !target.startsWith("TA") &&
+                        !beam.startsWith("TB") && !target.startsWith("TB") &&
+                        !beam.startsWith("TE") && !target.startsWith("TE") &&
+                        !beam.startsWith("TI") && !target.startsWith("TI") &&
+                        !beam.startsWith("TH") && !target.startsWith("TH") &&
+                        !beam.startsWith("TM") && !target.startsWith("TM") &&
+                        !beam.startsWith("U") && !target.startsWith("U") &&
+                        !beam.startsWith("VA") && !target.startsWith("VA") &&
+                        !beam.equals("W") && !target.equals("W") &&
+                        !beam.startsWith("WT") && !target.startsWith("WT") &&
+                        !beam.startsWith("XE") && !target.startsWith("XE") &&
+                        !beam.startsWith("YB") && !target.startsWith("YB") &&
+                        !beam.startsWith("YT") && !target.startsWith("YT") &&
+                        !beam.startsWith("ZN") && !target.startsWith("ZN") &&
+                        !beam.startsWith("ZR") && !target.startsWith("ZR") 
+                         ){
+                        if( !_initialstates.contains(_initialstate) ) {
+                             _initialstates.add(_initialstate);
+                             _countsis.add(_countre); 
+                        }
+                        else{
+                             int j = _initialstates.indexOf(_initialstate);
+                             BigInteger temp = _countsis.get(j);
+                             _countsis.set(j,temp.add(_countre));
+                        }
+                    }
+                }
+            } 
+        }
+        
+        return _initialstates;   
+    }
+}

Added: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/EasySearch2.java
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/EasySearch2.java	Fri Oct  2 17:31:35 2009	(r1296)
@@ -0,0 +1,115 @@
+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.*;
+
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.math.BigInteger;
+
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.Link;
+import org.apache.tapestry5.MarkupWriter;
+import org.apache.tapestry5.StreamResponse;
+//import org.apache.tapestry5.annotations.Inject;
+//import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.ioc.services.TypeCoercer;
+import org.apache.tapestry5.dom.Element;
+import org.apache.tapestry5.services.Response;
+
+
+public class EasySearch2{
+
+    @Inject
+    private RequestGlobals _reqGlobals;
+
+    @Inject
+    private org.hibernate.Session _session;
+
+    public String getQueryParam(String param){
+       return _reqGlobals.getRequest().getParameter(param);
+    }
+
+    private static String _finalstate;
+    
+    public String getInitialState(){
+    
+       String _initialstate = _reqGlobals.getRequest().getParameter("initial");
+       int j = _initialstate.lastIndexOf("(");
+       if(j > 0){_initialstate = _initialstate.substring(0,j-1);}
+       return _initialstate;
+    }
+
+    public String getCount2() {
+        int j = _finalstates.indexOf(_dsreaction);
+//        System.out.println("size"  +  _countsfs.size() + " j is " + j + " _finalstate is " + _dsreaction);
+        BigInteger _count2 = _countsfs.get(j);
+        return _count2.toString();
+//        return "xxx";
+    }
+    
+//DsReaction 
+    private static String _dsreaction;
+    public String getDsReaction() {  return _dsreaction; }
+    public void setDsReaction(String dsreaction) {  _dsreaction = dsreaction; }
+    
+    private List <String> _dsreactions = new ArrayList();
+    private List <String> _finalstates = new ArrayList();
+    private List <BigInteger> _countsre = new ArrayList();
+    private List <BigInteger> _countsfs = new ArrayList();
+    public List <String> getDsReactions(){
+        String initialstate = getInitialState();
+        Query q = null;
+        StringBuffer b = new StringBuffer();
+        b.append("select DsReactions from DsReactions where DsReactions like '");
+        b.append(initialstate);
+        b.append("%' group by DsReactions order by DsReactions"); 
+         q = _session.createSQLQuery(b.toString());
+        _dsreactions = q.list();
+
+        Query qc = null;
+        StringBuffer bc = new StringBuffer();
+        bc.append("select count(*) from DsReactions where DsReactions like '");
+        bc.append(initialstate);
+        bc.append("%' group by DsReactions order by DsReactions"); 
+        qc = _session.createSQLQuery(bc.toString());
+        _countsre = qc.list();
+
+        Iterator it = _dsreactions.iterator();
+        Iterator itc = _countsre.iterator();
+        _countsfs.clear();
+        _finalstates.clear();
+        while (it.hasNext()){
+            String _dsreac = (String) it.next();
+            BigInteger _countre = (BigInteger) itc.next();
+            int i = _dsreac.indexOf("-->");
+            if(i > 0 ) {
+                String _finalstate = _dsreac.substring(i+4);
+                System.out.println(_finalstate);
+                if( !_finalstates.contains(_finalstate) ) {
+                     _finalstates.add(_finalstate);
+                     _countsfs.add(_countre); 
+                }
+                 else{
+                      int j = _finalstates.indexOf(_finalstate);
+                      BigInteger temp = _countsfs.get(j);
+                      _countsfs.set(j,temp.add(_countre));
+                 }
+            }
+        }
+       return _finalstates;   
+   }
+}

Added: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/EasySearch3.java
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/EasySearch3.java	Fri Oct  2 17:31:35 2009	(r1296)
@@ -0,0 +1,192 @@
+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.*;
+
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.net.URLEncoder;
+import java.net.URLDecoder;
+
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.Link;
+import org.apache.tapestry5.MarkupWriter;
+import org.apache.tapestry5.StreamResponse;
+//import org.apache.tapestry5.annotations.Inject;
+//import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.ioc.services.TypeCoercer;
+import org.apache.tapestry5.dom.Element;
+import org.apache.tapestry5.services.Response;
+
+
+public class EasySearch3{
+
+    @Inject
+    private RequestGlobals _reqGlobals;
+
+    @Inject
+    private org.hibernate.Session _session;
+
+
+    public String getQueryParam(String param){
+//       return _reqGlobals.getRequest().getParameter(param).replaceAll("%","z");
+       return _reqGlobals.getRequest().getParameter(param);
+    }
+
+    public String getFinal(){
+       return _reqGlobals.getRequest().getParameter("final");
+    }
+
+    public String getDsReaction(){
+       String is = _reqGlobals.getRequest().getParameter("initial");
+       String fs = _reqGlobals.getRequest().getParameter("final");
+       String re = is + " --> " + fs;
+//       return _reqGlobals.getRequest().getParameter("dsreaction");
+       return re;
+    }
+    public String getDsReactionURL(){
+       String re = getDsReaction();
+       System.out.println("In getReactionURL " + re);
+       try{
+           re = URLEncoder.encode(re,"UTF-8"); 
+           System.out.println("In getReactionURL encoded " + re);
+       }catch(Exception ex){};
+       return re;
+    }
+
+//DsObservable 
+    private static String _dsobservable;
+    public String getDsObservable() {  return _dsobservable; }
+    public String getDsObservable(String a) {  
+        return _dsobservable; 
+    }
+    public void setDsObservable(String dsobservable) {  _dsobservable = dsobservable; }
+    
+
+    private int obscount;
+    public String zeroObsCount(){
+        obscount = 0;
+        return "";
+    }
+    public String addObsCount(){
+        obscount += 1;
+        return "";
+    }
+    public String getObsCount(){
+        return Integer.toString(obscount);
+    }
+
+    public String newColumn(){
+        return "<\\/td><td>";
+    }
+
+    public Boolean getIsTen(){
+        if( obscount == 10) {
+             obscount=0;
+             return true;
+        }
+        else{
+            return false;
+        }    
+    }
+
+    public List <String> getDsObservables(){
+//        String dsreaction = getQueryParam("dsreaction");
+        String dsreaction = getQueryParam("initial") + " -->" + getQueryParam("final");
+        int j = dsreaction.lastIndexOf("(");
+        dsreaction = dsreaction.substring(0,j-1);
+        Query q = null;
+        StringBuffer b = new StringBuffer();
+        b.append("select distinct do.DsObservables from DsObservables do,DsReactions dr where do.DATASET_ID=dr.DATASET_ID and dr.DsReactions like '");
+        b.append(dsreaction);
+        b.append("' order by DsObservables"); 
+//        q = _session.createSQLQuery(b.toString()).setFirstResult(_start).setMaxResults(_length);
+         q = _session.createSQLQuery(b.toString());
+       return q.list();
+    }
+
+
+     private List <String> getDsObservables(String str){
+//        String dsreaction = getQueryParam("dsreaction");
+        String dsreaction = getQueryParam("initial") + " -->" + getQueryParam("final");
+        int j = dsreaction.lastIndexOf("(");
+        dsreaction = dsreaction.substring(0,j-1);
+        Query q = null;
+        StringBuffer b = new StringBuffer();
+        b.append("select distinct do.DsObservables from DsObservables do,DsReactions dr where do.DATASET_ID=dr.DATASET_ID and dr.DsReactions like '");
+        b.append(dsreaction);
+        b.append("' and do.DsObservables like '");
+        b.append(str);
+        b.append("%'");
+        b.append(" order by DsObservables"); 
+        q = _session.createSQLQuery(b.toString());
+        return q.list();
+    }
+    
+    public Boolean getIsDsObservablesA(){ if ( getDsObservables("A").isEmpty() ) { return false; } else { return true; } }
+    public Boolean getIsDsObservablesB(){ if ( getDsObservables("B").isEmpty() ) { return false; } else { return true; } }
+    public Boolean getIsDsObservablesC(){ if ( getDsObservables("C").isEmpty() ) { return false; } else { return true; } }
+    public Boolean getIsDsObservablesD(){ if ( getDsObservables("D").isEmpty() ) { return false; } else { return true; } }
+    public Boolean getIsDsObservablesE(){ if ( getDsObservables("E").isEmpty() ) { return false; } else { return true; } }
+    public Boolean getIsDsObservablesF(){ if ( getDsObservables("F").isEmpty() ) { return false; } else { return true; } }
+    public Boolean getIsDsObservablesG(){ if ( getDsObservables("G").isEmpty() ) { return false; } else { return true; } }
+    public Boolean getIsDsObservablesH(){ if ( getDsObservables("H").isEmpty() ) { return false; } else { return true; } }
+    public Boolean getIsDsObservablesI(){ if ( getDsObservables("I").isEmpty() ) { return false; } else { return true; } }
+    public Boolean getIsDsObservablesJ(){ if ( getDsObservables("J").isEmpty() ) { return false; } else { return true; } }
+    public Boolean getIsDsObservablesK(){ if ( getDsObservables("K").isEmpty() ) { return false; } else { return true; } }
+    public Boolean getIsDsObservablesL(){ if ( getDsObservables("L").isEmpty() ) { return false; } else { return true; } }
+    public Boolean getIsDsObservablesM(){ if ( getDsObservables("M").isEmpty() ) { return false; } else { return true; } }
+    public Boolean getIsDsObservablesN(){ if ( getDsObservables("N").isEmpty() ) { return false; } else { return true; } }
+    public Boolean getIsDsObservablesO(){ if ( getDsObservables("O").isEmpty() ) { return false; } else { return true; } }
+    public Boolean getIsDsObservablesP(){ if ( getDsObservables("P").isEmpty() ) { return false; } else { return true; } }
+    public Boolean getIsDsObservablesQ(){ if ( getDsObservables("Q").isEmpty() ) { return false; } else { return true; } }
+    public Boolean getIsDsObservablesR(){ if ( getDsObservables("R").isEmpty() ) { return false; } else { return true; } }
+    public Boolean getIsDsObservablesS(){ if ( getDsObservables("S").isEmpty() ) { return false; } else { return true; } }
+    public Boolean getIsDsObservablesT(){ if ( getDsObservables("T").isEmpty() ) { return false; } else { return true; } }
+    public Boolean getIsDsObservablesU(){ if ( getDsObservables("U").isEmpty() ) { return false; } else { return true; } }
+    public Boolean getIsDsObservablesV(){ if ( getDsObservables("V").isEmpty() ) { return false; } else { return true; } }
+    public Boolean getIsDsObservablesW(){ if ( getDsObservables("W").isEmpty() ) { return false; } else { return true; } }
+    public Boolean getIsDsObservablesX(){ if ( getDsObservables("X").isEmpty() ) { return false; } else { return true; } }
+    public Boolean getIsDsObservablesY(){ if ( getDsObservables("Y").isEmpty() ) { return false; } else { return true; } }
+    public Boolean getIsDsObservablesZ(){ if ( getDsObservables("Z").isEmpty() ) { return false; } else { return true; } }
+
+    public List <String> getDsObservablesA(){ return getDsObservables("A"); }
+    public List <String> getDsObservablesB(){ return getDsObservables("B"); }
+    public List <String> getDsObservablesC(){ return getDsObservables("C"); }
+    public List <String> getDsObservablesD(){ return getDsObservables("D"); }
+    public List <String> getDsObservablesE(){ return getDsObservables("E"); }
+    public List <String> getDsObservablesF(){ return getDsObservables("F"); }
+    public List <String> getDsObservablesG(){ return getDsObservables("G"); }
+    public List <String> getDsObservablesH(){ return getDsObservables("H"); }
+    public List <String> getDsObservablesI(){ return getDsObservables("I"); }
+    public List <String> getDsObservablesJ(){ return getDsObservables("J"); }
+    public List <String> getDsObservablesK(){ return getDsObservables("K"); }
+    public List <String> getDsObservablesL(){ return getDsObservables("L"); }
+    public List <String> getDsObservablesM(){ return getDsObservables("M"); }
+    public List <String> getDsObservablesN(){ return getDsObservables("N"); }
+    public List <String> getDsObservablesO(){ return getDsObservables("O"); }
+    public List <String> getDsObservablesP(){ return getDsObservables("P"); }
+    public List <String> getDsObservablesQ(){ return getDsObservables("Q"); }
+    public List <String> getDsObservablesR(){ return getDsObservables("R"); }
+    public List <String> getDsObservablesS(){ return getDsObservables("S"); }
+    public List <String> getDsObservablesT(){ return getDsObservables("T"); }
+    public List <String> getDsObservablesU(){ return getDsObservables("U"); }
+    public List <String> getDsObservablesV(){ return getDsObservables("V"); }
+    public List <String> getDsObservablesW(){ return getDsObservables("W"); }
+    public List <String> getDsObservablesX(){ return getDsObservables("X"); }
+    public List <String> getDsObservablesY(){ return getDsObservables("Y"); }
+    public List <String> getDsObservablesZ(){ return getDsObservables("Z"); }
+}

Modified: trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/Browsing.tml
==============================================================================
--- trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/Browsing.tml	Fri Oct  2 09:22:30 2009	(r1295)
+++ trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/Browsing.tml	Fri Oct  2 17:31:35 2009	(r1296)
@@ -32,13 +32,13 @@
      <a href="browsing?keyword=${getQueryKeyword()}&amp;value=${getQueryValue()}&amp;pos=${getPosUp()}">browse upwards</a>
      <br/>
      <t:loop source="names" value="name"> 
-         <br/>
-         <a href="reactionquery?string=${getSearchName()}+${getName()}&amp;plength=10&amp;start=1"> ${getName()}</a>    
+           <br/>
+           <a href="search/${getSearchName()}_${getName()}"> ${getNameReal()}</a> 
      </t:loop>
      <p/>
 
      <a href="browsing?keyword=${getQueryKeyword()}&amp;value=${getQueryValue()}&amp;pos=${getPosDn()}">browse downwards</a>
-     <p/><a href="http://durpdg.dur.ac.uk/hepdata/new_reac.shtml">Back</a>
+     <p/><a href="browse">Back</a>
 </td>
 </tr>
 </table>

Added: trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/EasySearch1.tml
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/EasySearch1.tml	Fri Oct  2 17:31:35 2009	(r1296)
@@ -0,0 +1,68 @@
+<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+  <head>
+    <title>HepData Reaction Database EasySearch stage 1</title>
+  </head>
+  <body bgcolor="#FFFFDD">
+  <div ID="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
+<!--   <script LANGUAGE="JavaScript" SRC="${asset:context:/overlib.js}"></script> -->
+   <h2> 
+<!-- <img alt=" " src="${asset:context:/logounidurham-new.gif}"/> -->
+	 HepData Reaction Database </h2>
+   <!-- <p><img alt=" " src="${asset:context:/rain_line.gif}"/></p> -->
+
+   
+   <form method="GET" action="EasySearch2">
+     <table>
+      <tr>
+      <td align='center' colspan='2'>
+      <b> <font size='+1'> Easy Search Method  - stage 1</font></b>
+      </td>
+      </tr>
+      <tr>
+      <td colspan='2'>
+   In this and the following pages you will be asked to choose an<br/> 
+   an inital state, than a final state and/or an observable for the<br/>
+   data you are looking for.  Below, the left hand list of initial states<br/>
+   are the twelve most common.  You can choose from either list.<br/> 
+      </td>
+      </tr>
+
+       <tr>
+         <td align='center'>
+           <b>Common initial states</b><br/>
+           <select name='initial' size='12'>
+           <OPTION> P P          </OPTION>
+           <OPTION> PBAR P       </OPTION>
+           <OPTION> P N          </OPTION>
+           <OPTION> E+ P         </OPTION>
+           <OPTION> E- P         </OPTION>
+           <OPTION> E+ E-        </OPTION>
+           <OPTION> GAMMA GAMMA  </OPTION>
+           <OPTION> GAMMA P      </OPTION>
+           <OPTION> PI+ P        </OPTION>
+           <OPTION> PI- P        </OPTION>
+           <OPTION> K+ P         </OPTION>
+           <OPTION> K- P         </OPTION>
+           </select>
+         </td>
+         <td align='center'>
+            <b>All available initial states</b><br/>
+           <select name='initial' size='12'>
+             <option selected='true' value='%'>any initial state</option>
+           <t:loop source="dsReactions" value="dsReaction">
+             <option>${getDsReaction()} (${getCount2()})</option>
+           </t:loop>
+           </select>
+         </td>
+       </tr>
+       <tr>
+       <td colspan="2">
+          then press <input type="submit" value="continue" />
+          to continue the search or <input type="reset" value="reset" />
+        </td>
+       </tr>
+     </table>
+   </form>
+<!--    <t:Credits /> -->
+  </body>
+</html>

Added: trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/EasySearch2.tml
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/EasySearch2.tml	Fri Oct  2 17:31:35 2009	(r1296)
@@ -0,0 +1,49 @@
+<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+  <head>
+    <title>HepData Reaction Database EasySearch stage 2</title>
+  </head>
+  <body bgcolor="#FFFFDD">
+  <div ID="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
+<!--   <script LANGUAGE="JavaScript" SRC="${asset:context:/overlib.js}"></script> -->
+  <h2>
+<!-- <img alt=" " src="${asset:context:/logounidurham-new.gif}"/> -->
+	 HepData Reaction Database </h2>
+<!--   <p><img alt=" " src="${asset:context:/rain_line.gif}"/></p> -->
+
+
+     <form method="GET" action="EasySearch3">
+     <input type='hidden' name='initial' value='${getInitialState()}' />
+     <table>
+       <tr>
+         <td align='center' colspan='1'>
+          <b>  <font size='+1'>Easy Search Method  - stage 2</font></b>
+         </td>
+       </tr>
+      <tr>
+      <td colspan='1'>
+      The following <b>final states</b> exist for the <b>initial state ${getInitialState()}</b><br/>
+      </td>
+      </tr>
+      <tr>
+      <td>
+     <select name='final' size='12'>
+     <option selected='true' value='%'>any final state</option>
+     <t:loop source="dsReactions" value="dsReaction">
+         <option>${getDsReaction()} (${getCount2()})</option>
+     </t:loop>
+     </select>
+     </td>
+     </tr>
+     <tr>
+     <td colspan='1'>
+     The press <input type="submit" value="continue" />
+     to continue with the search, or <input type="reset" value="reset" />
+     </td>
+     </tr>
+     </table>
+     </form>
+     Back to <a href="EasySearch1">EasySeach Stage 1</a>
+     
+<!--   <t:Credits /> -->
+  </body>
+</html>

Added: trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/EasySearch3.tml
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/EasySearch3.tml	Fri Oct  2 17:31:35 2009	(r1296)
@@ -0,0 +1,133 @@
+<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+  <head>
+    <title>HepData Reaction Database EasySearch stage 3</title>
+  </head>
+  <body bgcolor="#FFFFDD">
+  <div ID="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
+<!--  <script LANGUAGE="JavaScript" SRC="${asset:context:/overlib.js}"></script> -->
+  <h2>
+<!-- <img alt=" " src="${asset:context:/logounidurham-new.gif}"/> -->
+	 HepData Reaction Database </h2>
+<!--   <p><img alt=" " src="${asset:context:/rain_line.gif}"/></p> -->
+
+
+<!-- <t:grid t:source="dsObservables" rowsPerPage="10"  />-->
+
+<h3> The following observables are available for the reaction ${getDsReaction()} </h3> 
+
+<t:writeDsObservables />
+
+<!--
+<table>
+<tr>
+<td valign='top'> 
+<t:loop source="dsObservables" value="dsObservable"> 
+     ${addObsCount()}
+     <t:if t:test="isTen">
+     </t:if>       
+      <t:writeDsObservable dsobservable="dsObservable"/>
+      <a href="ReactionQuery?dsreaction=${getDsReactionURL()}&amp;dsobservable=${getDsObservable()}&amp;plength=10&amp;start=1">${getDsObservable()}</a><br/>
+</t:loop>
+</td>
+</tr>
+</table>
+-->
+<!--
+<table>
+<tr>
+<td valign='top'> <t:loop source="dsObservablesA" value="dsObservable"> 
+        <a href="ReactionQuery?dsreaction=${getDsReaction()}&amp;dsobservable=${getDsObservable()}&amp;plength=10&amp;start=1">${getDsObservable()}</a><br/>
+     </t:loop>
+</td>
+<td valign='top'> <t:loop source="dsObservablesB" value="dsObservable"> 
+        <a href="ReactionQuery?dsreaction=${getDsReaction()}&amp;dsobservable=${getDsObservable()}&amp;plength=10&amp;start=1">${getDsObservable()}</a><br/>
+     </t:loop>
+</td>
+<td valign='top'> <t:loop source="dsObservablesC" value="dsObservable"> 
+        <a href="ReactionQuery?dsreaction=${getDsReaction()}&amp;dsobservable=${getDsObservable()}&amp;plength=10&amp;start=1">${getDsObservable()}</a><br/>
+     </t:loop>
+</td>
+<td valign='top'> <t:loop source="dsObservablesD" value="dsObservable"> 
+        <a href="ReactionQuery?dsreaction=${getDsReaction()}&amp;dsobservable=${getDsObservable()}&amp;plength=10&amp;start=1">${getDsObservable()}</a><br/>
+     </t:loop>
+</td>
+<td valign='top'> <t:loop source="dsObservablesE" value="dsObservable"> 
+        <a href="ReactionQuery?dsreaction=${getDsReaction()}&amp;dsobservable=${getDsObservable()}&amp;plength=10&amp;start=1">${getDsObservable()}</a><br/>
+     </t:loop>
+</td>
+<td valign='top'> <t:loop source="dsObservablesF" value="dsObservable"> 
+        <a href="ReactionQuery?dsreaction=${getDsReaction()}&amp;dsobservable=${getDsObservable()}&amp;plength=10&amp;start=1">${getDsObservable()}</a><br/>
+     </t:loop>
+</td>
+</tr>
+
+</table>   
+-->
+<!--
+     <form method="GET" action="ReactionQuery">
+
+     <input type="hidden" name="dsreaction" value="${getDsReaction()}" /> 
+
+     <table>
+       <tr>
+         <td align='center' colspan='5'>
+          <b> <font size='+1'>Easy Search Method  - stage 3</font></b>
+         </td>
+       </tr>
+      <tr>
+      <td colspan='5'>
+      The following <b>observables</b> exist for the reaction <b> ${getDsReaction()}</b><br/>
+      </td>
+      </tr>
+
+      <tr>
+      <t:if test="isDsObservablesA"> <td><select name='dsobservable' size='3'><t:loop source="dsObservablesA" value="dsObservable"><option>${getDsObservable()}</option></t:loop></select></td></t:if>
+      <t:if test="isDsObservablesB"> <td><select name='dsobservable' size='3'><t:loop source="dsObservablesB" value="dsObservable"><option>${getDsObservable()}</option></t:loop></select></td></t:if>
+      <t:if test="isDsObservablesC"> <td><select name='dsobservable' size='3'><t:loop source="dsObservablesC" value="dsObservable"><option>${getDsObservable()}</option></t:loop></select></td></t:if>
+      <t:if test="isDsObservablesD"> <td><select name='dsobservable' size='3'><t:loop source="dsObservablesD" value="dsObservable"><option>${getDsObservable()}</option></t:loop></select></td></t:if>
+      </tr><tr>
+      <t:if test="isDsObservablesE"> <td><select name='dsobservable' size='3'><t:loop source="dsObservablesE" value="dsObservable"><option>${getDsObservable()}</option></t:loop></select></td></t:if>
+      <t:if test="isDsObservablesF"> <td><select name='dsobservable' size='3'><t:loop source="dsObservablesF" value="dsObservable"><option>${getDsObservable()}</option></t:loop></select></td></t:if>
+      <t:if test="isDsObservablesG"> <td><select name='dsobservable' size='3'><t:loop source="dsObservablesG" value="dsObservable"><option>${getDsObservable()}</option></t:loop></select></td></t:if>
+      <t:if test="isDsObservablesH"> <td><select name='dsobservable' size='3'><t:loop source="dsObservablesH" value="dsObservable"><option>${getDsObservable()}</option></t:loop></select></td></t:if>
+      </tr><tr>
+      <t:if test="isDsObservablesI"> <td><select name='dsobservable' size='3'><t:loop source="dsObservablesI" value="dsObservable"><option>${getDsObservable()}</option></t:loop></select></td></t:if>
+      <t:if test="isDsObservablesJ"> <td><select name='dsobservable' size='3'><t:loop source="dsObservablesJ" value="dsObservable"><option>${getDsObservable()}</option></t:loop></select></td></t:if>
+      <t:if test="isDsObservablesK"> <td><select name='dsobservable' size='3'><t:loop source="dsObservablesK" value="dsObservable"><option>${getDsObservable()}</option></t:loop></select></td></t:if>
+      <t:if test="isDsObservablesL"> <td><select name='dsobservable' size='3'><t:loop source="dsObservablesL" value="dsObservable"><option>${getDsObservable()}</option></t:loop></select></td></t:if>
+      </tr><tr>
+      <t:if test="isDsObservablesM"> <td><select name='dsobservable' size='3'><t:loop source="dsObservablesM" value="dsObservable"><option>${getDsObservable()}</option></t:loop></select></td></t:if>
+      <t:if test="isDsObservablesN"> <td><select name='dsobservable' size='3'><t:loop source="dsObservablesN" value="dsObservable"><option>${getDsObservable()}</option></t:loop></select></td></t:if>
+      <t:if test="isDsObservablesO"> <td><select name='dsobservable' size='3'><t:loop source="dsObservablesO" value="dsObservable"><option>${getDsObservable()}</option></t:loop></select></td></t:if>
+      <t:if test="isDsObservablesP"> <td><select name='dsobservable' size='3'><t:loop source="dsObservablesP" value="dsObservable"><option>${getDsObservable()}</option></t:loop></select></td></t:if>
+      </tr><tr>
+      <t:if test="isDsObservablesQ"> <td><select name='dsobservable' size='3'><t:loop source="dsObservablesQ" value="dsObservable"><option>${getDsObservable()}</option></t:loop></select></td></t:if>
+      <t:if test="isDsObservablesR"> <td><select name='dsobservable' size='3'><t:loop source="dsObservablesR" value="dsObservable"><option>${getDsObservable()}</option></t:loop></select></td></t:if>
+      <t:if test="isDsObservablesS"> <td><select name='dsobservable' size='3'><t:loop source="dsObservablesS" value="dsObservable"><option>${getDsObservable()}</option></t:loop></select></td></t:if>
+      <t:if test="isDsObservablesT"> <td><select name='dsobservable' size='3'><t:loop source="dsObservablesT" value="dsObservable"><option>${getDsObservable()}</option></t:loop></select></td></t:if>
+      <t:if test="isDsObservablesU"> <td><select name='dsobservable' size='3'><t:loop source="dsObservablesU" value="dsObservable"><option>${getDsObservable()}</option></t:loop></select></td></t:if>
+      </tr><tr>
+      <t:if test="isDsObservablesV"> <td><select name='dsobservable' size='3'><t:loop source="dsObservablesV" value="dsObservable"><option>${getDsObservable()}</option></t:loop></select></td></t:if>
+      <t:if test="isDsObservablesW"> <td><select name='dsobservable' size='3'><t:loop source="dsObservablesW" value="dsObservable"><option>${getDsObservable()}</option></t:loop></select></td></t:if>
+      <t:if test="isDsObservablesX"> <td><select name='dsobservable' size='3'><t:loop source="dsObservablesX" value="dsObservable"><option>${getDsObservable()}</option></t:loop></select></td></t:if>
+      <t:if test="isDsObservablesY"> <td><select name='dsobservable' size='3'><t:loop source="dsObservablesY" value="dsObservable"><option>${getDsObservable()}</option></t:loop></select></td></t:if>
+      </tr><tr>
+      <t:if test="isDsObservablesZ"> <td><select name='dsobservable' size='3'><t:loop source="dsObservablesZ" value="dsObservable"><option>${getDsObservable()}</option></t:loop></select></td></t:if>
+      </tr>
+
+      <tr>
+       <td colspan="5">
+          then press <input type="submit" value="START" />
+          to begin the search, or <input type="reset" value="RESET" />
+        </td>
+       </tr>
+     </table>
+     <input type="hidden" name="plength" value="10" /> 
+     <input type="hidden" name="start" value="1" /> 
+
+     </form>
+-->
+    Back to <a href="EasySearch1">EasySeach Stage 1</a>
+<!--   <t:Credits /> -->
+  </body>
+</html>


More information about the HepData-svn mailing list