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.tapestry5.annotations.*; 00008 import org.apache.tapestry5.ioc.annotations.*; 00009 import org.apache.tapestry5.services.*; 00010 00011 import org.hibernate.*; 00012 import org.hibernate.criterion.*; 00013 import java.util.*; 00014 00015 00016 public class DisplaySummary{ 00017 00018 @Inject 00019 private RequestGlobals _reqGlobals; 00020 00021 @Inject 00022 private org.hibernate.Session _session; 00023 00024 00025 public String getQueryParam(String param){ 00026 return _reqGlobals.getRequest().getParameter(param); 00027 } 00028 00029 public String getSave(){ 00030 return this.getQueryParam("string"); 00031 } 00032 00033 private Paper _paper; 00034 private Paper getPaper(){ 00035 int i1 = getSave().indexOf("d"); 00036 String id = getSave().substring(4,i1); 00037 Query q = _session.createQuery("select distinct p from Paper p where p._id = " + id); 00038 Paper _paper = (Paper) q.uniqueResult(); 00039 return _paper; 00040 } 00041 00042 private Dataset _dataset; 00043 public Dataset getDataset(){ 00044 int i1 = getSave().indexOf("d"); 00045 int i2 = getSave().indexOf("y"); 00046 String ids = getSave().substring(i1+2,i2); 00047 Dataset _dataset = this.getPaper().getDataset(Integer.parseInt(ids)); 00048 return _dataset; 00049 } 00050 00051 private YAxis _yaxis; 00052 public YAxis getYAxis(){ 00053 int i1 = getSave().indexOf("d"); 00054 int i2 = getSave().indexOf("y"); 00055 String ids = getSave().substring(i1+2,i2); 00056 String idy = getSave().substring(i2+2); 00057 YAxis _yaxis = this.getPaper().getDataset(Integer.parseInt(ids)).getYAxis(Integer.parseInt(idy)); 00058 return _yaxis; 00059 } 00060 00061 private XAxis _xaxis; 00062 public XAxis getXAxis(){ 00063 int i1 = getSave().indexOf("d"); 00064 int i2 = getSave().indexOf("y"); 00065 String ids = getSave().substring(i1+2,i2); 00066 XAxis _xaxis = this.getPaper().getDataset(Integer.parseInt(ids)).getXAxis(1); 00067 return _xaxis; 00068 } 00069 00070 public String getFirstAuthorName(){ 00071 int n = 0; 00072 String _firstauthor = ""; 00073 for (String author : getPaper().getAuthors()){ 00074 n += 1; 00075 if(n == 1) {_firstauthor = author;} 00076 } 00077 String _refdate = "xx"; 00078 for (Reference reference : getPaper().getReferences()){ 00079 _refdate = reference.getDate(); 00080 } 00081 int _lref = _refdate.length(); 00082 _firstauthor = _firstauthor + " " + _refdate.substring(_lref-2,_lref); 00083 return _firstauthor; 00084 } 00085 00086 public String getFirstExperimentName(){ 00087 int n = 0; 00088 String _firstexperiment = ""; 00089 for (Experiment experiment : getPaper().getExperiments()){ 00090 n += 1; 00091 if(n == 1) { _firstexperiment = experiment.getName();} 00092 } 00093 return _firstexperiment; 00094 } 00095 public String getFirstInformalName(){ 00096 int n = 0; 00097 String _firstinformal = ""; 00098 for (Experiment experiment : getPaper().getExperiments()){ 00099 n += 1; 00100 if(n == 1) { _firstinformal = experiment.getInformalName();} 00101 } 00102 return _firstinformal; 00103 } 00104 00105 00106 }