use of com.palantir.example.profile.schema.generated.UserProfileTable in project atlasdb by palantir.
the class ProfileStore method deleteImage.
public void deleteImage(UUID userId) {
Long streamId = getPhotoStreamId(userId);
if (streamId == null) {
return;
}
UserProfileTable table = tables.getUserProfileTable(tx);
table.deletePhotoStreamId(UserProfileRow.of(userId));
UserPhotosStreamStore streamStore = UserPhotosStreamStore.of(txnMgr, tables);
streamStore.unmarkStreamAsUsed(tx, streamId, EncodingUtils.encodeUUID(userId));
}
use of com.palantir.example.profile.schema.generated.UserProfileTable in project atlasdb by palantir.
the class ProfileStore method getPhotoStreamId.
private Long getPhotoStreamId(UUID userId) {
UserProfileTable table = tables.getUserProfileTable(tx);
Map<UserProfileRow, Long> result = table.getPhotoStreamIds(ImmutableSet.of(UserProfileRow.of(userId)));
if (result.isEmpty()) {
return null;
} else {
return Iterables.getOnlyElement(result.values());
}
}
use of com.palantir.example.profile.schema.generated.UserProfileTable in project atlasdb by palantir.
the class ProfileStore method storeNewUser.
public UUID storeNewUser(UserProfile data) {
UUID userId = getNewId();
UserProfileTable table = tables.getUserProfileTable(tx);
table.putMetadata(UserProfileRow.of(userId), data);
return userId;
}
use of com.palantir.example.profile.schema.generated.UserProfileTable in project atlasdb by palantir.
the class ProfileStore method updateImage.
public void updateImage(UUID userId, Sha256Hash hash, InputStream imageData) {
UserProfile userData = getUserData(userId);
Preconditions.checkNotNull(userData, "userData cannot be null");
UserPhotosStreamStore streamStore = UserPhotosStreamStore.of(txnMgr, tables);
Long oldStreamId = getPhotoStreamId(userId);
if (oldStreamId != null) {
// Unmark old stream before we overwrite it.
streamStore.unmarkStreamAsUsed(tx, oldStreamId, EncodingUtils.encodeUUID(userId));
}
// This will either store a new stream and mark it as used
// or return an old stream that matches the hash and mark it as used.
long streamId = streamStore.getByHashOrStoreStreamAndMarkAsUsed(tx, hash, imageData, EncodingUtils.encodeUUID(userId));
UserProfileTable table = tables.getUserProfileTable(tx);
table.putPhotoStreamId(UserProfileRow.of(userId), streamId);
}
use of com.palantir.example.profile.schema.generated.UserProfileTable in project atlasdb by palantir.
the class ProfileStore method getUsersWithBirthday.
public Set<UUID> getUsersWithBirthday(long birthEpochDays) {
UserProfileTable table = tables.getUserProfileTable(tx);
UserBirthdaysIdxTable idx = UserBirthdaysIdxTable.of(table);
List<UserBirthdaysIdxColumnValue> columns = idx.getRowColumns(UserBirthdaysIdxRow.of(birthEpochDays));
return IterableView.of(columns).transform(UserBirthdaysIdxColumnValue.getColumnNameFun()).transform(UserBirthdaysIdxColumn.getIdFun()).immutableSetCopy();
}
Aggregations