|
[HepData-svn] r1919 - trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/queryblackhole at projects.hepforge.org blackhole at projects.hepforge.orgThu Jan 28 16:46:04 GMT 2016
Author: whalley Date: Thu Jan 28 16:46:04 2016 New Revision: 1919 Log: modifications for keywords Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/query/ConstructQueryPaper.java Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/query/ConstructQueryPaper.java ============================================================================== --- trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/query/ConstructQueryPaper.java Thu Jan 28 16:43:28 2016 (r1918) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/query/ConstructQueryPaper.java Thu Jan 28 16:46:04 2016 (r1919) @@ -206,9 +206,51 @@ } } else if(reference != null) { return Reference(reference,flag,_session);} + else if(spiresid==null&&inspireid==null&&doi==null&&redid==null&&author==null&&dsreaction==null&&experiment==null&&date==null&&reference==null&&reaction==null&&observable==null&&sqrts==null){ + return Keyword(queryString,flag,_session); + } else{ return Physics(experiment,date,datetype,reaction,observable,sqrts,sqrtstype,flag,_session); } } ////// Special constructors/// + public static Query Keyword(String queryString, String flag, org.hibernate.Session _session){ + queryString=queryString.replaceAll(" and "," AND "); + String queries[] = queryString.split(" AND "); + Query q=null; + StringBuffer b = new StringBuffer(); + if(flag.equals("count")){ + b.append("select count(distinct p1.PAPER_ID) from Papers p1"); + } + else { + b.append("select distinct {p1.*} from Papers {p1}"); + } + b.append(",DsKeywords dk1, Datasets d1"); + for (int i=2; i<=queries.length; i++){ + String istr=String.valueOf(i); + b.append(",Papers p"+istr); + b.append(",DsKeywords dk"+istr+", Datasets d"+istr); + } + for (int i=1; i<=queries.length; i++){ + String istr=String.valueOf(i); + if(i==1) { + b.append(" where p1.PAPER_ID=d1._paper_PAPER_ID"); + b.append(" and p1.PAPER_ID=p1.PAPER_ID"); + } + else{ b.append(" and p1.PAPER_ID=d"+istr+"._paper_PAPER_ID");} + b.append(" and p1.PAPER_ID=p"+istr+".PAPER_ID"); + b.append(" and d"+istr+".DATASET_ID=dk"+istr+".DATASET_ID"); + b.append(" and dk"+istr+".Keyword like "); + b.append("'"+queries[i-1]+"'"); + } + b.append(" order by p1.HepdataId desc"); + + if(flag.equals("count")){ + q = _session.createSQLQuery(b.toString()); + } + else{ + q = _session.createSQLQuery(b.toString()).addEntity("p1",Paper.class); + } + return q; + } public static Query EventShapes(String flag,org.hibernate.Session _session){ Query q=null; StringBuffer b = new StringBuffer();
More information about the HepData-svn mailing list |