Ejemplo n.º 1
0
  public Profile getProfile(int profileID) {
    Profile profile = null;
    try { // creates a SQL Statement object in order to execute the SQL insert command
      stmt = conn.createStatement();
      ResultSet result =
          stmt.executeQuery("SELECT * FROM PROFILES WHERE ProfileID=" + profileID + "");
      if (result.next()) { // if result of the query is not empty
        profile =
            new Profile(
                result.getString(2),
                result.getString(3),
                result.getString(5),
                result.getBoolean(7));
        profile.setLogin(result.getString(4));
        profile.setStatus(Status.convertValue(result.getInt(8)));
        if (result.getString(6) != null) {
          profile.setEmail(result.getString(6));
        }
      }
      stmt.close();

    } catch (SQLException e) {
      System.err.println(e.toString());
    }
    return profile;
  }
  private Profile getActionAuditOwner(
      Map<String, Profile> actionOwnersCache, UGCAudit currentAudit) {
    Profile p = actionOwnersCache.get(currentAudit.getProfileId());
    if (p == null) {
      Profile currentProfile =
          this.profileRepository.findOne(new ObjectId(currentAudit.getProfileId()));
      p = new Profile();
      if (currentProfile != null) {
        p.setUserName(currentProfile.getUserName());
        p.setTenantName(currentProfile.getTenantName());
        p.setEmail(currentProfile.getEmail());
        p.setId(currentProfile.getId());
      }
      actionOwnersCache.put(currentAudit.getProfileId(), p);
    }

    return p;
  }