Package edu.uga.galileo.voci.db

Examples of edu.uga.galileo.voci.db.QueryParser


    StringBuffer sql = new StringBuffer();
    sql.append("insert into user_preferences ");
    sql.append("(user_id, name, value) ");
    sql.append("values (?, ?, ?) ");

    QueryParser qp = new QueryParser(sql.toString());
    qp.addPreparedStmtElementDefinition(user.getUserId());
    qp.addPreparedStmtElementDefinition(name);
    qp.addPreparedStmtElementDefinition(value);

    try {
      Configuration.getConnectionPool().executeInsertOrUpdate(qp);
    } catch (SQLException e1) {
      Logger.error("Couldn't insert user preference (" + name + "/"
View Full Code Here


    sql.append("delete from user_preferences ");
    sql.append("where user_id=? ");
    sql.append("and name=? ");

    QueryParser qp = new QueryParser(sql.toString());
    qp.addPreparedStmtElementDefinition(user.getUserId());
    qp.addPreparedStmtElementDefinition(name);

    try {
      Configuration.getConnectionPool().executeInsertOrUpdate(qp);
    } catch (SQLException e1) {
      Logger.error("Couldn't delete user preference (" + name + ")", e1);
View Full Code Here

    sql.append("select name, value ");
    sql.append("from user_preferences ");
    sql.append("where user_id=? ");

    QueryParser qp = new QueryParser(sql.toString());
    qp.addPreparedStmtElementDefinition(user.getUserId());

    try {
      Configuration.getConnectionPool().executeQuery(qp);
      if (qp.getResultCount() == 0) {
        return null;
      }

      ArrayList row;
      for (int m = 0; m < qp.getResultCount(); m++) {
        row = qp.getRowResults(m);
        results.put((String) row.get(0), (String) row.get(1));
      }
    } catch (SQLException e1) {
      Logger.error("Couldn't get user preferences (" + user.getUserName()
          + ")", e1);
View Full Code Here

    sql.append("       from projects ");
    sql.append("       where handle=?) ");
    sql.append("   ) ");
    sql.append("order by user_name asc ");
 
    QueryParser qp = new QueryParser(sql.toString());
    qp.addPreparedStmtElementDefinition(projectHandle);

    try {
      Configuration.getConnectionPool().executeQuery(qp);
      if (qp.getResultCount() == 0) {
        return null;
      }

      return createObjectsFromQueryParser(User.class, qp);
    } catch (SQLException e1) {
View Full Code Here

    sql.append("and item_id in ");
    sql.append("   (select item_id ");
    sql.append("    from item2community ");
    sql.append("    where community_id=?) ");

    QueryParser qp = new QueryParser(sql.toString());
    qp.addPreparedStmtElementDefinition(projectId);
    qp.addPreparedStmtElementDefinition(community.getCommunityId());

    try {
      Configuration.getConnectionPool().executeQuery(qp);
      if (qp.getResultCount() == 0) {
        return null;
      } else {
        return createItemsFromQueryParser(qp);
      }
    } catch (SQLException e) {
View Full Code Here

    sql.append("and item_id in ");
    sql.append("   (select item_id ");
    sql.append("    from item2collection ");
    sql.append("    where collection_id=?) ");

    QueryParser qp = new QueryParser(sql.toString());
    qp.addPreparedStmtElementDefinition(projectId);
    qp.addPreparedStmtElementDefinition(collection.getCollectionId());

    try {
      Configuration.getConnectionPool().executeQuery(qp);
      if (qp.getResultCount() == 0) {
        return null;
      } else {
        return createItemsFromQueryParser(qp);
      }
    } catch (SQLException e) {
View Full Code Here

    sql.append("and item_id in ");
    sql.append("   (select item_id ");
    sql.append("    from item2bundle ");
    sql.append("    where bundle_id=?) ");

    QueryParser qp = new QueryParser(sql.toString());
    qp.addPreparedStmtElementDefinition(projectId);
    qp.addPreparedStmtElementDefinition(bundle.getBundleId());

    try {
      Configuration.getConnectionPool().executeQuery(qp);
      if (qp.getResultCount() == 0) {
        return null;
      } else {
        return createItemsFromQueryParser(qp);
      }
    } catch (SQLException e) {
View Full Code Here

    sql.append("   active, status ");
    sql.append("from items ");
    sql.append("where item_id=? ");
    sql.append("and project_id=? ");

    QueryParser qp = new QueryParser(sql.toString());
    qp.addPreparedStmtElementDefinition(itemId);
    qp.addPreparedStmtElementDefinition(projectId);

    try {
      Configuration.getConnectionPool().executeQuery(qp);
      if (qp.getResultCount() > 0) {
        return createItemsFromQueryParser(qp).get(0);
      }
    } catch (SQLException e) {
      Logger.fatal("Couldn't execute query", e);
      throw new NoSuchItemException("A SQLException was the cause: "
View Full Code Here

    sql.append("insert into items ");
    sql.append("(item_id, project_id, active, ");
    sql.append("status, created, expires) values ");
    sql.append("(?, ?, ?, ?, now(), ?) ");

    QueryParser qp = new QueryParser(sql.toString());
    qp.addPreparedStmtElementDefinition(item.getItemId());
    qp.addPreparedStmtElementDefinition(item.getProjectId());
    qp.addPreparedStmtElementDefinition(item.isActive());
    qp.addPreparedStmtElementDefinition(QueryParserElement.INT, item
        .getStatus() <= 0 ? null : item.getStatus());
    qp.addPreparedStmtElementDefinition(QueryParserElement.TIMESTAMP, item
        .getExpires());

    if (connection != null) {
      qp.setConnection(connection);
    }

    try {
      Configuration.getConnectionPool().executeInsertOrUpdate(qp);
    } catch (SQLException e) {
View Full Code Here

   */
  private int getNextItemId() throws NoSuchItemException {
    StringBuffer sql = new StringBuffer();
    sql.append("select nextval('handle_id_seq') as nextVal ");

    QueryParser qp = new QueryParser(sql.toString());

    try {
      Configuration.getConnectionPool().executeQuery(qp);
      return qp.getResult(Integer.class, "nextVal");
    } catch (SQLException e) {
      Logger
          .error("Item ID couldn't be retrieved b/c of SQLException",
              e);
      throw new NoSuchItemException(
View Full Code Here

TOP

Related Classes of edu.uga.galileo.voci.db.QueryParser

Copyright © 2018 www.massapicom. 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.