Package edu.uga.galileo.voci.db

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


    sql.append("and bundle_id in ");
    sql.append("   (select bundle_id ");
    sql.append("    from bundle2community ");
    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(Bundle.class, qp);
      }
    } catch (SQLException e) {
View Full Code Here


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

    sql.append("select * ");
    sql.append("from item_bundles ");
    sql.append("where bundle_id=? ");
    sql.append("and project_id=? ");

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

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

    if (qp.getResultCount() > 0) {
      return createObjectFromQueryParser(Bundle.class, qp);
    } else {
      throw new NoSuchBundleException("The requested bundle ID ("
          + bundleId + ") doesn't exist.");
    }
View Full Code Here

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

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

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

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

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

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

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

    try {
      if (!Configuration.getConnectionPool().executeInsertOrUpdate(qp)) {
        throw new NoSuchBundleException("Bundle "
            + bundle.getId() + " in project "
View Full Code Here

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

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

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

      sql.append("from bundle2collection ");
      sql.append("where bundle_id=? ");
      sql.append("and collection_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 bundle2community ");
        sql.append("(bundle_id, community_id) values (?, ?) ");
      } else if (parentType == ContentType.COLLECTION) {
        sql.append("insert into bundle2collection ");
        sql.append("(bundle_id, collection_id) values (?, ?) ");
      }

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

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

    sql.append("where ((c.expires is null) or (c.expires>now())) ");
    sql.append("and c.project_id=? ");
    sql.append("and c.community_id=c2c.child_id ");
    sql.append("and c2c.parent_id=? ");

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

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

    sql.append("and ((c.expires is null) or (c.expires>now())) ");
    sql.append("and c.community_id not in ");
    sql.append("   (select distinct(child_id) ");
    sql.append("    from community2community) ");

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

    try {
      Configuration.getConnectionPool().executeQuery(qp);
      if (qp.getResultCount() == 0) {
        return null;
      } else {
        return createObjectsFromQueryParser(Community.class, qp);
      }
    } catch (SQLException 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.