Package edu.uga.galileo.voci.db

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


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

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

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

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


    sql.append("update collections ");
    sql.append("set active=?, status=?, expires=? ");
    sql.append("where collection_id=? ");
    sql.append("and project_id=? ");

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

    try {
      if (!Configuration.getConnectionPool().executeInsertOrUpdate(qp)) {
        throw new NoSuchCollectionException("Collection "
            + collection.getId() + " in project "
View Full Code Here

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

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

    try {
      if (!Configuration.getConnectionPool().executeInsertOrUpdate(qp)) {
        throw new NoSuchCollectionException("Childless collection "
            + collection.getId() + " in project "
View Full Code Here

   */
  private int getNextCollectionId() throws NoSuchCollectionException {
    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(
          "Collection ID couldn't be retrieved b/c of SQLException",
          e);
      throw new NoSuchCollectionException(
View Full Code Here

      sql.append("from collection2collection ");
      sql.append("where child_id=? ");
      sql.append("and parent_id=? ");
    }

    QueryParser qp = new QueryParser(sql.toString());
    qp.addPreparedStmtElementDefinition(childId);
    qp.addPreparedStmtElementDefinition(parentId);
    if (connection != null) {
      qp.setConnection(connection);
    }

    int preInsertCheck = -1;
    try {
      Configuration.getConnectionPool().executeQuery(qp);
      preInsertCheck = qp.getResult(Integer.class, "theCount");
    } catch (DataTypeMismatchException e) {
      Logger.error("Couldn't create an int out of an integer "
          + "db result.  Shouldn't happen, but...", e);
    }

    if (preInsertCheck == 0) {
      sql = new StringBuffer();
      if (parentType == ContentType.COMMUNITY) {
        sql.append("insert into collection2community ");
        sql.append("(collection_id, community_id) values (?, ?) ");
      } else if (parentType == ContentType.COLLECTION) {
        sql.append("insert into collection2collection ");
        sql.append("(child_id, parent_id) values (?, ?) ");
      }

      qp.clearForNewSQL();
      qp.setSql(sql.toString());
      qp.addPreparedStmtElementDefinition(childId);
      qp.addPreparedStmtElementDefinition(parentId);

      Configuration.getConnectionPool().executeInsertOrUpdate(qp);
    }
  }
View Full Code Here

    StringBuffer sql = new StringBuffer();
    sql.append("select parent_id ");
    sql.append("from collection2collection ");
    sql.append("where child_id=? ");

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

    Configuration.getConnectionPool().executeQuery(qp);
    return qp.getResults(Integer.class, "parent_id");
  }
View Full Code Here

    sql.append("    from collection2collection) ");
    sql.append("and c.collection_id not in ");
    sql.append("   (select distinct(collection_id) ");
    sql.append("    from collection2community) ");

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

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

    sql.append("and a.content_id=? ");
    sql.append("and a.user_id=u.user_id ");
    sql.append("and data_export!='{created}' ");
    sql.append("order by update_date desc ");

    QueryParser qp = new QueryParser(sql.toString());
    if (contentType != ContentType.USER) {
      qp.addPreparedStmtElementDefinition(projectId);
    }
    qp.addPreparedStmtElementDefinition(contentType.getValue());
    qp.addPreparedStmtElementDefinition(contentId);

    try {
      Configuration.getConnectionPool().executeQuery(qp);
      return createObjectsFromQueryParser(AuditLog.class, qp);
    } catch (SQLException e) {
View Full Code Here

    }
    sql.append("and content_type=? ");
    sql.append("and content_id=? ");
    sql.append("and update_date=? ");

    QueryParser qp = new QueryParser(sql.toString());
    if (contentType != ContentType.USER) {
      qp.addPreparedStmtElementDefinition(projectId);
    }
    qp.addPreparedStmtElementDefinition(contentType.getValue());
    qp.addPreparedStmtElementDefinition(contentId);
    qp.addPreparedStmtElementDefinition(update);

    try {
      Configuration.getConnectionPool().executeQuery(qp);
      if (qp.getResultCount() < 1) {
        throw new NoSuchAuditLogRecordException(
            "No such record exists.");
      }
      AuditLog result = createObjectFromQueryParser(AuditLog.class, qp);
      // repopulate the next four bits from the method call
View Full Code Here

    sql.append(" user_id, update_date, data_export) ");
    sql.append("values (?, ?, ?, ");
    sql.append(" (select user_id from users where user_name=?), ");
    sql.append("?, ?) ");

    QueryParser qp = new QueryParser(sql.toString());
    qp.addPreparedStmtElementDefinition(record.getProjectId());
    qp.addPreparedStmtElementDefinition(record.getContentType().getValue());
    qp.addPreparedStmtElementDefinition(record.getContentId());
    qp.addPreparedStmtElementDefinition(record.getUserName());
    qp.addPreparedStmtElementDefinition(record.getUpdateDate());
    qp.addPreparedStmtElementDefinition(record.getDataExport());

    try {
      Configuration.getConnectionPool().executeInsertOrUpdate(qp);
    } catch (SQLException e) {
      Logger.fatal("Couldn't execute SQL", e);
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.