|
[HepData-svn] r1489 - trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pagesblackhole at projects.hepforge.org blackhole at projects.hepforge.orgFri Nov 25 12:03:51 GMT 2011
Author: whalley Date: Fri Nov 25 12:03:51 2011 New Revision: 1489 Log: adding code for multiple record display Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/ViewBase.java Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/ViewBase.java ============================================================================== --- trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/ViewBase.java Thu Nov 24 15:28:47 2011 (r1488) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/ViewBase.java Fri Nov 25 12:03:51 2011 (r1489) @@ -211,6 +211,27 @@ } return ctx; } + public List<String> getHDPaper1Context() { + List<String> ctx = new Vector<String>(); + if (getPaper1() != null) { + ctx.add("p" + getPaper1().getId()); + } + return ctx; + } + public List<String> getHDPaper2Context() { + List<String> ctx = new Vector<String>(); + if (getPaper2() != null) { + ctx.add("p" + getPaper2().getId()); + } + return ctx; + } + public List<String> getHDPaper3Context() { + List<String> ctx = new Vector<String>(); + if (getPaper3() != null) { + ctx.add("p" + getPaper3().getId()); + } + return ctx; + } public List<String> getSpiresContext() { List<String> ctx = new Vector<String>(); if (getPaper() != null) { @@ -322,11 +343,78 @@ /////////////////////////////////////////////// + public boolean getHaveMultiple(){ + Long ins = getPaper().getInspireId(); + if(ins != null) { + Query q = getSession().createQuery("select distinct p from Paper p where p._inspireId="+ins); + return (q.list().size() > 1); + } + else { + return ( constructQuery().list().size() > 1); + } + } + public boolean getHaveMultiple2(){ + Long ins = getPaper().getInspireId(); + if(ins != null) { + Query q = getSession().createQuery("select distinct p from Paper p where p._inspireId="+ins); + return (q.list().size() == 2); + } + else { + return ( constructQuery().list().size() == 2); + } + } + public boolean getHaveMultiple3(){ + Long ins = getPaper().getInspireId(); + if(ins != null) { + Query q = getSession().createQuery("select distinct p from Paper p where p._inspireId="+ins); + return (q.list().size() == 3); + } + else { + return ( constructQuery().list().size() == 3); + } + } public Paper getPaper() { - Paper p = (Paper) constructQuery().uniqueResult(); + Paper p = (Paper) constructQuery().setMaxResults(1).uniqueResult(); return p; } + public Paper getPaper1() { + Long ins = getPaper().getInspireId(); + Paper p = null; + if(ins != null) { + Query q = getSession().createQuery("select distinct p from Paper p where p._inspireId="+ins); + p = (Paper) q.list().get(0); + } + else { + p = (Paper) constructQuery().list().get(0); + } + return p; + } + public Paper getPaper2() { + Long ins = getPaper().getInspireId(); + Paper p = null; + if(ins != null) { + Query q = getSession().createQuery("select distinct p from Paper p where p._inspireId="+ins); + p = (Paper) q.list().get(1); + } + else { + p = (Paper) constructQuery().list().get(1); + } + return p; + } + public Paper getPaper3() { + Long ins = getPaper().getInspireId(); + Paper p = null; + if(ins != null) { + Query q = getSession().createQuery("select distinct p from Paper p where p._inspireId="+ins); + p = (Paper) q.list().get(2); + } + else { + p = (Paper) constructQuery().list().get(2); + } + return p; + } + private Query constructQuery() { Query q = null; StringBuffer qs = new StringBuffer("select distinct p from Paper p where ");
More information about the HepData-svn mailing list |