Public Member Functions | |
String | getQueryParam (String param) |
Long | getCount () |
YAxis | getYAxis () |
void | setYAxis (YAxis y) |
List< YAxis > | getYAxes () |
Query | constructQuery () |
Query | constructQuery (String flag) |
Long | getSpiresId () |
Definition at line 16 of file TestSearch.java.
String getQueryParam | ( | String | param | ) |
Definition at line 25 of file TestSearch.java.
Referenced by TestSearch.constructQuery(), and TestSearch.getYAxes().
Long getCount | ( | ) |
Definition at line 29 of file TestSearch.java.
References TestSearch.constructQuery().
00029 { 00030 return (Long) constructQuery("count").uniqueResult(); 00031 }
YAxis getYAxis | ( | ) |
void setYAxis | ( | YAxis | y | ) |
List<YAxis> getYAxes | ( | ) |
Definition at line 40 of file TestSearch.java.
References TestSearch.constructQuery(), and TestSearch.getQueryParam().
00040 { 00041 Query q = constructQuery(); 00042 // how many results do we want out 00043 q.setMaxResults(Integer.parseInt(getQueryParam("number"))); 00044 // execute the query and return the list of results 00045 return q.list(); 00046 }
Query constructQuery | ( | ) |
Definition at line 48 of file TestSearch.java.
Referenced by TestSearch.getCount(), and TestSearch.getYAxes().
Query constructQuery | ( | String | flag | ) |
Definition at line 52 of file TestSearch.java.
References TestSearch.getQueryParam().
00052 { 00053 00054 String theBeam = ""; 00055 String theTarg = ""; 00056 String theFsp1 = ""; 00057 String theFsp2 = ""; 00058 String theFsp3 = ""; 00059 String theMFsp1 = ""; 00060 String theMFsp2 = ""; 00061 String theMFsp3 = ""; 00062 String theObs = ""; 00063 if ( getQueryParam("beam") != "") { theBeam = getQueryParam("beam"); } 00064 if ( getQueryParam("targ") != "") { theTarg = getQueryParam("targ"); } 00065 if ( getQueryParam("fsp1") != "") { theFsp1 = getQueryParam("fsp1"); } 00066 if ( getQueryParam("mfsp1") != ""){ theMFsp1 = getQueryParam("mfsp1"); } 00067 if ( getQueryParam("fsp2") != "") { theFsp2 = getQueryParam("fsp2"); } 00068 if ( getQueryParam("mfsp2") != ""){ theMFsp2 = getQueryParam("mfsp2"); } 00069 if ( getQueryParam("fsp3") != "") { theFsp3 = getQueryParam("fsp3"); } 00070 if ( getQueryParam("mfsp3") != ""){ theMFsp3 = getQueryParam("mfsp3"); } 00071 if ( getQueryParam("obs") != "") { theObs = getQueryParam("obs"); } 00072 00073 Query q = null; 00074 00075 // the string buffer way!! 00076 StringBuffer b = new StringBuffer(); 00077 00078 // assuming we have a beam particle first 00079 if(theBeam != ""){ 00080 if (flag == "count"){ 00081 b.append("select count(yabeam) from YAxis yabeam join yabeam._reactions yrbeam join yrbeam._initialState beam"); 00082 } 00083 else{ 00084 b.append("select distinct yabeam from YAxis yabeam join yabeam._reactions yrbeam join yrbeam._initialState beam"); 00085 } 00086 if (theTarg != ""){ b.append(",YAxis yatarg join yatarg._reactions yrtarg join yrtarg._initialState targ"); } 00087 if (theFsp1 != ""){ b.append(",YAxis yafsp1 join yafsp1._reactions yrfsp1 join yrfsp1._finalState fsp1"); } 00088 if (theFsp2 != ""){ b.append(",YAxis yafsp2 join yafsp2._reactions yrfsp2 join yrfsp2._finalState fsp2"); } 00089 if (theFsp3 != ""){ b.append(",YAxis yafsp3 join yafsp3._reactions yrfsp3 join yrfsp3._finalState fsp3"); } 00090 b.append(" where beam.name=:beampart"); 00091 if (theTarg != ""){ b.append(" and targ.name=:targpart"); } 00092 if (theFsp1 != ""){ b.append(" and fsp1.name=:fsp1part and fsp1.multiplicity=:fsp1mult"); } 00093 if (theFsp2 != ""){ b.append(" and fsp2.name=:fsp2part and fsp2.multiplicity=:fsp2mult"); } 00094 if (theFsp3 != ""){ b.append(" and fsp3.name=:fsp3part and fsp3.multiplicity=:fsp3mult"); } 00095 if (theObs != ""){ b.append(" and yabeam._observable=:observable"); } 00096 if (theTarg != ""){ b.append(" and yrbeam = yrtarg"); } 00097 if (theFsp1 != ""){ b.append(" and yrbeam = yrfsp1"); } 00098 if (theFsp2 != ""){ b.append(" and yrbeam = yrfsp2"); } 00099 if (theFsp3 != ""){ b.append(" and yrbeam = yrfsp3"); } 00100 q = _session.createQuery(b.toString()); 00101 q.setString("beampart",theBeam); 00102 if (theTarg != "") {q.setString( "targpart",theTarg); } 00103 if (theFsp1 != "") {q.setString( "fsp1part",theFsp1); } 00104 if (theFsp2 != "") {q.setString( "fsp2part",theFsp2); } 00105 if (theFsp3 != "") {q.setString( "fsp3part",theFsp3); } 00106 if (theFsp1 != "") {q.setString( "fsp1mult",theMFsp1); } 00107 if (theFsp2 != "") {q.setString( "fsp2mult",theMFsp2); } 00108 if (theFsp3 != "") {q.setString( "fsp3mult",theMFsp3); } 00109 if (theObs != "") {q.setString( "observable",theObs); } 00110 } 00111 00112 // no inital state so next assuming we have a fsp 00113 else if(theFsp1 != "") { 00114 if (flag == "count"){ 00115 b.append("select count(yafsp1) from YAxis yafsp1 join yafsp1._reactions yrfsp1 join yrfsp1._finalState fsp1"); 00116 } 00117 else { 00118 b.append("select distinct yafsp1 from YAxis yafsp1 join yafsp1._reactions yrfsp1 join yrfsp1._finalState fsp1"); 00119 } 00120 if (theFsp2 != ""){ b.append(",YAxis yafsp2 join yafsp2._reactions yrfsp2 join yrfsp2._finalState fsp2"); } 00121 if (theFsp3 != ""){ b.append(",YAxis yafsp3 join yafsp3._reactions yrfsp3 join yrfsp3._finalState fsp3"); } 00122 b.append(" where fsp1.name=:fsp1part and fsp1.multiplicity=:fsp1mult"); 00123 if (theFsp2 != ""){ b.append(" and fsp2.name=:fsp2part and fsp2.multiplicity=:fsp2mult"); } 00124 if (theFsp3 != ""){ b.append(" and fsp3.name=:fsp3part and fsp3.multiplicity=:fsp3mult"); } 00125 if (theObs != ""){ b.append(" and yafsp1._observable=:observable"); } 00126 if (theFsp2 != ""){ b.append(" and yrfsp1 = yrfsp2"); } 00127 if (theFsp3 != ""){ b.append(" and yrfsp1 = yrfsp3"); } 00128 q = _session.createQuery(b.toString()); 00129 q.setString("fsp1part",theFsp1); q.setString("fsp1mult",theMFsp1); 00130 if (theFsp2 != "") {q.setString("fsp2part",theFsp2); q.setString("fsp2mult",theMFsp2);} 00131 if (theFsp3 != "") {q.setString("fsp3part",theFsp3); q.setString("fsp3mult",theMFsp3);} 00132 if (theObs != "") {q.setString("observable",theObs);} 00133 } 00134 00135 // OK no reaction .. so do we have an observable? 00136 else if(theObs != "") { 00137 if (flag == "count"){ 00138 b.append("select count(yaobs) from YAxis yaobs"); 00139 } 00140 else { 00141 b.append("select distinct yaobs from YAxis yaobs"); 00142 } 00143 b.append(" where yaobs._observable=:observable"); 00144 q = _session.createQuery(b.toString()); 00145 q.setString("observable",theObs); 00146 } 00147 00148 // nothing left so must want everything !! 00149 else { 00150 if (flag == "count"){ 00151 b.append("select count(ya) from YAxis ya"); 00152 } 00153 else { 00154 b.append("select distinct ya from YAxis ya"); 00155 } 00156 q = _session.createQuery(b.toString()); 00157 } 00158 00159 return q; 00160 }
Long getSpiresId | ( | ) |