Package edu.uga.galileo.voci.db

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


    sql.append("select * ");
    sql.append("from communities ");
    sql.append("where community_id=? ");
    sql.append("and project_id=? ");

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

    try {
      Configuration.getConnectionPool().executeQuery(qp);
    } catch (SQLException e) {
      Logger.fatal("Couldn't execute query", e);
      throw new NoSuchCommunityException("A SQLException was the cause: "
          + e.getMessage());
    }

    if (qp.getResultCount() > 0) {
      return createObjectFromQueryParser(Community.class, qp);
    } else {
      throw new NoSuchCommunityException("The requested community ID ("
          + communityId + ") doesn't exist.");
    }
View Full Code Here


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

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

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

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

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

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

    try {
      if (!Configuration.getConnectionPool().executeInsertOrUpdate(qp)) {
        throw new NoSuchCommunityException("Community "
            + community.getId() + " in project "
View Full Code Here

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

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

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

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

    sql.append("select count(*) as theCount ");
    sql.append("from community2community ");
    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();
      sql.append("insert into community2community ");
      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 community2community ");
    sql.append("where child_id=? ");

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

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

    sql.append("from collections c, collection2collection c2c ");
    sql.append("where ((c.expires is null) or (c.expires>now())) ");
    sql.append("and c.collection_id=c2c.child_id ");
    sql.append("and c2c.parent_id=? ");

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

    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 collection_id in ");
    sql.append("   (select collection_id ");
    sql.append("    from collection2community ");
    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 createObjectsFromQueryParser(Collection.class, qp);
      }
    } catch (SQLException e) {
View Full Code Here

    sql.append("select * ");
    sql.append("from collections ");
    sql.append("where collection_id=? ");
    sql.append("and project_id=? ");

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

    try {
      Configuration.getConnectionPool().executeQuery(qp);
    } catch (SQLException e) {
      Logger.fatal("Couldn't execute query", e);
      throw new NoSuchCollectionException(
          "A SQLException was the cause: " + e.getMessage());
    }

    if (qp.getResultCount() > 0) {
      return createObjectFromQueryParser(Collection.class, qp);
    } else {
      throw new NoSuchCollectionException("The requested collection ID ("
          + collectionId + ") doesn't exist.");
    }
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.