@SuppressWarnings("rawtypes") @Override public Object[] getStatsMarksBySession(Long sessionId) { Query query = getSession().createSQLQuery(FIND_MARK_STATS_FOR_SESSION) .addScalar("min_grade", FloatType.INSTANCE) .addScalar("avg_grade", FloatType.INSTANCE) .addScalar("max_grade", FloatType.INSTANCE); query.setLong("sessionId", sessionId); List list = query.list(); if ((list == null) || (list.size() == 0)) { return null; } else { return (Object[]) list.get(0); } }
@SuppressWarnings("rawtypes") @Override public Object[] getStatsMarksForLeaders(Long toolContentId) { Query query = getSession().createSQLQuery(FIND_MARK_STATS_FOR_LEADERS) .addScalar("min_grade", FloatType.INSTANCE) .addScalar("avg_grade", FloatType.INSTANCE) .addScalar("max_grade", FloatType.INSTANCE) .addScalar("num_complete", IntegerType.INSTANCE); query.setLong("toolContentId", toolContentId); List list = query.list(); if ((list == null) || (list.size() == 0)) { return null; } else { return (Object[]) list.get(0); } }
@Override public Object[] getStatsMarksForLeaders(Long toolContentId) { Query query = getSession().createSQLQuery(FIND_MARK_STATS) .addScalar("min_grade", FloatType.INSTANCE) .addScalar("avg_grade", FloatType.INSTANCE) .addScalar("max_grade", FloatType.INSTANCE) .addScalar("num_complete", IntegerType.INSTANCE); query.setLong("toolContentId", toolContentId); @SuppressWarnings("rawtypes") List list = query.list(); if ((list == null) || (list.size() == 0)) { return null; } else { return (Object[]) list.get(0); } }
protected Object get(Class clazz, String id) { if (clazz.equals(String.class) || clazz.equals(StringType.class)) return id; if (clazz.equals(Character.class) || clazz.equals(CharacterType.class)) return (id == null || id.isEmpty() ? null : id.charAt(0)); if (clazz.equals(Byte.class) || clazz.equals(ByteType.class)) return Byte.valueOf(id); if (clazz.equals(Short.class) || clazz.equals(ShortType.class)) return Short.valueOf(id); if (clazz.equals(Integer.class) || clazz.equals(IntegerType.class)) return Integer.valueOf(id); if (clazz.equals(Long.class) || clazz.equals(LongType.class)) return Long.valueOf(id); if (clazz.equals(Float.class) || clazz.equals(FloatType.class)) return Float.valueOf(id); if (clazz.equals(Double.class) || clazz.equals(DoubleType.class)) return Double.valueOf(id); if (clazz.equals(Boolean.class) || clazz.equals(BooleanType.class)) return Boolean.valueOf(id); Map<String, Entity> entities = iEntities.get(clazz.getName()); if (entities != null) { Entity entity = entities.get(id); if (entity != null) return entity.getObject(); } for (Map.Entry<String, Map<String, Entity>> entry: iEntities.entrySet()) { Entity o = entry.getValue().get(id); if (o != null && clazz.isInstance(o.getObject())) return o.getObject(); } if (clazz.equals(Session.class)) return ((Entity)iEntities.get(Session.class.getName()).values().iterator().next()).getObject(); if (clazz.equals(Student.class)) return checkUnknown(clazz, id, iStudents.get(id)); if (iIsClone) return checkUnknown(clazz, id, iHibSession.get(clazz, clazz.equals(ItypeDesc.class) ? (Serializable) Integer.valueOf(id) : (Serializable) Long.valueOf(id))); return checkUnknown(clazz, id, null); }