예제 #1
0
  public ResetPassword create(ResetPassword resetPassword) {
    return persistenceService.process(
        new ProcessFunc<ResetPassword, ResetPassword>(resetPassword) {
          @Override
          public ResetPassword process() {
            try {
              delete(input.getHandle(), conn);

              PreparedStatement insert =
                  conn.prepareStatement(
                      "INSERT INTO reset_password (handle, nonce, created) VALUES (?,?,?)");

              input.setCreated(new Date());
              insert.setString(1, input.getHandle());
              insert.setString(2, input.getNonce());
              insert.setTimestamp(3, new Timestamp(input.getCreated().getTime()));

              insert.execute();
            } catch (SQLException e) {
              throw new GeneralException(e);
            }

            return input;
          }
        });
  }
예제 #2
0
  public List<Integer> getProfileIdsForOrganization(int organizationId) {
    return persistenceService.process(
        new RetrieveFunc<List<Integer>>(organizationId) {
          @Override
          protected List<Integer> retrieveConcrete() throws SQLException {
            PreparedStatement select =
                conn.prepareStatement(
                    "SELECT id FROM profile WHERE organization=? ORDER BY id DESC");
            select.setInt(1, input);

            ResultSet result = select.executeQuery();

            List<Integer> ids = new ArrayList<Integer>();
            while (result.next()) {
              ids.add(result.getInt(1));
            }

            return ids;
          }
        });
  }
예제 #3
0
  public ResetPassword getByCode(String code) {
    return persistenceService.process(
        new ProcessFunc<String, ResetPassword>(code) {
          @Override
          public ResetPassword process() {
            try {
              String query = "SELECT handle, created FROM reset_password WHERE nonce=?";

              PreparedStatement statement = conn.prepareStatement(query);
              statement.setString(1, input);

              ResultSet rs = statement.executeQuery();

              if (rs.next()) {
                return new ResetPassword(rs.getString(1), input, rs.getTimestamp(2));
              } else {
                return null;
              }
            } catch (SQLException e) {
              throw new GeneralException(e);
            }
          }
        });
  }
예제 #4
0
 public void delete(int id) {
   persistenceService.process(new DeleteProfileByIdFunc(id));
 }
예제 #5
0
 public Profile createProfile(Profile profile) {
   return persistenceService.process(new CreateProfileFunc(profile, this));
 }
예제 #6
0
  public ProfileSummary create(Profile profile) {
    Profile savedProfile = persistenceService.process(new CreateProfileFunc(profile, this));

    return getProfileSummary(savedProfile.getId());
  }
예제 #7
0
 public ProfileSummary getProfileByOrganization(int organizationId, int userId) {
   return persistenceService.process(
       new RetrieveProfileForOrganizationFunc(organizationId, userId));
 }
예제 #8
0
 public ProfileSummary getProfileSummary(Integer profileId, Connection conn) {
   return persistenceService.process(conn, new RetrieveProfileSummaryFunc(profileId));
 }
예제 #9
0
 public ProfileSummary getProfileSummary(Integer profileId) {
   return persistenceService.process(new RetrieveProfileSummaryFunc(profileId));
 }
예제 #10
0
 @Override
 public Profile get(int id, Connection connection) {
   return persistenceService.process(connection, new RetrieveProfileFunc(id));
 }
예제 #11
0
 @Override
 public Profile get(int id) {
   return persistenceService.process(new RetrieveProfileFunc(id));
 }
예제 #12
0
 public Profile update(Profile profile) {
   return persistenceService.process(new UpdateProfileFunc(profile));
 }
예제 #13
0
 public void delete(String handle, Connection conn) {
   persistenceService.process(conn, deleteFunc(handle));
 }
예제 #14
0
 public void delete(String handle) {
   persistenceService.process(deleteFunc(handle));
 }