Package edu.uga.galileo.voci.db

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


    sql.append("   and content_type=? ");
    sql.append("   and content_id=?) ");
    sql.append("and a.content_id=? ");
    sql.append("and a.user_id=u.user_id ");

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

    try {
      Configuration.getConnectionPool().executeQuery(qp);
      if (qp.getResultCount() != 1) {
        return null;
      } else {
        try {
          return qp.getResult(Timestamp.class, "update_date")
              .toString()
              + "|" + qp.getResult(String.class, "user_name");
        } catch (DataTypeMismatchException e) {
          Logger.error("Code problem.", e);
        }
      }
    } catch (SQLException e) {
View Full Code Here


    StringBuffer sql = new StringBuffer();
    sql.append(" select * ");
    sql.append(" from users ");
    sql.append(" where upper(user_name)=upper(?) ");

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

    try {
      Configuration.getConnectionPool().executeQuery(qp);
      if (qp.getResultCount() > 0) {
        user = createObjectFromQueryParser(User.class, qp);
      } else {
        user = null;
        // throw new NoSuchUserException("The requested user name ("
        // + userName + ") doesn't exist.");
View Full Code Here

    StringBuffer sql = new StringBuffer();
    sql.append(" select * ");
    sql.append(" from users ");
    sql.append(" where user_id=? ");

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

    try {
      Configuration.getConnectionPool().executeQuery(qp);
      if (qp.getResultCount() > 0) {
        user = createObjectFromQueryParser(User.class, qp);
      } else {
        throw new NoSuchUserException("The requested userId (" + userId
            + ") doesn't exist.");
      }
View Full Code Here

  public ArrayList<User> getUserList() throws NoSuchUserException {
    StringBuffer sql = new StringBuffer();
    sql
        .append("select * from users order by last_name, first_name, user_name");

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

    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(" (user_name, pwd, email, first_name, last_name, ");
    sql.append(" phone, notes, active) ");
    sql.append(" values ");
    sql.append(" (?, ?, ?, ?, ?, ?, ?, ?) ");

    QueryParser qp = new QueryParser(sql.toString());
    qp.addPreparedStmtElementDefinition(user.getUserName());
    qp.addPreparedStmtElementDefinition(user.getPwd());
    qp.addPreparedStmtElementDefinition(user.getEmail());
    qp.addPreparedStmtElementDefinition(user.getFirstName());
    qp.addPreparedStmtElementDefinition(user.getLastName());
    qp.addPreparedStmtElementDefinition(user.getPhone());
    qp.addPreparedStmtElementDefinition(user.getNotes());
    qp.addPreparedStmtElementDefinition(QueryParserElement.BOOLEAN, user
        .isActive());

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

    sql.append(" update users ");
    sql
        .append(" set user_name=?, pwd=?, email=?, first_name=?, last_name=?, ");
    sql.append(" phone=?, notes=?, active=? where user_id=? ");

    QueryParser qp = new QueryParser(sql.toString());
    qp.addPreparedStmtElementDefinition(user.getUserName());
    qp.addPreparedStmtElementDefinition(user.getPwd());
    qp.addPreparedStmtElementDefinition(user.getEmail());
    qp.addPreparedStmtElementDefinition(user.getFirstName());
    qp.addPreparedStmtElementDefinition(user.getLastName());
    qp.addPreparedStmtElementDefinition(user.getPhone());
    qp.addPreparedStmtElementDefinition(user.getNotes());
    qp.addPreparedStmtElementDefinition(QueryParserElement.BOOLEAN, user
        .isActive());
    qp.addPreparedStmtElementDefinition(user.getUserId());

    try {
      Configuration.getConnectionPool().executeInsertOrUpdate(qp);
    } catch (SQLException e) {
      Logger.error("User record couldn't be updated", e);
View Full Code Here

    sql.append("and u.user_id=m.user_id ");
    sql.append("and r.role_id=m.role_id ");
    sql.append("and r.name='sysadmin' ");
    sql.append("and r.manager=true ");

    QueryParser qp = new QueryParser(sql.toString());
    qp.addPreparedStmtElementDefinition(INT, user.getUserId());
    try {
      Configuration.getConnectionPool().executeQuery(qp);
    } catch (SQLException e1) {
      Logger.fatal("Couldn't execute query", e1);
      return false;
    }

    int theCount = 0;
    try {
      theCount = qp.getResult(Integer.class, "theCount").intValue();
    } catch (DataTypeMismatchException e) {
      Logger.error("This shouldn't happen.", e);
    }

    Logger.debug(user.getUserName() + " is " + (theCount == 0 ? "NOT" : "")
View Full Code Here

    sql.append("and r.manager=true ");
    sql.append("and r.role_id=r2p.role_id ");
    sql.append("and r2p.project_id=p.project_id ");
    sql.append("and p.handle=? ");

    QueryParser qp = new QueryParser(sql.toString());
    qp.addPreparedStmtElementDefinition(INT, user.getUserId());
    qp.addPreparedStmtElementDefinition(project);
    try {
      Configuration.getConnectionPool().executeQuery(qp);
    } catch (SQLException e1) {
      Logger.fatal("Couldn't execute query", e1);
      return false;
    }

    int theCount = 0;
    try {
      theCount = qp.getResult(Integer.class, "theCount").intValue();
    } catch (DataTypeMismatchException e) {
      Logger.error("This shouldn't happen.", e);
    }

    Logger.debug(user.getUserName() + " belongs to " + theCount
View Full Code Here

    sql.append("and r.manager=true ");
    sql.append("and r.role_id=r2p.role_id ");
    sql.append("and r2p.project_id=p.project_id ");
    sql.append("and p.handle=? ");

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

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

    Logger.debug("getUserAdminRoles size: " + qp.getResultCount());

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

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

    sql.append("last_name, phone, notes, active ");
    sql.append("from users ");
    sql.append("where user_name=? ");
    sql.append("and pwd=? ");

    QueryParser qp = new QueryParser(sql.toString());
    qp.addPreparedStmtElementDefinition(STRING, username);
    try {
      qp.addPreparedStmtElementDefinition(Encrypt.encrypt(Configuration
          .getString("keyfile"), password));
    } catch (Exception e) {
      throw new PasswordFailureException(
          "Couldn't encrypt password (this could be a database problem): "
              + e.toString());
    }

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

    if (qp.getResultCount() == 0) {
      qp.clearForNewSQL();
      sql = null;
      sql = new StringBuffer();
      sql.append("select count(*) as theCount ");
      sql.append("from users ");
      sql.append("where user_name=? ");
      qp = new QueryParser(sql.toString());
      qp.addPreparedStmtElementDefinition(username);

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

      try {
        if (qp.getResult(Integer.class, "theCount").intValue() == 0) {
          throw new NoSuchUserException("User '" + username
              + "' doesn't exist");
        } else {
          throw new PasswordFailureException(
              "Password doesn't match database.");
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.