use of org.activityinfo.shared.dto.UserProfileDTO in project activityinfo by bedatadriven.
the class GetUserProfileHandler method execute.
@Override
public void execute(final GetUserProfile command, ExecutionContext context, final AsyncCallback<UserProfileDTO> callback) {
final int userId = command.getUserId();
SqlQuery.select().appendColumn("u.name", "name").appendColumn("u.email", "email").appendColumn("u.organization", "organization").appendColumn("u.jobtitle", "jobtitle").appendColumn("u.locale", "locale").appendColumn("u.emailNotification", "emailNotification").from("userlogin", "u").where("u.userid").equalTo(userId).execute(context.getTransaction(), new SqlResultCallback() {
@Override
public void onSuccess(SqlTransaction tx, SqlResultSet results) {
SqlResultSetRowList list = results.getRows();
if (list.isEmpty()) {
callback.onFailure(new IllegalArgumentException("user " + userId + " not found"));
}
SqlResultSetRow row = list.get(0);
UserProfileDTO dto = new UserProfileDTO(userId);
dto.setName(row.getString("name"));
dto.setEmail(row.getString("email"));
dto.setOrganization(row.getString("organization"));
dto.setJobtitle(row.getString("jobtitle"));
dto.setLocale(row.getString("locale"));
dto.setEmailNotification(row.getBoolean("emailNotification"));
callback.onSuccess(dto);
}
});
}
use of org.activityinfo.shared.dto.UserProfileDTO in project activityinfo by bedatadriven.
the class UpdateUserProfileHandler method execute.
@Override
public void execute(final UpdateUserProfile command, ExecutionContext context, final AsyncCallback<VoidResult> callback) {
UserProfileDTO model = command.getModel();
SqlUpdate.update("userlogin").where("userId", model.getUserId()).value("name", model.getName()).value("organization", model.getOrganization()).value("jobtitle", model.getJobtitle()).value("emailNotification", model.isEmailNotification()).execute(context.getTransaction());
callback.onSuccess(new VoidResult());
}
use of org.activityinfo.shared.dto.UserProfileDTO in project activityinfo by bedatadriven.
the class UserProfilePage method bindProfile.
private void bindProfile() {
userProfile = new UserProfileDTO();
AuthenticatedUser user = new ClientSideAuthProvider().get();
dispatcher.execute(new GetUserProfile(user.getUserId()), new AsyncCallback<UserProfileDTO>() {
@Override
public void onFailure(Throwable caught) {
Log.error("error binding profile", caught);
MessageBox.alert(I18N.CONSTANTS.serverError(), caught.getMessage(), null);
}
@Override
public void onSuccess(UserProfileDTO userProfileDTO) {
userProfile = userProfileDTO;
binding.bind(userProfile);
UserProfilePage.this.show();
}
});
}
Aggregations