use of com.bedatadriven.rebar.sql.client.SqlResultSetRowList 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);
}
});
}
Aggregations