Examples of DBQuery


Examples of org.olat.core.commons.persistence.DBQuery

  /** the logging object used in this class **/
  private static final OLog log_ = Tracing.createLoggerFor(HourOfDayStatisticManager.class);

  @Override
  public StatisticResult generateStatisticResult(UserRequest ureq, ICourse course, long courseRepositoryEntryKey) {
    DBQuery dbQuery = DBFactory.getInstance().createQuery("select businessPath,hour,value from org.olat.course.statistic.hourofday.HourOfDayStat sv "
        + "where sv.resId=:resId");
    dbQuery.setLong("resId", courseRepositoryEntryKey);

    StatisticResult statisticResult = new StatisticResult(course, dbQuery.list());
    List<String> columnHeaders = statisticResult.getColumnHeaders();
    if (columnHeaders!=null && columnHeaders.size()>1) {
      try{
        int start = Integer.parseInt(columnHeaders.get(0));
        int end = Integer.parseInt(columnHeaders.get(columnHeaders.size()-1));
View Full Code Here

Examples of org.olat.core.commons.persistence.DBQuery

  public List<Message> getNewMessageInfo(Long forumKey, Date latestRead) {
    // FIXME:fj: lastModified has no index -> test performance with forum with
    // 200 messages
    String query = "select msg from org.olat.modules.fo.MessageImpl as msg" +
      " where msg.forum.key = :forumKey and msg.lastModified > :latestRead order by msg.lastModified desc";
    DBQuery dbquery = DBFactory.getInstance().createQuery(query);
    dbquery.setLong("forumKey", forumKey.longValue());
    dbquery.setTimestamp("latestRead", latestRead);
    dbquery.setCacheable(true);
    return dbquery.list();
  }
View Full Code Here

Examples of org.olat.core.commons.persistence.DBQuery

    boolean children = false;
    DB db = DBFactory.getInstance();
    Long message_id = m.getKey();
    String q = " select count(msg) from org.olat.modules.fo.MessageImpl msg where msg.parent = :input ";

    DBQuery query = db.createQuery(q);
    query.setLong("input", message_id.longValue());
    List result = query.list();
    int count = ((Long) result.get(0)).intValue();

    if (count > 0) {
      children = true;
    }
View Full Code Here

Examples of org.olat.core.commons.persistence.DBQuery

*/
public class StudyLevelStatisticManager implements IStatisticManager {

  @Override
  public StatisticResult generateStatisticResult(UserRequest ureq, ICourse course, long courseRepositoryEntryKey) {
    DBQuery dbQuery = DBFactory.getInstance().createQuery("select businessPath,studyLevel,value from org.olat.course.statistic.studylevel.StudyLevelStat sv "
        + "where sv.resId=:resId");
    dbQuery.setLong("resId", courseRepositoryEntryKey);

    return new StatisticResult(course, dbQuery.list());
  }
View Full Code Here

Examples of org.olat.core.commons.persistence.DBQuery

        if (firstIteration) firstIteration = false;
      }
      query = query.concat(")");
    }

    DBQuery dbQuery = DBFactory.getInstance().createQuery(query);
    dbQuery.setBoolean("resAdminAction", false);
    dbQuery.setString("resId", Long.toString(resId));
    if (begin != null) {
      dbQuery.setDate("createdAfter", begin);
    }
    if (end != null) {
      Calendar cal = Calendar.getInstance();
      cal.setTime(end);
      cal.add(Calendar.DAY_OF_MONTH, 1);
      end = cal.getTime();
      dbQuery.setDate("createdBefore", end);
    }
   
    if(values.length > 0) {
      int i = 0;
      for (String value : values) {
        dbQuery.setString("value"+i, value);
        i++;
      }
    }

    return dbQuery.list();
  }
View Full Code Here

Examples of org.olat.core.commons.persistence.DBQuery

        if (firstIteration) firstIteration = false;
      }
      query = query.concat(")");
    }

    DBQuery dbQuery = DBFactory.getInstance().createQuery(query);
    dbQuery.setBoolean("resAdminAction", false);
    dbQuery.setString("resId", Long.toString(resId));
    if (begin != null) {
      dbQuery.setDate("createdAfter", begin);
    }
    if (end != null) {
      Calendar cal = Calendar.getInstance();
      cal.setTime(end);
      cal.add(Calendar.DAY_OF_MONTH, 1);
      end = cal.getTime();
      dbQuery.setDate("createdBefore", end);
    }
   
    if(values.length > 0) {
      int i = 0;
      for (String value : values) {
        dbQuery.setString("value"+i, value);
        i++;
      }
    }

    count = ((Long)dbQuery.list().get(0)).intValue();

    setAggregation(count);
  }
View Full Code Here

Examples of org.olat.core.commons.persistence.DBQuery

  private static final OLog log_ = Tracing.createLoggerFor(WeeklyStatisticManager.class);
  private SimpleDateFormat sdf_ = new SimpleDateFormat("yyyy-ww");
 
  @Override
  public StatisticResult generateStatisticResult(UserRequest ureq, ICourse course, long courseRepositoryEntryKey) {
    DBQuery dbQuery = DBFactory.getInstance().createQuery("select businessPath,week,value from org.olat.course.statistic.weekly.WeeklyStat sv "
        + "where sv.resId=:resId");
    dbQuery.setLong("resId", courseRepositoryEntryKey);

    return new StatisticResult(course, dbQuery.list());
  }
View Full Code Here

Examples of org.olat.core.commons.persistence.DBQuery

      dateClause.append(" and (week=:fromDate or week>=:fromDate) ");
    }
    if (toDate!=null) {
      dateClause.append(" and (week=:toDate or week<=:toDate) ");
    }
    DBQuery dbQuery = DBFactory.getInstance().createQuery("select businessPath,week,value from org.olat.course.statistic.weekly.WeeklyStat sv "
        + "where sv.resId=:resId "
        + dateClause);
    dbQuery.setLong("resId", courseRepositoryEntryKey);
    StringBuffer infoMsg = new StringBuffer();
    if (fromDate!=null) {
      String fromDateStr = getYear(fromDate)+"-"+getWeek(fromDate);
      infoMsg.append("from date: "+fromDateStr);
      dbQuery.setString("fromDate", fromDateStr);
    }
    if (toDate!=null) {
      String toDateStr = getYear(toDate)+"-"+getWeek(toDate);
      if (infoMsg!=null) {
        infoMsg.append(", ");
      }
      infoMsg.append("to date: "+toDateStr);
      dbQuery.setString("toDate", toDateStr);
    }
   
    log_.info("generateStatisticResult: Searching with params "+infoMsg.toString());
   
    StatisticResult statisticResult = new StatisticResult(course, dbQuery.list());
    fillGapsInColumnHeaders(statisticResult);
    return statisticResult;
  }
View Full Code Here

Examples of org.olat.core.commons.persistence.DBQuery

    DBFactory.getInstance().intermediateCommit();
    initDone = true;
  }
 
  private PLock findPLock(String asset) { 
    DBQuery q = DBFactory.getInstance().createQuery("select plock from org.olat.resource.lock.pessimistic.PLockImpl as plock where plock.asset = :asset");
    q.setParameter("asset", asset);
    q.setLockMode("plock", LockMode.UPGRADE);
    List res = q.list();
    if (res.size() == 0) {
      return null;
    } else {
      return (PLock) res.get(0);
    }
View Full Code Here

Examples of org.olat.core.commons.persistence.DBQuery

    sb.append("' or p.name = '").append(COACH_COMMENT);
    sb.append("' )");
    if (identity != null) {
      sb.append(" and p.identity = :id");
    }
    DBQuery query = DBFactory.getInstance().createQuery(sb.toString());
    query.setString("restypename", course.getResourceableTypeName());
    query.setLong("restypeid", course.getResourceableId().longValue());
    if (identity != null) {
      query.setEntity("id", identity);
    }
    List properties = query.list();
    return properties;   
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.