Search in sources :

Example 1 with UserProfileDTO

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);
        }
    });
}
Also used : SqlResultSet(com.bedatadriven.rebar.sql.client.SqlResultSet) UserProfileDTO(org.activityinfo.shared.dto.UserProfileDTO) SqlResultCallback(com.bedatadriven.rebar.sql.client.SqlResultCallback) SqlTransaction(com.bedatadriven.rebar.sql.client.SqlTransaction) SqlResultSetRow(com.bedatadriven.rebar.sql.client.SqlResultSetRow) SqlResultSetRowList(com.bedatadriven.rebar.sql.client.SqlResultSetRowList)

Example 2 with UserProfileDTO

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());
}
Also used : VoidResult(org.activityinfo.shared.command.result.VoidResult) UserProfileDTO(org.activityinfo.shared.dto.UserProfileDTO)

Example 3 with UserProfileDTO

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();
        }
    });
}
Also used : ClientSideAuthProvider(org.activityinfo.client.authentication.ClientSideAuthProvider) GetUserProfile(org.activityinfo.shared.command.GetUserProfile) UserProfileDTO(org.activityinfo.shared.dto.UserProfileDTO) AuthenticatedUser(org.activityinfo.shared.auth.AuthenticatedUser)

Aggregations

UserProfileDTO (org.activityinfo.shared.dto.UserProfileDTO)3 SqlResultCallback (com.bedatadriven.rebar.sql.client.SqlResultCallback)1 SqlResultSet (com.bedatadriven.rebar.sql.client.SqlResultSet)1 SqlResultSetRow (com.bedatadriven.rebar.sql.client.SqlResultSetRow)1 SqlResultSetRowList (com.bedatadriven.rebar.sql.client.SqlResultSetRowList)1 SqlTransaction (com.bedatadriven.rebar.sql.client.SqlTransaction)1 ClientSideAuthProvider (org.activityinfo.client.authentication.ClientSideAuthProvider)1 AuthenticatedUser (org.activityinfo.shared.auth.AuthenticatedUser)1 GetUserProfile (org.activityinfo.shared.command.GetUserProfile)1 VoidResult (org.activityinfo.shared.command.result.VoidResult)1