Static Public Member Functions | |
static Query | QueryString (String queryString, String flag, org.hibernate.Session _session) |
static Query | EventShapes (String flag, org.hibernate.Session _session) |
static Query | EventShapesEE (String flag, org.hibernate.Session _session) |
static Query | EventShapesNotEE (String flag, org.hibernate.Session _session) |
static Query | JetProduction (String flag, org.hibernate.Session _session) |
static Query | JetProductionEE (String flag, org.hibernate.Session _session) |
static Query | JetProductionNotEE (String flag, org.hibernate.Session _session) |
static Query | Experiment (String experiment, String flag, org.hibernate.Session _session) |
static Query | ExperimentDate (String experiment, String date, String datetype, String flag, org.hibernate.Session _session) |
static Query | Reference (String reference, String flag, org.hibernate.Session _session) |
static Query | Date (String date, String datetype, String flag, org.hibernate.Session _session) |
static Query | SpiresId (String spiresid, String flag, org.hibernate.Session _session) |
static Query | RedId (String redid, String flag, org.hibernate.Session _session) |
static Query | Author (String author, String flag, org.hibernate.Session _session) |
static Query | Physics (String experiment, String date, String datetype, String reaction, String observable, String sqrts, String flag, org.hibernate.Session _session) |
Definition at line 16 of file ConstructQueryPaper.java.
static Query QueryString | ( | String | queryString, | |
String | flag, | |||
org.hibernate.Session | _session | |||
) | [static] |
Definition at line 19 of file ConstructQueryPaper.java.
References ConstructQueryPaper.Author(), ConstructQueryPaper.Date(), ConstructQueryPaper.EventShapes(), ConstructQueryPaper.EventShapesEE(), ConstructQueryPaper.EventShapesNotEE(), ConstructQueryPaper.Experiment(), ConstructQueryPaper.ExperimentDate(), ConstructQueryPaper.JetProduction(), ConstructQueryPaper.JetProductionEE(), ConstructQueryPaper.JetProductionNotEE(), ConstructQueryPaper.Physics(), ConstructQueryPaper.RedId(), ConstructQueryPaper.Reference(), and ConstructQueryPaper.SpiresId().
00019 { 00020 // 00021 //start by removing the FIND at the beginning of the query if it is present 00022 int ix = -1; 00023 if(queryString.toUpperCase().startsWith("F ") || 00024 queryString.toUpperCase().startsWith("FI ") || 00025 queryString.toUpperCase().startsWith("FIN ") || 00026 queryString.toUpperCase().startsWith("FIND ")){ 00027 ix = queryString.indexOf(" "); 00028 } 00029 00030 // deal with > and < with no spacings, taking care of the reaction --> 00031 queryString=queryString.replaceAll("<"," < "); 00032 queryString=queryString.replaceAll(">"," > "); 00033 queryString=queryString.replaceAll("- >","->"); 00034 00035 00036 // these next lines are for the special queries on on event shapes etc... 00037 if( queryString.toUpperCase().equals("EVENTSHAPES") ){ 00038 return EventShapes(flag,_session); 00039 } 00040 else if( queryString.toUpperCase().equals("EVENTSHAPESEE") ){ 00041 return EventShapesEE(flag,_session); 00042 } 00043 else if( queryString.toUpperCase().equals("EVENTSHAPESNOTEE") ){ 00044 return EventShapesNotEE(flag,_session); 00045 } 00046 else if( queryString.toUpperCase().equals("JETPRODUCTION") ){ 00047 return JetProduction(flag,_session); 00048 } 00049 else if( queryString.toUpperCase().equals("JETPRODUCTIONEE") ){ 00050 return JetProductionEE(flag,_session); 00051 } 00052 else if( queryString.toUpperCase().equals("JETPRODUCTIONNOTEE") ){ 00053 return JetProductionNotEE(flag,_session); 00054 } 00055 System.out.println("query: " + queryString); 00056 // 00057 00058 String words[] = queryString.substring(ix+1).toUpperCase().split("\\s+AND\\s+"); 00059 String reaction = null; 00060 String observable = null; 00061 String sqrts = null; 00062 String spiresid = null; 00063 String redid = null; 00064 String experiment = null; 00065 String author = null; 00066 String reference = null; 00067 String date = null; 00068 String datetype = "="; 00069 System.out.println(queryString); 00070 for (int i=0; i<words.length; i++){ 00071 String parts[] = words[i].split("\\s+"); 00072 if( parts[0].equals("RE") || parts[0].equals("REAC") || parts[0].equals("REACTION") ) { 00073 reaction = parts[1]; 00074 for (int j=2; j<parts.length; j++){ 00075 if(parts[j].equals("HADRONS")){parts[j] = "2HADRON";} 00076 if(parts[j].equals("JETS")){parts[j] = "2JET";} 00077 reaction = reaction.concat(" " + parts[j]); 00078 } 00079 } 00080 if(parts[0].equals("OBS")) {observable = parts[1];} 00081 if(parts[0].equals("IRN")) {spiresid = parts[1];} 00082 if(parts[0].equals("RED")) {redid = parts[1];} 00083 if(parts[0].equals("EXP") || parts[0].equals("DE") || parts[0].equals("CN")) {experiment = parts[1];} 00084 if(parts[0].equals("AUTH") || parts[0].equals("A") || parts[0].equals("AUTHOR") ) {author = parts[1];} 00085 if(parts[0].equals("SQRTS") || parts[0].equals("ECM")) {sqrts = parts[1];} 00086 if(parts[0].equals("REF") || parts[0].equals("R") ) { 00087 reference = parts[1]; 00088 for (int j=2; j<parts.length; j++){ 00089 reference = reference.concat(" " + parts[j]); 00090 } 00091 } 00092 if(parts[0].equals("DATE") || parts[0].equals("YEAR") || parts[0].equals("D") ) { 00093 int next = 1; 00094 if(parts[1].equals("<") || 00095 parts[1].equals(">") ){ 00096 datetype=parts[1]; 00097 next=2; 00098 } 00099 date = parts[next]; 00100 for (int j=next+1; j<parts.length; j++){ 00101 date = date.concat(" " + parts[j]); 00102 } 00103 System.out.println(datetype); 00104 } 00105 if(parts[0].equals("FSP")){ 00106 if(parts[1].equals("HADRONS")){parts[1] = "2HADRON";} 00107 if(parts[1].equals("JETS")){parts[1] = "2JET";} 00108 reaction = "--> " + parts[1]; 00109 } 00110 if(parts[0].equals("FS")){ 00111 if(parts[1].equals("HADRONS")){parts[1] = "2HADRON";} 00112 if(parts[1].equals("JETS")){parts[1] = "2JET";} 00113 reaction = "--> " + parts[1]; 00114 for (int j=2; j<parts.length; j++){ 00115 if(parts[j].equals("HADRONS")){parts[j] = "2HADRON";} 00116 if(parts[j].equals("JETS")){parts[j] = "2JET";} 00117 reaction = reaction.concat(" " + parts[j]); 00118 } 00119 } 00120 if(parts[0].equals("BEAM") || parts[0].equals("TARG")){ 00121 reaction = parts[1]; 00122 } 00123 } 00124 if(spiresid != null) { return SpiresId(spiresid,flag,_session);} 00125 else if(redid != null) { return RedId(redid,flag,_session);} 00126 else if(author != null) { return Author(author,flag,_session);} 00127 else if(experiment != null) { 00128 if(date != null){ 00129 if(reaction != null || observable != null || sqrts != null){ 00130 return Physics(experiment,date,datetype,reaction,observable,sqrts,flag,_session); 00131 } 00132 else{ 00133 System.out.println("calling ExperimentDate" + experiment + date); 00134 return ExperimentDate(experiment,date,datetype,flag,_session); 00135 } 00136 } 00137 else{ 00138 if(reaction != null || observable != null || sqrts != null){ 00139 return Physics(experiment,date,datetype,reaction,observable,sqrts,flag,_session); 00140 } 00141 else{ 00142 return Experiment(experiment,flag,_session); 00143 } 00144 } 00145 } 00146 else if(date != null) { 00147 if(experiment !=null) { 00148 if(reaction != null || observable != null || sqrts != null){ 00149 return Physics(experiment,date,datetype,reaction,observable,sqrts,flag,_session); 00150 } 00151 else{ 00152 System.out.println("calling ExperimentDate" + experiment + date); 00153 return ExperimentDate(experiment,date,datetype,flag,_session); 00154 } 00155 } 00156 else{ 00157 if(reaction != null || observable != null || sqrts != null){ 00158 return Physics(experiment,date,datetype,reaction,observable,sqrts,flag,_session); 00159 } 00160 else{ 00161 return Date(date,datetype,flag,_session); 00162 } 00163 } 00164 } 00165 else if(reference != null) { return Reference(reference,flag,_session);} 00166 else{ return Physics(experiment,date,datetype,reaction,observable,sqrts,flag,_session); } 00167 }
static Query EventShapes | ( | String | flag, | |
org.hibernate.Session | _session | |||
) | [static] |
Definition at line 169 of file ConstructQueryPaper.java.
Referenced by ConstructQueryPaper.QueryString().
00169 { 00170 Query q=null; 00171 StringBuffer b = new StringBuffer(); 00172 00173 if (flag.equals("count")){ 00174 b.append("select count(distinct p.PAPER_ID) from Papers p"); 00175 } 00176 else{ 00177 b.append("select distinct {p.*} from Papers {p}"); 00178 } 00179 b.append(",Datasets ds"); 00180 b.append(",DsObservables dsobs"); 00181 00182 b.append(" where (dsobs.DsObservables like 'dsig/dcol%'"); 00183 b.append(" or dsobs.DsObservables like 'dn/dcol%')"); 00184 b.append(" and dsobs.DATASET_ID=ds.DATASET_ID"); 00185 00186 b.append(" and p.PAPER_ID=ds._paper_PAPER_ID"); 00187 b.append(" order by p.SpiresId desc"); 00188 00189 if(flag.equals("count")){ 00190 q = _session.createSQLQuery(b.toString()); 00191 } 00192 else{ 00193 q = _session.createSQLQuery(b.toString()).addEntity("p",Paper.class); 00194 } 00195 System.out.println(q.toString()); 00196 return q; 00197 }
static Query EventShapesEE | ( | String | flag, | |
org.hibernate.Session | _session | |||
) | [static] |
Definition at line 198 of file ConstructQueryPaper.java.
Referenced by ConstructQueryPaper.QueryString().
00198 { 00199 System.out.println("using Special"); 00200 Query q=null; 00201 StringBuffer b = new StringBuffer(); 00202 00203 if (flag.equals("count")){ 00204 b.append("select count(distinct p.PAPER_ID) from Papers p"); 00205 } 00206 else{ 00207 b.append("select distinct {p.*} from Papers {p}"); 00208 } 00209 b.append(",Datasets ds"); 00210 b.append(",DsObservables dsobs"); 00211 b.append(",DsReactions dsreac"); 00212 00213 b.append(" where (dsobs.DsObservables like 'dsig/dcol%'"); 00214 b.append(" or dsobs.DsObservables like 'dn/dcol%')"); 00215 b.append(" and dsobs.DATASET_ID=ds.DATASET_ID"); 00216 00217 b.append(" and dsreac.DsReactions like 'E+ E-%'"); 00218 b.append(" and dsreac.DATASET_ID=ds.DATASET_ID"); 00219 00220 b.append(" and p.PAPER_ID=ds._paper_PAPER_ID"); 00221 b.append(" order by p.SpiresId desc"); 00222 00223 if(flag.equals("count")){ 00224 q = _session.createSQLQuery(b.toString()); 00225 } 00226 else{ 00227 q = _session.createSQLQuery(b.toString()).addEntity("p",Paper.class); 00228 } 00229 System.out.println(q.toString()); 00230 return q; 00231 }
static Query EventShapesNotEE | ( | String | flag, | |
org.hibernate.Session | _session | |||
) | [static] |
Definition at line 232 of file ConstructQueryPaper.java.
Referenced by ConstructQueryPaper.QueryString().
00232 { 00233 System.out.println("using Special"); 00234 Query q=null; 00235 StringBuffer b = new StringBuffer(); 00236 00237 if (flag.equals("count")){ 00238 b.append("select count(distinct p.PAPER_ID) from Papers p"); 00239 } 00240 else{ 00241 b.append("select distinct {p.*} from Papers {p}"); 00242 } 00243 b.append(",Datasets ds"); 00244 b.append(", DsObservables dsobs"); 00245 b.append(", DsReactions dsreac"); 00246 00247 b.append(" where (dsobs.DsObservables like 'dsig/dcol%'"); 00248 b.append(" or dsobs.DsObservables like 'dn/dcol%')"); 00249 b.append(" and dsobs.DATASET_ID=ds.DATASET_ID"); 00250 00251 b.append(" and dsreac.DsReactions not like 'E+ E-%'"); 00252 b.append(" and dsreac.DATASET_ID=ds.DATASET_ID"); 00253 00254 b.append(" and p.PAPER_ID=ds._paper_PAPER_ID"); 00255 b.append(" order by p.SpiresId desc"); 00256 00257 if(flag.equals("count")){ 00258 q = _session.createSQLQuery(b.toString()); 00259 } 00260 else{ 00261 q = _session.createSQLQuery(b.toString()).addEntity("p",Paper.class); 00262 } 00263 System.out.println(q.toString()); 00264 return q; 00265 }
static Query JetProduction | ( | String | flag, | |
org.hibernate.Session | _session | |||
) | [static] |
Definition at line 266 of file ConstructQueryPaper.java.
Referenced by ConstructQueryPaper.QueryString().
00266 { 00267 System.out.println("using Special"); 00268 Query q=null; 00269 StringBuffer b = new StringBuffer(); 00270 00271 if (flag.equals("count")){ 00272 b.append("select count(distinct p.PAPER_ID) from Papers p"); 00273 } 00274 else{ 00275 b.append("select distinct {p.*} from Papers {p}"); 00276 } 00277 b.append(",Datasets ds"); 00278 b.append(",YAxes ya"); 00279 b.append(",AxisReactions ar"); 00280 b.append(",FinalStates fs"); 00281 00282 b.append(" where fs.ParticleName like 'JET'"); 00283 b.append(" and fs.REACTION_ID=ar.REACTION_ID"); 00284 b.append(" and ar._yAxis_AXIS_ID=ya.AXIS_ID"); 00285 b.append(" and ya._dataset_DATASET_ID=ds.DATASET_ID"); 00286 00287 b.append(" and p.PAPER_ID=ds._paper_PAPER_ID"); 00288 b.append(" order by p.SpiresId desc"); 00289 00290 if(flag.equals("count")){ 00291 q = _session.createSQLQuery(b.toString()); 00292 } 00293 else{ 00294 q = _session.createSQLQuery(b.toString()).addEntity("p",Paper.class); 00295 } 00296 System.out.println(q.toString()); 00297 return q; 00298 }
static Query JetProductionEE | ( | String | flag, | |
org.hibernate.Session | _session | |||
) | [static] |
Definition at line 299 of file ConstructQueryPaper.java.
Referenced by ConstructQueryPaper.QueryString().
00299 { 00300 System.out.println("using Special"); 00301 Query q=null; 00302 StringBuffer b = new StringBuffer(); 00303 00304 if (flag.equals("count")){ 00305 b.append("select count(distinct p.PAPER_ID) from Papers p"); 00306 } 00307 else{ 00308 b.append("select distinct {p.*} from Papers {p}"); 00309 } 00310 b.append(",Datasets ds"); 00311 b.append(",YAxes ya"); 00312 b.append(",AxisReactions ar"); 00313 b.append(",FinalStates fs"); 00314 b.append(", DsReactions dsreac"); 00315 00316 b.append(" where dsreac.DsReactions like 'E+ E-%'"); 00317 b.append(" and dsreac.DATASET_ID=ds.DATASET_ID"); 00318 00319 b.append(" and fs.ParticleName like 'JET'"); 00320 b.append(" and fs.REACTION_ID=ar.REACTION_ID"); 00321 b.append(" and ar._yAxis_AXIS_ID=ya.AXIS_ID"); 00322 b.append(" and ya._dataset_DATASET_ID=ds.DATASET_ID"); 00323 00324 b.append(" and p.PAPER_ID=ds._paper_PAPER_ID"); 00325 b.append(" order by p.SpiresId desc"); 00326 00327 if(flag.equals("count")){ 00328 q = _session.createSQLQuery(b.toString()); 00329 } 00330 else{ 00331 q = _session.createSQLQuery(b.toString()).addEntity("p",Paper.class); 00332 } 00333 System.out.println(q.toString()); 00334 return q; 00335 }
static Query JetProductionNotEE | ( | String | flag, | |
org.hibernate.Session | _session | |||
) | [static] |
Definition at line 336 of file ConstructQueryPaper.java.
Referenced by ConstructQueryPaper.QueryString().
00336 { 00337 System.out.println("using Special"); 00338 Query q=null; 00339 StringBuffer b = new StringBuffer(); 00340 00341 if (flag.equals("count")){ 00342 b.append("select count(distinct p.PAPER_ID) from Papers p"); 00343 } 00344 else{ 00345 b.append("select distinct {p.*} from Papers {p}"); 00346 } 00347 b.append(",Datasets ds"); 00348 b.append(",YAxes ya"); 00349 b.append(",AxisReactions ar"); 00350 b.append(",FinalStates fs"); 00351 b.append(", DsReactions dsreac"); 00352 00353 b.append(" where dsreac.DsReactions not like 'E+ E-%'"); 00354 b.append(" and dsreac.DATASET_ID=ds.DATASET_ID"); 00355 00356 b.append(" and fs.ParticleName like 'JET'"); 00357 b.append(" and fs.REACTION_ID=ar.REACTION_ID"); 00358 b.append(" and ar._yAxis_AXIS_ID=ya.AXIS_ID"); 00359 b.append(" and ya._dataset_DATASET_ID=ds.DATASET_ID"); 00360 00361 b.append(" and p.PAPER_ID=ds._paper_PAPER_ID"); 00362 b.append(" order by p.SpiresId desc"); 00363 00364 if(flag.equals("count")){ 00365 q = _session.createSQLQuery(b.toString()); 00366 } 00367 else{ 00368 q = _session.createSQLQuery(b.toString()).addEntity("p",Paper.class); 00369 } 00370 System.out.println(q.toString()); 00371 return q; 00372 }
static Query Experiment | ( | String | experiment, | |
String | flag, | |||
org.hibernate.Session | _session | |||
) | [static] |
Definition at line 374 of file ConstructQueryPaper.java.
Referenced by ConstructQueryPaper.QueryString().
00374 { 00375 System.out.println("using Experiment"); 00376 String theExp=experiment; 00377 Query q=null; 00378 StringBuffer b = new StringBuffer(); 00379 00380 if (flag.equals("count")){ 00381 b.append("select count(distinct p) from Paper p"); 00382 } 00383 else{ 00384 b.append("select distinct p from Paper p"); 00385 } 00386 b.append(" join p._experiments exp"); 00387 b.append(" where (exp._name like '%"); 00388 b.append(experiment); 00389 b.append("%'"); 00390 b.append(" or exp._informalName like '%"); 00391 b.append(experiment); 00392 b.append("%')"); 00393 b.append(" order by p._spiresId desc"); 00394 q = _session.createQuery(b.toString()); 00395 System.out.println(q.toString()); 00396 // q.setString("exp",theExp); 00397 00398 return q; 00399 }
static Query ExperimentDate | ( | String | experiment, | |
String | date, | |||
String | datetype, | |||
String | flag, | |||
org.hibernate.Session | _session | |||
) | [static] |
Definition at line 401 of file ConstructQueryPaper.java.
Referenced by ConstructQueryPaper.QueryString().
00401 { 00402 System.out.println("using ExperimentDate"); 00403 String theDate=date; 00404 String theExp=experiment; 00405 Query q=null; 00406 StringBuffer b = new StringBuffer(); 00407 00408 if (flag.equals("count")){ 00409 b.append("select count(distinct p) from Paper p"); 00410 } 00411 else{ 00412 b.append("select distinct p from Paper p"); 00413 } 00414 b.append(" join p._experiments exp"); 00415 b.append(" join p._references ref"); 00416 b.append(" where (exp._name like '%"); 00417 b.append(experiment); 00418 b.append("%'"); 00419 b.append(" or exp._informalName like '%"); 00420 b.append(experiment); 00421 b.append("%')"); 00422 00423 if(datetype.equals("=")){ 00424 b.append(" and ref._date like '%"); 00425 b.append(date); 00426 b.append("'"); 00427 } 00428 else{ 00429 b.append(" and ref._date " + datetype); 00430 b.append(date); 00431 b.append(" and ref._date not like ''"); 00432 } 00433 b.append(" order by p._spiresId desc"); 00434 00435 q = _session.createQuery(b.toString()); 00436 System.out.println(q.toString()); 00437 // q.setString("date",theDate); 00438 00439 return q; 00440 }
static Query Reference | ( | String | reference, | |
String | flag, | |||
org.hibernate.Session | _session | |||
) | [static] |
Definition at line 442 of file ConstructQueryPaper.java.
Referenced by ConstructQueryPaper.QueryString().
00442 { 00443 System.out.println("using Reference"); 00444 String theRef=reference; 00445 Query q=null; 00446 StringBuffer b = new StringBuffer(); 00447 00448 if (flag.equals("count")){ 00449 b.append("select count(distinct p) from Paper p"); 00450 } 00451 else{ 00452 b.append("select distinct p from Paper p"); 00453 } 00454 b.append(" join p._references ref"); 00455 b.append(" where ref._description like '"); 00456 b.append(reference); 00457 b.append("'"); 00458 b.append(" order by p._spiresId desc"); 00459 q = _session.createQuery(b.toString()); 00460 // q.setString("ref",theRef); 00461 00462 return q; 00463 }
static Query Date | ( | String | date, | |
String | datetype, | |||
String | flag, | |||
org.hibernate.Session | _session | |||
) | [static] |
Definition at line 465 of file ConstructQueryPaper.java.
Referenced by ConstructQueryPaper.QueryString().
00465 { 00466 System.out.println("using Date"); 00467 String theDate=date; 00468 Query q=null; 00469 StringBuffer b = new StringBuffer(); 00470 00471 if (flag.equals("count")){ 00472 b.append("select count(distinct p) from Paper p"); 00473 } 00474 else{ 00475 b.append("select distinct p from Paper p"); 00476 } 00477 b.append(" join p._references ref"); 00478 if(datetype.equals("=")){ 00479 b.append(" where ref._date like '%"); 00480 b.append(date); 00481 b.append("'"); 00482 } 00483 else{ 00484 b.append(" where ref._date " + datetype); 00485 b.append(date); 00486 b.append(" and ref._date not like ''"); 00487 } 00488 b.append(" order by p._spiresId desc"); 00489 q = _session.createQuery(b.toString()); 00490 // q.setString("date",theDate); 00491 00492 return q; 00493 }
static Query SpiresId | ( | String | spiresid, | |
String | flag, | |||
org.hibernate.Session | _session | |||
) | [static] |
Definition at line 495 of file ConstructQueryPaper.java.
Referenced by ConstructQueryPaper.QueryString().
00495 { 00496 System.out.println("using SpiresId"); 00497 String theIrn=spiresid; 00498 Query q=null; 00499 StringBuffer b = new StringBuffer(); 00500 00501 if (flag.equals("count")){ 00502 b.append("select count(distinct p) from Paper p"); 00503 } 00504 else{ 00505 b.append("select distinct p from Paper p"); 00506 } 00507 b.append(" where p._spiresId like '"); 00508 b.append(spiresid); 00509 b.append("' order by p._spiresId desc"); 00510 q = _session.createQuery(b.toString()); 00511 // q.setString("exp",theExp); 00512 00513 return q; 00514 }
static Query RedId | ( | String | redid, | |
String | flag, | |||
org.hibernate.Session | _session | |||
) | [static] |
Definition at line 516 of file ConstructQueryPaper.java.
Referenced by ConstructQueryPaper.QueryString().
00516 { 00517 System.out.println("using RedId"); 00518 Query q=null; 00519 StringBuffer b = new StringBuffer(); 00520 00521 if (flag.equals("count")){ 00522 b.append("select count(distinct p) from Paper p"); 00523 } 00524 else{ 00525 b.append("select distinct p from Paper p"); 00526 } 00527 b.append(" where p._redId like '"); 00528 b.append(redid); 00529 b.append("' order by p._spiresId desc"); 00530 q = _session.createQuery(b.toString()); 00531 00532 return q; 00533 }
static Query Author | ( | String | author, | |
String | flag, | |||
org.hibernate.Session | _session | |||
) | [static] |
Definition at line 535 of file ConstructQueryPaper.java.
Referenced by ConstructQueryPaper.QueryString().
00535 { 00536 String theAuth=author; 00537 Query q=null; 00538 StringBuffer b = new StringBuffer(); 00539 00540 if (flag.equals("count")){ 00541 b.append("select count(p.HepdataId) from Papers p, PaperAuthors pa"); 00542 } 00543 else{ 00544 b.append("select * from Papers p, PaperAuthors pa"); 00545 } 00546 b.append(" where p.PAPER_ID=pa.PAPER_ID"); 00547 b.append(" and pa.element like '"); 00548 b.append(author); 00549 b.append("' order by p.SpiresId desc"); 00550 if(flag.equals("count")){ 00551 q = _session.createSQLQuery(b.toString()); 00552 } 00553 else{ 00554 q = _session.createSQLQuery(b.toString()).addEntity("p",Paper.class); 00555 } 00556 return q; 00557 }
static Query Physics | ( | String | experiment, | |
String | date, | |||
String | datetype, | |||
String | reaction, | |||
String | observable, | |||
String | sqrts, | |||
String | flag, | |||
org.hibernate.Session | _session | |||
) | [static] |
Definition at line 560 of file ConstructQueryPaper.java.
Referenced by ConstructQueryPaper.QueryString().
00560 { 00561 System.out.println("using Physics"); 00562 00563 List <String> isp = new ArrayList(); 00564 List <String> fsp = new ArrayList(); 00565 List <String> mfsp = new ArrayList(); 00566 List <String> misp = new ArrayList(); 00567 00568 System.out.println("Here we are in Papers"); 00569 System.out.println("sorting reaction: " + reaction); 00571 if( reaction != null && !reaction.equals("") && !reaction.equals("null")) { 00573 String is = getInitialState(reaction); 00574 java.util.StringTokenizer stis = new java.util.StringTokenizer(is); 00575 String st = ""; 00576 while(stis.hasMoreTokens()){ 00577 st = stis.nextToken(); 00578 if(st.matches("^[A-Za-z].*")){ 00579 if(isp.isEmpty()){ 00580 isp.add(st); 00581 misp.add("1"); 00582 } 00583 else{ 00584 int isize = isp.size(); 00585 for (int i=0; i<isize; i++){ 00586 if(isp.get(i).equals(st)){ 00587 int n = Integer.parseInt(misp.get(i)); 00588 n += 1; 00589 misp.set(i,Integer.toString(n)); 00590 } 00591 else{ 00592 isp.add(st); 00593 misp.add("1"); 00594 } 00595 } 00596 } 00597 } 00598 else{ 00599 isp.add(st.substring(1)); 00600 misp.add(st.substring(0,1)); 00601 } 00602 // isp.add(stis.nextToken()); 00603 } 00604 String fs = getFinalState(reaction); 00605 java.util.StringTokenizer stfs = new java.util.StringTokenizer(fs); 00606 while(stfs.hasMoreTokens()){ 00607 st = stfs.nextToken(); 00608 if(st.matches("^[A-Za-z].*")){ 00609 if(fsp.isEmpty()){ 00610 fsp.add(st); 00611 mfsp.add("1"); 00612 } 00613 else{ 00614 int fsize = fsp.size(); 00615 for (int i=0; i<fsize; i++){ 00616 if(fsp.get(i).equals(st)){ 00617 int n = Integer.parseInt(mfsp.get(i)); 00618 n += 1; 00619 mfsp.set(i,Integer.toString(n)); 00620 } 00621 else{ 00622 fsp.add(st); 00623 mfsp.add("1"); 00624 } 00625 } 00626 } 00627 } 00628 else{ 00629 fsp.add(st.substring(1)); 00630 mfsp.add(st.substring(0,1)); 00631 } 00632 } 00633 } 00634 String theObs = ""; 00635 if ( observable != null && !observable.equals("") && !observable.equals("null") ) { theObs = observable; } 00636 00637 String theSqrtsLo = ""; 00638 System.out.println("sqrts is: " + sqrts); 00639 if ( sqrts != null && !sqrts.equals("") && !sqrts.equals("null")) { theSqrtsLo = sqrts; System.out.println(sqrts); } 00640 00641 Query q = null; 00642 00643 // the string buffer way!! 00644 StringBuffer b = new StringBuffer(); 00645 00646 if(isp.size() > 0){ 00647 //select... 00648 System.out.println("we have an intial state " + isp + "/" + misp); 00649 System.out.println("and final state " + fsp + "/" + mfsp ); 00650 System.out.println("and observable " + observable); 00651 if (flag.equals("count")){ 00652 b.append("select count(distinct pbeam) from Paper pbeam"); 00653 } 00654 else{ 00655 b.append("select distinct pbeam from Paper pbeam"); 00656 } 00657 //joins.... 00658 if(experiment != null) {b.append(" join pbeam._experiments exp");} 00659 if(date != null) {b.append(" join pbeam._references ref");} 00660 b.append(" join pbeam._datasets dsbeam"); 00661 b.append(" join dsbeam._yAxes yabeam"); 00662 b.append(" join yabeam._reactions yrbeam"); 00663 b.append(" join yrbeam._initialState beam"); 00664 if (isp.size() > 1){ 00665 b.append(",Paper ptarg"); 00666 b.append(" join ptarg._datasets dstarg"); 00667 b.append(" join dstarg._yAxes yatarg"); 00668 b.append(" join yatarg._reactions yrtarg"); 00669 b.append(" join yrtarg._initialState targ"); 00670 } 00671 for (int i = 1 ; i <= fsp.size(); i++){ 00672 b.append(",Paper pfsp"+i); 00673 b.append(" join pfsp"+i+"._datasets dsfsp"+i); 00674 b.append(" join dsfsp"+i+"._yAxes yafsp"+i); 00675 b.append(" join yafsp"+i+"._reactions yrfsp"+i); 00676 b.append(" join yrfsp"+i+"._finalState fsp"+i); 00677 } 00678 if( theSqrtsLo != null && !theSqrtsLo.equals("") && !theSqrtsLo.equals("null") ){ 00679 b.append(",Paper pprop"); 00680 b.append(" join pprop._datasets dsprop"); 00681 b.append(" join dsprop._yAxes yaprop"); 00682 b.append(" join yaprop._properties prop"); 00683 } 00684 //where... 00685 b.append(" where beam.name like :beampart and beam.multiplicity=:beammult"); 00686 if(experiment != null){ 00687 b.append(" and (exp._name like '%"); 00688 b.append(experiment); 00689 b.append("%'"); 00690 b.append(" or exp._informalName like '%"); 00691 b.append(experiment); 00692 b.append("%')"); 00693 } 00694 if(date != null){ 00695 if(datetype.equals("=")){ 00696 b.append(" and ref._date like '%"); 00697 b.append(date); 00698 b.append("'");} 00699 else{ 00700 b.append(" and ref._date " + datetype); 00701 b.append(date); 00702 b.append(" and ref._date not like ''"); 00703 } 00704 } 00705 if (isp.size() > 1){ 00706 b.append(" and targ.name=:targpart"); 00707 b.append(" and yrbeam = yrtarg"); 00708 } 00709 for (int i = 1 ; i <= fsp.size(); i++){ 00710 b.append(" and fsp"+i+".name like :fsp"+i+"part and fsp"+i+".multiplicity=:fsp"+i+"mult"); 00711 b.append(" and yrbeam = yrfsp"+i); 00712 } 00713 if ( theObs != null && !theObs.equals("") && !theObs.equals("null") ) { b.append(" and yabeam._observable like:observable"); } 00714 if ( theSqrtsLo != null && !theSqrtsLo.equals("") && !theSqrtsLo.equals("null") ){ 00715 b.append(" and yabeam = yaprop"); 00716 b.append(" and prop._name like 'sqrts' and prop._lowValue>:sqrtslo"); 00717 } 00718 // sort 00719 b.append(" order by pbeam._spiresId desc"); 00720 //create query 00721 //make substitutions 00722 q = _session.createQuery(b.toString()); 00723 q.setString("beampart",isp.get(0)); 00724 q.setString("beammult",misp.get(0)); 00725 if (isp.size() > 1) {q.setString( "targpart",isp.get(1)); } 00726 for (int i = 1 ; i <= fsp.size(); i++){ 00727 q.setString( "fsp"+i+"part",fsp.get(i-1)); 00728 q.setString( "fsp"+i+"mult",mfsp.get(i-1)); 00729 } 00730 // System.out.println(q.toString()); 00731 if ( theObs != null && !theObs.equals("") && !theObs.equals("null") ) {q.setString( "observable",theObs); } 00732 if ( theSqrtsLo != null && !theSqrtsLo.equals("") && !theSqrtsLo.equals("null") ) {q.setString( "sqrtslo",theSqrtsLo); } 00733 } 00734 00735 // no inital state so next assuming we have a fsp 00736 else if(fsp.size() > 0) { 00737 //select(no initialstate)... 00738 if (flag.equals("count")){ 00739 b.append("select count(distinct pfsp1) from Paper pfsp1"); 00740 } 00741 else{ 00742 b.append("select distinct pfsp1 from Paper pfsp1"); 00743 } 00744 //joins(no initialstate)... 00745 if(experiment != null) {b.append(" join pfsp1._experiments exp");} 00746 if(date != null) {b.append(" join pfsp1._references ref");} 00747 b.append(" join pfsp1._datasets dsfsp1"); 00748 b.append(" join dsfsp1._yAxes yafsp1"); 00749 b.append(" join yafsp1._reactions yrfsp1"); 00750 b.append(" join yrfsp1._finalState fsp1"); 00751 for (int i = 2 ; i <= fsp.size(); i++){ 00752 b.append(",Paper pfsp"+i); 00753 b.append(" join pfsp"+i+"._datasets dsfsp"+i); 00754 b.append(" join dsfsp"+i+"._yAxes yafsp"+i); 00755 b.append(" join yafsp"+i+"._reactions yrfsp"+i); 00756 b.append(" join yrfsp"+i+"._finalState fsp"+i); 00757 } 00758 if ( theSqrtsLo != null && !theSqrtsLo.equals("") && !theSqrtsLo.equals("null") ) { 00759 b.append(",Paper pprop"); 00760 b.append(" join pprop._datasets dsprop"); 00761 b.append(" join dsprop._yAxes yaprop"); 00762 b.append(" join yaprop._properties prop"); 00763 } 00764 //where(no initialstate)... 00765 b.append(" where fsp1.name like :fsp1part and fsp1.multiplicity=:fsp1mult"); 00766 if(experiment != null){ 00767 b.append(" and (exp._name like '%"); 00768 b.append(experiment); 00769 b.append("%'"); 00770 b.append(" or exp._informalName like '%"); 00771 b.append(experiment); 00772 b.append("%')"); 00773 } 00774 if(date != null){ 00775 if(datetype.equals("=")){ 00776 b.append(" and ref._date like '%"); 00777 b.append(date); 00778 b.append("'");} 00779 else{ 00780 b.append(" and ref._date " + datetype); 00781 b.append(date); 00782 b.append(" and ref._date not like ''"); 00783 } 00784 } 00785 for (int i = 2 ; i <= fsp.size(); i++){ 00786 b.append(" and fsp"+i+".name like :fsp"+i+"part and fsp"+i+".multiplicity=:fsp"+i+"mult"); 00787 b.append(" and yrfsp1 = yrfsp"+i); 00788 } 00789 if ( theObs != null && !theObs.equals("") && !theObs.equals("null") ) { b.append(" and yafsp1._observable like:observable"); } 00790 if ( theSqrtsLo != null && !theSqrtsLo.equals("") && !theSqrtsLo.equals("null") ) { 00791 b.append(" and yafsp1 = yaprop"); 00792 b.append(" and prop._name like 'sqrts' and prop._lowValue>:sqrtslo"); 00793 } 00794 b.append(" order by pfsp1._spiresId desc"); 00795 //create query... 00796 q = _session.createQuery(b.toString()); 00797 //make substitutions... 00798 for (int i = 1 ; i <= fsp.size(); i++){ 00799 q.setString("fsp"+i+"part",fsp.get(i-1)); 00800 q.setString("fsp"+i+"mult",mfsp.get(i-1)); 00801 } 00802 if ( theObs != null && !theObs.equals("") && !theObs.equals("null") ) {q.setString("observable",theObs);} 00803 if ( theSqrtsLo != null && !theSqrtsLo.equals("") && !theSqrtsLo.equals("null") ) {q.setString( "sqrtslo",theSqrtsLo); } 00804 } 00805 // OK no reaction .. so do we have an observable? 00807 else if ( theObs != null && !theObs.equals("") && !theObs.equals("null") ) { 00808 //> here we have no reaction but an observable 00809 if (flag.equals("count")){ 00810 b.append("select count(distinct pobs) from Paper pobs"); 00811 } 00812 else{ 00813 b.append("select distinct pobs from Paper pobs"); 00814 } 00815 if(experiment != null) {b.append(" join pobs._experiments exp");} 00816 if(date != null) {b.append(" join pobs._references ref");} 00817 b.append(" join pobs._datasets dsobs join dsobs._yAxes yaobs"); 00818 if ( theSqrtsLo != null && !theSqrtsLo.equals("") && !theSqrtsLo.equals("null") ) { 00819 b.append(",Paper pprop"); 00820 b.append(" join pprop._datasets dsprop"); 00821 b.append(" join dsprop._yAxes yaprop"); 00822 b.append(" join yaprop._properties prop"); 00823 } 00824 b.append(" where yaobs._observable like:observable"); 00825 if(experiment != null){ 00826 b.append(" and (exp._name like '%"); 00827 b.append(experiment); 00828 b.append("%'"); 00829 b.append(" or exp._informalName like '%"); 00830 b.append(experiment); 00831 b.append("%')"); 00832 } 00833 if(date != null){ 00834 if(datetype.equals("=")){ 00835 b.append(" and ref._date like '%"); 00836 b.append(date); 00837 b.append("'");} 00838 else{ 00839 b.append(" and ref._date " + datetype); 00840 b.append(date); 00841 b.append(" and ref._date not like ''"); 00842 } 00843 } 00844 if ( theSqrtsLo != null && !theSqrtsLo.equals("") && !theSqrtsLo.equals("null") ) { 00845 b.append(" and yaobs = yaprop"); 00846 b.append(" and prop._name like 'sqrts' and prop._lowValue>:sqrtslo"); 00847 } 00848 b.append(" order by pobs._spiresId desc"); 00849 q = _session.createQuery(b.toString()); 00850 q.setString("observable",theObs); 00851 if ( theSqrtsLo != null && !theSqrtsLo.equals("") && !theSqrtsLo.equals("null") ) {q.setString( "sqrtslo",theSqrtsLo); } 00852 } 00853 00854 // here if sqrtslo on its own ! just to test 00855 else if ( theSqrtsLo != null && !theSqrtsLo.equals("") && !theSqrtsLo.equals("null") ) { 00856 if (flag.equals("count")){ 00857 b.append("select count(distinct pprop) from Paper pprop"); 00858 } 00859 else{ 00860 b.append("select distinct pprop from Paper pprop"); 00861 } 00862 if(experiment != null) {b.append(" join pprop._experiments exp");} 00863 if(date != null) {b.append(" join pprop._references ref");} 00864 b.append(" join pprop._datasets dsprop"); 00865 b.append(" join dsprop._yAxes yaprop"); 00866 b.append(" join yaprop._properties prop"); 00867 00868 b.append(" where prop._name like 'sqrts' and prop._lowValue>:sqrtslo"); 00869 if(experiment != null){ 00870 b.append(" and (exp._name like '%"); 00871 b.append(experiment); 00872 b.append("%'"); 00873 b.append(" or exp._informalName like '%"); 00874 b.append(experiment); 00875 b.append("%')"); 00876 } 00877 if(date != null){ 00878 if(datetype.equals("=")){ 00879 b.append(" and ref._date like '%"); 00880 b.append(date); 00881 b.append("'");} 00882 else{ 00883 b.append(" and ref._date " + datetype); 00884 b.append(date); 00885 b.append(" and ref._date not like ''"); 00886 } 00887 } 00888 b.append(" order by pprop._spiresId desc"); 00889 q = _session.createQuery(b.toString()); 00890 q.setString("sqrtslo",theSqrtsLo); 00891 } 00892 // nothing left so must want everything !! 00893 else{ 00894 if (flag.equals("count")){ 00895 b.append("select count(distinct pa) from Paper pa"); 00896 } 00897 else{ 00898 b.append("select distinct pa from Paper pa"); 00899 } 00900 b.append(" order by pa._spiresId desc"); 00901 q = _session.createQuery(b.toString()); 00902 } 00903 00904 System.out.println(q.toString()); 00905 return q; 00906 00907 }