Package edu.uga.galileo.voci.db

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


    sql.append("    where handle=?) ");
    sql.append("and content_type=? ");
    sql.append("and include_in_blurb=true ");
    sql.append("order by display_order ");

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

    try {
      Configuration.getConnectionPool().executeQuery(qp);
      if (qp.getResultCount() > 0) {
        ArrayList<String> results = new ArrayList<String>();
        String result;
        ArrayList row;
        for (int m = 0; m < qp.getResultCount(); m++) {
          row = qp.getRowResults(m);
          result = (String) row.get(0);
          if ((row.get(1) != null)
              && (((String) row.get(1)).length() > 0)) {
            result += "." + (String) row.get(1);
          }
View Full Code Here


  public ArrayList<String> getProjectList() {
    StringBuffer sql = new StringBuffer();
    sql.append("select handle ");
    sql.append("from projects ");

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

    try {
      Configuration.getConnectionPool().executeQuery(qp);
    } catch (SQLException e1) {
      Logger.fatal("Couldn't execute query", e1);
    }

    try {
      return qp.getResults(String.class, "handle");
    } catch (DataTypeMismatchException e) {
      Logger.error("Couldn't get String datatype from query", e);
    }

    return null;
View Full Code Here

    sql.append("select project_id, name, description, handle, ");
    sql.append("parent_id, searchable ");
    sql.append("from projects ");
    sql.append("where handle=? ");

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

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

    if (qp.getResultCount() < 1) {
      throw new NoSuchProjectException("No such record exists.");
    }

    return createObjectFromQueryParser(Project.class, qp);
  }
View Full Code Here

    StringBuffer sql = new StringBuffer();
    sql.append("update projects ");
    sql.append("set name=?, description=? ");
    sql.append("where handle=? and project_id=? ");

    QueryParser qp = new QueryParser(sql.toString());
    qp.addPreparedStmtElementDefinition(project.getName());
    qp.addPreparedStmtElementDefinition(project.getDescription());
    qp.addPreparedStmtElementDefinition(project.getHandle());
    qp.addPreparedStmtElementDefinition(INT, project.getProjectId());

    try {
      Configuration.getConnectionPool().executeInsertOrUpdate(qp);
    } catch (SQLException e) {
      Logger.error("Couldn't execute SQL", e);
View Full Code Here

    StringBuffer sql = new StringBuffer();
    sql.append("select handle ");
    sql.append("from projects ");
    sql.append("where project_id=? ");

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

    try {
      Configuration.getConnectionPool().executeQuery(qp);
      try {
        return qp.getResult(String.class, "handle");
      } catch (DataTypeMismatchException e) {
        Logger.error("Data type mismatch", e);
      }
    } catch (SQLException e1) {
      Logger.fatal("Couldn't execute query", e1);
View Full Code Here

    StringBuffer sql = new StringBuffer();
    sql.append("select project_id ");
    sql.append("from projects ");
    sql.append("where handle=? ");

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

    try {
      Configuration.getConnectionPool().executeQuery(qp);
      try {
        return qp.getResult(Integer.class, "project_id");
      } catch (DataTypeMismatchException e) {
        Logger.error("Data type mismatch", e);
      }
    } catch (SQLException e1) {
      Logger.fatal("Couldn't execute query", e1);
View Full Code Here

  public ArrayList<String> getAllProjectHandles() {
    StringBuffer sql = new StringBuffer();
    sql.append("select handle ");
    sql.append("from projects ");

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

    try {
      Configuration.getConnectionPool().executeQuery(qp);
    } catch (SQLException e1) {
      Logger.fatal("Couldn't execute query", e1);
      return new ArrayList<String>();
    }

    ArrayList<String> results = null;
    try {
      results = qp.getResults(String.class, "handle");
    } catch (DataTypeMismatchException e) {
      Logger.error("Your code's not requesting the right datatype.", e);
    }

    if (results == null) {
View Full Code Here

    sql.append("   select parent_id ");
    sql.append("   from projects ");
    sql.append("   where handle=? ");
    sql.append(") ");

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

    try {
      Configuration.getConnectionPool().executeQuery(qp);
    } catch (SQLException e1) {
      Logger.error("Couldn't execute query", e1);
      return null;
    }

    String result = null;
    try {
      result = qp.getResult(String.class, "handle");
    } catch (DataTypeMismatchException e) {
      Logger.error("Your code's not requesting the right datatype.", e);
    }

    return result;
View Full Code Here

    StringBuffer sql = new StringBuffer();
    sql.append("select * ");
    sql.append("from projects ");
    sql.append("where parent_id=? ");

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

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

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

   * @see edu.uga.galileo.voci.db.dao.RoleDAO#updateRole2User(User)
   */
  public void updateRole2User( User user) throws RoleUpdateAddException
  {
    // delete current roles for this user
    QueryParser qpp = new QueryParser("delete from role2user where user_id=?");
    qpp.addPreparedStmtElementDefinition(user.getUserId());
   
    try
    {
      Configuration.getConnectionPool().executeInsertOrUpdate(qpp);
    }
    catch( SQLException e )
    {
      Logger.error("SQLException prevented role2user record deletion", e);
      throw new RoleUpdateAddException(
          "SQLException prevented role2user record deletion: "
              + e.getMessage());
    }
   
    // update user roles   
    //get roleId's
    int[] roleIds = getRoleIdsByNames(user.getRoles());
    StringBuffer sql = new StringBuffer();
   
    for( int i = 0; i < roleIds.length; i++ )
    {
      sql.append(" insert into role2user ");
      sql.append(" ( user_id, role_id ) ");
      sql.append(" values ");
      sql.append(" ( ?, ?) ");
   
      QueryParser qp = new QueryParser(sql.toString());
      qp.addPreparedStmtElementDefinition(user.getUserId());
      qp.addPreparedStmtElementDefinition( roleIds[i]);
 
      try
      {
        Configuration.getConnectionPool().executeInsertOrUpdate(qp);
      }
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.