DisplayPaper.java

Go to the documentation of this file.
00001 package cedar.hepdata.webapp.pages;
00002 
00003 import cedar.hepdata.model.*;
00004 import cedar.hepdata.xml.*;
00005 import cedar.hepdata.db.*;
00006 
00007 import org.apache.tapestry.annotations.*;
00008 import org.apache.tapestry.services.*;
00009 
00010 import org.hibernate.*;
00011 import org.hibernate.criterion.*;
00012 import java.util.*;
00013 
00014 
00015 public class DisplayPaper{
00016 
00017     @Inject
00018     private RequestGlobals _reqGlobals;
00019 
00020     @Inject
00021     private org.hibernate.Session _session;
00022 
00023    
00024     public String getQueryParam(String param){
00025        return _reqGlobals.getRequest().getParameter(param);
00026     }
00027 
00028     public Long getCount(){
00029         return (Long) constructQuery("count").uniqueResult();
00030     }
00031 
00032 //Papers
00033     private Paper _paper;
00034     public Paper getPaper() { return _paper; }
00035     public void setPaper(Paper p) { _paper = p; }
00036    
00037     public List <Paper> getPapers(){
00038         Query q = constructQuery();
00039         // execute the query and return the list of results
00040         return q.list();   
00041     }
00042 
00043 //Datasets
00044     private Dataset _dataset;
00045     public Dataset getDataset() { return _dataset; }
00046     public void setDataset(Dataset d) { _dataset = d; }
00047     public SortedSet <Dataset> getDatasets(){
00048         return _paper.getDatasets();
00049     }
00050 
00051 //Datasets
00052     private YAxis _yaxis;
00053     public YAxis getYAxis() { return _yaxis; }
00054     public void setYAxis(YAxis y) { _yaxis = y; }
00055     public SortedSet <YAxis> getYAxes(){
00056         return _dataset.getYAxes();
00057     }
00058 
00059 
00060 
00061 
00062     private Query constructQuery(){
00063         return this.constructQuery("blank");
00064     }
00065 
00066     private Query constructQuery(String flag){
00067 
00068         String theIrn = "";
00069         if ( getQueryParam("irn")  != "") { theIrn  = getQueryParam("irn");  }
00070 
00071         Query q = null;
00072 
00073         // the string buffer way!!
00074         StringBuffer b = new StringBuffer();
00075 
00076         // assuming a spiresid search first 
00077         if(theIrn != ""){
00078             if (flag == "count"){
00079                 b.append("select count(distinct p) from Paper p where p._spiresId = :irn"); 
00080             }
00081             else{
00082                 b.append("select distinct p from Paper p where p._spiresId = :irn"); 
00083             }
00084             q = _session.createQuery(b.toString());
00085             q.setString( "irn",theIrn);
00086         }
00087         // return the list of results
00088         return q;
00089 
00090     }
00091         
00092      
00093 }

Generated on Tue Apr 21 15:55:00 2009 for HepData Web servlets by  doxygen 1.5.5