Skip to content

Commit

Permalink
fix: modification count in person and account settings (#19)
Browse files Browse the repository at this point in the history
Co-authored-by: milan.horvath <[email protected]>
  • Loading branch information
milanhorvath and milan.horvath authored Mar 12, 2024
1 parent 03c0eaa commit 83a28ee
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.tkit.onecx.user.profile.rs.external.v1.controllers;

import java.io.*;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.transaction.Transactional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public Response createUserProfileData(CreateUserProfileRequestDTO createUserProf

return Response
.created(uriInfo.getAbsolutePathBuilder().path(userProfile.getId()).build())
.entity(userProfileMapper.map(userProfile))
.entity(userProfileMapper.mapProfile(userProfile))
.build();
}

Expand All @@ -77,7 +77,7 @@ public Response getUserProfileData(String id) {
return Response.status(Response.Status.NOT_FOUND).build();
}

return Response.ok(userProfileMapper.map(userProfile)).build();
return Response.ok(userProfileMapper.mapProfile(userProfile)).build();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public Response getMyUserProfile() {
userProfile = userProfileDAO.create(createUserProfile);
}

return Response.ok(userProfileMapper.map(userProfile)).build();
return Response.ok(userProfileMapper.mapProfile(userProfile)).build();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import java.util.List;
import java.util.stream.Stream;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.Named;
import org.mapstruct.*;
import org.tkit.onecx.user.profile.domain.criteria.UserPersonCriteria;
import org.tkit.onecx.user.profile.domain.models.*;
import org.tkit.quarkus.jpa.daos.PageResult;
Expand Down Expand Up @@ -36,6 +33,15 @@ default UserProfile create(CreateUserProfileRequestDTO dto) {
@Mapping(target = "address", ignore = true)
UserPerson create(CreateUserPersonDTO dto);

@Named("mapProfile")
default UserProfileDTO mapProfile(UserProfile entity) {
UserProfileDTO dto = map(entity);
dto.getPerson().setModificationCount(entity.getModificationCount());
dto.getAccountSettings().setModificationCount(entity.getModificationCount());

return dto;
}

UserProfileDTO map(UserProfile entity);

default UserPersonDTO mapUserPerson(UserProfile entity) {
Expand Down Expand Up @@ -75,6 +81,7 @@ default void updateUserPerson(UserProfile model, UpdateUserPersonRequestDTO dto)
UserProfilePageResultDTO mapPageResult(PageResult<UserProfile> page);

@Named("mapStream")
@IterableMapping(qualifiedByName = "mapProfile")
List<UserProfileDTO> mapStream(Stream<UserProfile> stream);

default void updateUserSettings(UserProfile model, UpdateUserSettingsDTO dto) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ void getUserProfileTest() {
assertThat(userPofile).isNotNull();
assertThat(userPofile.getUserId()).isEqualTo("user3");
assertThat(userPofile.getPerson().getDisplayName()).isEqualTo("User Three");
assertThat(userPofile.getPerson().getModificationCount()).isNotNull();
assertThat(userPofile.getAccountSettings().getModificationCount()).isNotNull();
}

@Test
Expand Down

0 comments on commit 83a28ee

Please sign in to comment.