Package nz.co.transparent.client.db

Examples of nz.co.transparent.client.db.FinderException


        sql += " WHERE " + whereClause;
      }

      Map map = (Map) queryRunner.query(sql, rsh);
      if (map == null) {
        throw new FinderException();
      }

      return map;
    } catch (SQLException se) {
      log.warning("GenericController SQLException: " + se.getMessage());
View Full Code Here


        sql += " WHERE " + whereClause;
      }
     
      List mapList = (List) queryRunner.query(conn, sql, rsh);
      if (mapList.size() == 0l) {
        throw new FinderException();
      }
     
      Iterator iterator = mapList.iterator();
      if (iterator.hasNext()) {
        return (Map) iterator.next();
View Full Code Here

        //params[1] = PasswordService.encrypt(passWordInPlainText);
        personMap = (Map) queryRunner.query(sql, rshMap);
       
        // Person could not be found, but there are already persons present
        if (personMap != null) {
          throw new FinderException();
        }
       
        // Add admin user
        personMap = new HashMap();
        int uniqueKey = nz.co.transparent.client.db.SQL.getUniqueKey("person", "person_id");
        personMap.put("person_id", new Integer(uniqueKey));
        personMap.put("user_name" , userName);
        personMap.put("comment" , "Added by system on " + new java.util.Date());
        personMap.put("updater_person_id" , new Integer(uniqueKey));
        GenericController genericController = GenericController.getInstance();
        genericController.insertRecord("person", "person_id", personMap);
       
        Map personRoleMap = new HashMap();
        // Add admin
        personRoleMap.put("person_role_id", null);
        personRoleMap.put("person_id", personMap.get("person_id"));
        personRoleMap.put("role_id",new Integer(1));
        personRoleMap.put("updater_person_id",new Integer(0));
        genericController.insertRecord("person_role", "person_role_id", personRoleMap);

        // Add operator
        personRoleMap.put("person_role_id", null);
        personRoleMap.put("role_id",new Integer(2));
        genericController.insertRecord("person_role", "person_role_id", personRoleMap);
       
        // Grant all premission to person table
        sql = "grant ALL on APP.person to " + userName + " with grant option";
        int result = queryRunner.update(sql);
      }

      sql =
        "select role_id from person_role where person_id = "
          + personMap.get("person_id");
      List personRoleList =
        (List) queryRunner.query(sql, rshList);
      Iterator iterator = personRoleList.iterator();
      Map personRoleMap = null;
      Map roleMap = null;
      Integer roleID = null;
      ArrayList roleList = new ArrayList(personRoleList.size());
      while (iterator.hasNext()) {
        personRoleMap = (Map) iterator.next();
        roleID = (Integer) personRoleMap.get("role_id");
        sql =
          "select role_code from role where role_id = "
            + roleID.intValue();
        roleMap = (Map) queryRunner.query(sql, rshMap);
        roleList.add(roleMap.get("role_code"));
      }

      personMap.put("role_list", roleList);

      // Update login
      sql =
        "update login"
          + " set login_date=CURRENT_TIMESTAMP"
          + " where ("
          + " (person_id=?)"
          + " )";

      Integer personID = (Integer) personMap.get("person_id");
      int result = queryRunner.update(sql, personID);

      if (result == 0) {
        sql =
          "insert into login"
            + " set user_name="
            + SQL.getUniqueKey("login", "user_name")
            + " ,person_id=?";
        result = queryRunner.update(sql, personID);
      }

      return;
    } catch (SQLException se) {
      String message =
        "LoginController: SQL Exception: " + se.getMessage();
      log.warning(message);

      if (message.indexOf("Cannot create PoolableConnectionFactory") > -1) {
        throw new FinderException(se);
      } else {
        throw new ControllerException(message);
      }
    }
  }
View Full Code Here

TOP

Related Classes of nz.co.transparent.client.db.FinderException

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.