List of usage examples for org.hibernate Query setBoolean
@Deprecated @SuppressWarnings("unchecked") default Query<R> setBoolean(String name, boolean val)
From source file:org.sakaiproject.tool.assessment.facade.AssessmentGradingFacadeQueries.java
License:Educational Community License
public int getActualNumberRetake(final Long publishedAssessmentId, final String agentIdString) { final HibernateCallback hcb = new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query q = session .createQuery("select count(*) from AssessmentGradingData a, StudentGradingSummaryData s " + " where a.publishedAssessmentId=? and a.agentId=? and a.forGrade=? " + " and a.publishedAssessmentId = s.publishedAssessmentId and a.agentId = s.agentId " + " and a.submittedDate > s.createdDate"); q.setLong(0, publishedAssessmentId.longValue()); q.setString(1, agentIdString); q.setBoolean(2, true); return q.list(); };//from w w w.ja v a 2s .co m }; List countList = getHibernateTemplate().executeFind(hcb); Iterator iter = countList.iterator(); if (iter.hasNext()) { int i = ((Integer) iter.next()).intValue(); return i; } else { return 0; } }
From source file:org.sakaiproject.tool.assessment.facade.AssessmentGradingFacadeQueries.java
License:Educational Community License
public HashMap getSiteActualNumberRetakeHash(final String siteId) { HashMap actualNumberRetakeHash = new HashMap(); final HibernateCallback hcb = new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query q = session.createQuery("select a.publishedAssessmentId, a.agentId, count(*) " + " from AssessmentGradingData a, StudentGradingSummaryData s, AuthorizationData au " + " where a.forGrade=? and au.functionId = ? and au.agentIdString = ? and a.publishedAssessmentId = au.qualifierId" + " and a.publishedAssessmentId = s.publishedAssessmentId and a.agentId = s.agentId " + " and a.submittedDate > s.createdDate" + " group by a.publishedAssessmentId, a.agentId"); q.setBoolean(0, true); q.setString(1, "OWN_PUBLISHED_ASSESSMENT"); q.setString(2, siteId);/*from w w w .j a va2s. c o m*/ return q.list(); }; }; List countList = getHibernateTemplate().executeFind(hcb); Iterator iter = countList.iterator(); Long lastPublishedAssessmentId = Long.valueOf(-1l); HashMap actualNumberRetakePerStudentHash = new HashMap(); while (iter.hasNext()) { Object o[] = (Object[]) iter.next(); Long publishedAssessmentid = (Long) o[0]; if (lastPublishedAssessmentId.equals(publishedAssessmentid)) { actualNumberRetakePerStudentHash.put(o[1], o[2]); } else { actualNumberRetakePerStudentHash = new HashMap(); actualNumberRetakePerStudentHash.put(o[1], o[2]); actualNumberRetakeHash.put(publishedAssessmentid, actualNumberRetakePerStudentHash); lastPublishedAssessmentId = publishedAssessmentid; } } return actualNumberRetakeHash; }
From source file:org.sakaiproject.tool.assessment.facade.AssessmentGradingFacadeQueries.java
License:Educational Community License
public HashMap getActualNumberRetakeHash(final String agentIdString) { HashMap actualNumberRetakeHash = new HashMap(); final HibernateCallback hcb = new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query q = session.createQuery( "select a.publishedAssessmentId, count(*) from AssessmentGradingData a, StudentGradingSummaryData s " + " where a.agentId=? and a.forGrade=? " + " and a.publishedAssessmentId = s.publishedAssessmentId and a.agentId = s.agentId " + " and a.submittedDate > s.createdDate" + " group by a.publishedAssessmentId"); q.setString(0, agentIdString); q.setBoolean(1, true); return q.list(); };/*from w ww . j a v a2 s . c o m*/ }; List countList = getHibernateTemplate().executeFind(hcb); Iterator iter = countList.iterator(); while (iter.hasNext()) { Object o[] = (Object[]) iter.next(); actualNumberRetakeHash.put(o[0], o[1]); } return actualNumberRetakeHash; }
From source file:org.sakaiproject.tool.assessment.facade.AssessmentGradingFacadeQueries.java
License:Educational Community License
public int getLateSubmissionsNumberByAgentId(final Long publishedAssessmentId, final String agentIdString, final Date dueDate) { final HibernateCallback hcb = new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query q = session.createQuery( "from AssessmentGradingData a where a.publishedAssessmentId=? and a.agentId=? and a.forGrade=? and a.submittedDate>?"); q.setLong(0, publishedAssessmentId.longValue()); q.setString(1, agentIdString); q.setBoolean(2, true); q.setDate(3, dueDate);//from w w w. ja v a 2 s .co m return q.list(); }; }; List assessmentGradings = getHibernateTemplate().executeFind(hcb); return assessmentGradings.size(); }
From source file:org.sakaiproject.tool.assessment.facade.AssessmentGradingFacadeQueries.java
License:Educational Community License
public List getAllOrderedSubmissions(final String publishedId) { final HibernateCallback hcb = new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query q = session.createQuery("from AssessmentGradingData a " + "where a.publishedAssessmentId=? and (a.forGrade=? or (a.forGrade=? and a.status=? and a.finalScore <> 0)) " + "order by a.agentId ASC, a.submittedDate"); q.setLong(0, Long.parseLong(publishedId)); q.setBoolean(1, true); q.setBoolean(2, false);//w w w.j a v a 2 s . c o m q.setInteger(3, AssessmentGradingData.NO_SUBMISSION.intValue()); return q.list(); }; }; return getHibernateTemplate().executeFind(hcb); }
From source file:org.sakaiproject.tool.assessment.facade.AssessmentGradingFacadeQueries.java
License:Educational Community License
public void removeUnsubmittedAssessmentGradingData(final AssessmentGradingData data) { final HibernateCallback hcb = new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query q = session .createQuery("from AssessmentGradingData a where a.publishedAssessmentId=? and a.agentId=? " + "and a.forGrade=? and a.status=? " + "order by a.submittedDate desc"); q.setLong(0, data.getPublishedAssessmentId().longValue()); q.setString(1, data.getAgentId()); q.setBoolean(2, false); q.setInteger(3, AssessmentGradingData.NO_SUBMISSION.intValue()); return q.list(); };//w w w.j av a 2 s.c om }; List assessmentGradings = getHibernateTemplate().executeFind(hcb); if (assessmentGradings.size() != 0) { deleteAll(assessmentGradings); } }
From source file:org.sakaiproject.tool.assessment.facade.AssessmentGradingFacadeQueries.java
License:Educational Community License
/*** * // w ww . j ava 2 s . c om *@author Mustansar Mehmood */ public Double getAverageSubmittedAssessmentGrading(final Long publishedAssessmentId, final String agentId) { Double averageScore = new Double(0.0); AssessmentGradingData ag = null; final String query = "from AssessmentGradingData a " + " where a.publishedAssessmentId=? and a.agentId=? and " + " a.forGrade=? order by a.submittedDate desc"; final HibernateCallback hcb = new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query q = session.createQuery(query); q.setLong(0, publishedAssessmentId.longValue()); q.setString(1, agentId); q.setBoolean(2, true); return q.list(); }; }; List assessmentGradings = getHibernateTemplate().executeFind(hcb); if (assessmentGradings.size() != 0) { AssessmentGradingData agd = null; Double cumulativeScore = new Double(0); Iterator i = assessmentGradings.iterator(); while (i.hasNext()) { agd = (AssessmentGradingData) i.next(); cumulativeScore += agd.getFinalScore(); } averageScore = cumulativeScore / assessmentGradings.size(); DecimalFormat df = new DecimalFormat("0.##"); DecimalFormatSymbols dfs = new DecimalFormatSymbols(); dfs.setDecimalSeparator('.'); df.setDecimalFormatSymbols(dfs); averageScore = new Double(df.format((double) averageScore)); } return averageScore; }
From source file:org.sakaiproject.tool.assessment.facade.AssessmentGradingFacadeQueries.java
License:Educational Community License
public List getHighestSubmittedAssessmentGradingList(final Long publishedAssessmentId) { final String query = "from AssessmentGradingData a where a.publishedAssessmentId=? and a.forGrade=? order by a.agentId asc, a.finalScore desc"; final HibernateCallback hcb = new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query q = session.createQuery(query); q.setLong(0, publishedAssessmentId.longValue()); q.setBoolean(1, true); return q.list(); };/*w ww . j av a 2 s. c o m*/ }; List assessmentGradings = getHibernateTemplate().executeFind(hcb); ArrayList l = new ArrayList(); String currentAgent = ""; for (int i = 0; i < assessmentGradings.size(); i++) { AssessmentGradingData g = (AssessmentGradingData) assessmentGradings.get(i); if (!currentAgent.equals(g.getAgentId())) { l.add(g); currentAgent = g.getAgentId(); } } return l; }
From source file:org.sakaiproject.tool.assessment.facade.AssessmentGradingFacadeQueries.java
License:Educational Community License
public List getUnSubmittedAssessmentGradingDataList(final Long publishedAssessmentId, final String agentIdString) { final HibernateCallback hcb = new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query q = session.createQuery( "from AssessmentGradingData a where a.publishedAssessmentId=? and a.agentId=? and a.forGrade=? order by a.attemptDate desc"); q.setLong(0, publishedAssessmentId.longValue()); q.setString(1, agentIdString); q.setBoolean(2, false); return q.list(); };//from w w w.j a va 2 s . co m }; List assessmentGradings = getHibernateTemplate().executeFind(hcb); return assessmentGradings; }
From source file:org.sakaiproject.tool.assessment.facade.PublishedAssessmentFacadeQueries.java
License:Educational Community License
public Integer getNumberOfSubmissions(final String publishedAssessmentId, final String agentId) { final String query = "select count(a) from AssessmentGradingData a where a.publishedAssessmentId=? and a.agentId=? and a.forGrade=?"; // Object[] objects = new Object[3]; // objects[0] = new Long(publishedAssessmentId); // objects[1] = agentId; // objects[2] = new Boolean(true); // Type[] types = new Type[3]; // types[0] = Hibernate.LONG; // types[1] = Hibernate.STRING; // types[2] = Hibernate.BOOLEAN; final HibernateCallback hcb = new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query q = session.createQuery(query); q.setLong(0, Long.parseLong(publishedAssessmentId)); q.setString(1, agentId);/*from w w w . j a v a 2 s . com*/ q.setBoolean(2, true); return q.list(); }; }; List list = getHibernateTemplate().executeFind(hcb); // List list = getHibernateTemplate().find(query, objects, types); return (Integer) list.get(0); }