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; } }); }
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; } }); }
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); } } }); }
public void delete(int id) { persistenceService.process(new DeleteProfileByIdFunc(id)); }
public Profile createProfile(Profile profile) { return persistenceService.process(new CreateProfileFunc(profile, this)); }
public ProfileSummary create(Profile profile) { Profile savedProfile = persistenceService.process(new CreateProfileFunc(profile, this)); return getProfileSummary(savedProfile.getId()); }
public ProfileSummary getProfileByOrganization(int organizationId, int userId) { return persistenceService.process( new RetrieveProfileForOrganizationFunc(organizationId, userId)); }
public ProfileSummary getProfileSummary(Integer profileId, Connection conn) { return persistenceService.process(conn, new RetrieveProfileSummaryFunc(profileId)); }
public ProfileSummary getProfileSummary(Integer profileId) { return persistenceService.process(new RetrieveProfileSummaryFunc(profileId)); }
@Override public Profile get(int id, Connection connection) { return persistenceService.process(connection, new RetrieveProfileFunc(id)); }
@Override public Profile get(int id) { return persistenceService.process(new RetrieveProfileFunc(id)); }
public Profile update(Profile profile) { return persistenceService.process(new UpdateProfileFunc(profile)); }
public void delete(String handle, Connection conn) { persistenceService.process(conn, deleteFunc(handle)); }
public void delete(String handle) { persistenceService.process(deleteFunc(handle)); }