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 AssessmentGradingData getLastSavedAssessmentGradingByAgentId(final Long publishedAssessmentId, final String agentIdString) { AssessmentGradingData ag = null;//from w w w .j a va2 s . c om // don't pick the assessmentGradingData that is created by instructor entering comments/scores 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, publishedAssessmentId.longValue()); q.setString(1, agentIdString); q.setBoolean(2, false); q.setInteger(3, AssessmentGradingData.NO_SUBMISSION.intValue()); return q.list(); }; }; List assessmentGradings = getHibernateTemplate().executeFind(hcb); // List assessmentGradings = getHibernateTemplate().find( // "from AssessmentGradingData a where a.publishedAssessmentId=? and a.agentId=? and a.forGrade=? order by a.submittedDate desc", // new Object[] { publishedAssessmentId, agentIdString, Boolean.FALSE }, // new org.hibernate.type.Type[] { Hibernate.LONG, Hibernate.STRING, Hibernate.BOOLEAN }); if (assessmentGradings.size() != 0) { ag = (AssessmentGradingData) assessmentGradings.get(0); ag.setItemGradingSet(getItemGradingSet(ag.getAssessmentGradingId())); } return ag; }
From source file:org.sakaiproject.tool.assessment.facade.AssessmentGradingFacadeQueries.java
License:Educational Community License
public AssessmentGradingData getLastSubmittedAssessmentGradingByAgentId(final Long publishedAssessmentId, final String agentIdString, Long assessmentGradingId) { AssessmentGradingData ag = null;//from w w w . java 2s . c o m 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.submittedDate desc"); q.setLong(0, publishedAssessmentId.longValue()); q.setString(1, agentIdString); q.setBoolean(2, true); return q.list(); }; }; List assessmentGradings = getHibernateTemplate().executeFind(hcb); if (assessmentGradingId == null) { if (assessmentGradings.size() > 0) { ag = (AssessmentGradingData) assessmentGradings.get(0); } } else { for (int i = 0; i < assessmentGradings.size(); i++) { AssessmentGradingData agd = (AssessmentGradingData) assessmentGradings.get(i); if (agd.getAssessmentGradingId().compareTo(assessmentGradingId) == 0) { ag = agd; ag.setItemGradingSet(getItemGradingSet(agd.getAssessmentGradingId())); break; } } } return ag; }
From source file:org.sakaiproject.tool.assessment.facade.AssessmentGradingFacadeQueries.java
License:Educational Community License
public AssessmentGradingData getHighestSubmittedAssessmentGrading(final Long publishedAssessmentId, final String agentId, Long assessmentGradingId) { AssessmentGradingData ag = null;//from www. j a v a 2 s . co m final String query = "from AssessmentGradingData a " + " where a.publishedAssessmentId=? and a.agentId=? and " + " a.forGrade=? order by a.finalScore desc, 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 (assessmentGradingId == null) { if (assessmentGradings.size() > 0) { ag = (AssessmentGradingData) assessmentGradings.get(0); } } else { for (int i = 0; i < assessmentGradings.size(); i++) { AssessmentGradingData agd = (AssessmentGradingData) assessmentGradings.get(i); if (agd.getAssessmentGradingId().compareTo(assessmentGradingId) == 0) { ag = agd; ag.setItemGradingSet(getItemGradingSet(agd.getAssessmentGradingId())); break; } } } return ag; }
From source file:org.sakaiproject.tool.assessment.facade.AssessmentGradingFacadeQueries.java
License:Educational Community License
public List getLastSubmittedAssessmentGradingList(final Long publishedAssessmentId) { final String query = "from AssessmentGradingData a where a.publishedAssessmentId=? and a.forGrade=? order by a.agentId asc, 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.setBoolean(1, true); return q.list(); };/*from w ww .ja va 2s . 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 getLastSubmittedOrGradedAssessmentGradingList(final Long publishedAssessmentId) { final String query = "from AssessmentGradingData a where a.publishedAssessmentId=? and (a.forGrade=? or (a.forGrade=? and a.status=?)) order by a.agentId asc, 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.setBoolean(1, true); q.setBoolean(2, false);// w w w.j av a 2s . com q.setInteger(3, AssessmentGradingData.NO_SUBMISSION.intValue()); return q.list(); }; }; 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 getHighestSubmittedOrGradedAssessmentGradingList(final Long publishedAssessmentId) { final String query = "from AssessmentGradingData a where a.publishedAssessmentId=? and (a.forGrade=? or (a.forGrade=? and a.status=?)) 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); q.setBoolean(2, false);/* www. j a v a 2 s . c o m*/ q.setInteger(3, AssessmentGradingData.NO_SUBMISSION.intValue()); return q.list(); }; }; 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 HashSet getItemSet(final Long publishedAssessmentId, final Long sectionId) { HashSet itemSet = new HashSet(); final HibernateCallback hcb = new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query q = session.createQuery("select distinct p.itemId " + "from PublishedItemData p, AssessmentGradingData a, ItemGradingData i " + "where a.publishedAssessmentId=? and a.forGrade=? and p.section.id=? " + "and i.assessmentGradingId = a.assessmentGradingId " + "and p.itemId = i.publishedItemId "); q.setLong(0, publishedAssessmentId.longValue()); q.setBoolean(1, true); q.setLong(2, sectionId.longValue()); return q.list(); };/*from w w w. java2 s. c o m*/ }; List assessmentGradings = getHibernateTemplate().executeFind(hcb); final Collection<Long> itemIds = new ArrayList<Long>(); Iterator iter = assessmentGradings.iterator(); while (iter.hasNext()) { itemIds.add((Long) iter.next()); } if (itemIds.isEmpty()) return itemSet; final HibernateCallback hcb2 = new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { final Criteria criteria = session.createCriteria(PublishedItemData.class); if (itemIds.size() > 1000) { final Set<Long> ids = new HashSet<Long>(); Disjunction disjunction = Restrictions.disjunction(); for (Long id : itemIds) { if (ids.size() < 1000) { ids.add(id); } else { criteria.add(disjunction.add(Restrictions.in("itemId", ids))); ids.clear(); } } } else { criteria.add(Restrictions.in("itemId", itemIds)); } return criteria.list(); }; }; List publishedItems = getHibernateTemplate().executeFind(hcb2); Iterator pubIter = publishedItems.iterator(); PublishedItemData publishedItemData2; while (pubIter.hasNext()) { publishedItemData2 = (PublishedItemData) pubIter.next(); log.debug("itemId = " + publishedItemData2.getItemId()); itemSet.add(publishedItemData2); } return itemSet; }
From source file:org.sakaiproject.tool.assessment.facade.AssessmentGradingFacadeQueries.java
License:Educational Community License
public List getAllAssessmentGradingByAgentId(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.submittedDate desc"); q.setLong(0, publishedAssessmentId.longValue()); q.setString(1, agentIdString); q.setBoolean(2, true); return q.list(); };/*w ww . j a v a2 s . c o m*/ }; List assessmentGradings = getHibernateTemplate().executeFind(hcb); return assessmentGradings; }
From source file:org.sakaiproject.tool.assessment.facade.AssessmentGradingFacadeQueries.java
License:Educational Community License
public HashMap getSiteSubmissionCountHash(final String siteId) { HashMap siteSubmissionCountHash = 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, AuthorizationData au " + "where a.forGrade=? and au.functionId = ? and au.agentIdString = ? and a.publishedAssessmentId = au.qualifierId " + "group by a.publishedAssessmentId, a.agentId " + "order by a.publishedAssessmentId, a.agentId "); q.setBoolean(0, true); q.setString(1, "OWN_PUBLISHED_ASSESSMENT"); q.setString(2, siteId);//from www . j av a 2 s. c o m return q.list(); }; }; List countList = getHibernateTemplate().executeFind(hcb); Iterator iter = countList.iterator(); Long lastPublishedAssessmentId = Long.valueOf(-1l); HashMap numberSubmissionPerStudentHash = new HashMap(); while (iter.hasNext()) { Object o[] = (Object[]) iter.next(); Long publishedAssessmentid = (Long) o[0]; if (lastPublishedAssessmentId.equals(publishedAssessmentid)) { numberSubmissionPerStudentHash.put(o[1], o[2]); } else { numberSubmissionPerStudentHash = new HashMap(); numberSubmissionPerStudentHash.put(o[1], o[2]); siteSubmissionCountHash.put(publishedAssessmentid, numberSubmissionPerStudentHash); lastPublishedAssessmentId = publishedAssessmentid; } } return siteSubmissionCountHash; }
From source file:org.sakaiproject.tool.assessment.facade.AssessmentGradingFacadeQueries.java
License:Educational Community License
public HashMap getSiteInProgressCountHash(final String siteId) { HashMap siteInProgressCountHash = 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, AuthorizationData au " + "where a.forGrade=? and au.functionId = ? and au.agentIdString = ? " + "and a.publishedAssessmentId = au.qualifierId and (a.status=? or a.status=?) " + "group by a.publishedAssessmentId, a.agentId " + "order by a.publishedAssessmentId, a.agentId "); q.setBoolean(0, false); q.setString(1, "OWN_PUBLISHED_ASSESSMENT"); q.setString(2, siteId);/* w ww. jav a 2s .com*/ q.setInteger(3, 0); q.setInteger(4, 6); return q.list(); }; }; List countList = getHibernateTemplate().executeFind(hcb); Iterator iter = countList.iterator(); Long lastPublishedAssessmentId = Long.valueOf(-1l); HashMap numberInProgressPerStudentHash = new HashMap(); while (iter.hasNext()) { Object o[] = (Object[]) iter.next(); Long publishedAssessmentid = (Long) o[0]; if (lastPublishedAssessmentId.equals(publishedAssessmentid)) { numberInProgressPerStudentHash.put(o[1], o[2]); } else { numberInProgressPerStudentHash = new HashMap(); numberInProgressPerStudentHash.put(o[1], o[2]); siteInProgressCountHash.put(publishedAssessmentid, numberInProgressPerStudentHash); lastPublishedAssessmentId = publishedAssessmentid; } } return siteInProgressCountHash; }