-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update user detail mapper and user service entry
Using MapperStruct to create a mapper for user detail to make it more generic Refactor user service entry Update a more complicated example for user service
- Loading branch information
1 parent
44bae4d
commit 97b9a41
Showing
6 changed files
with
64 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 6 additions & 51 deletions
57
symphony-bdk-core/src/main/java/com/symphony/bdk/core/service/user/UserDetailMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,15 @@ | ||
package com.symphony.bdk.core.service.user; | ||
|
||
import com.symphony.bdk.gen.api.model.UserAttributes; | ||
import com.symphony.bdk.gen.api.model.UserDetail; | ||
import com.symphony.bdk.gen.api.model.V2UserAttributes; | ||
import com.symphony.bdk.gen.api.model.V2UserDetail; | ||
|
||
class UserDetailMapper { | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.factory.Mappers; | ||
|
||
protected static V2UserAttributes.AccountTypeEnum toV2AccountType(UserAttributes.AccountTypeEnum accountTypeEnum) { | ||
if (accountTypeEnum != null) { | ||
switch (accountTypeEnum) { | ||
case SYSTEM: | ||
return V2UserAttributes.AccountTypeEnum.SYSTEM; | ||
case NORMAL: | ||
return V2UserAttributes.AccountTypeEnum.NORMAL; | ||
} | ||
} | ||
return null; | ||
} | ||
@Mapper | ||
public interface UserDetailMapper { | ||
|
||
protected static V2UserAttributes toV2UserAttribute(UserAttributes userAttributes) { | ||
if (userAttributes != null) { | ||
return new V2UserAttributes() | ||
.emailAddress(userAttributes.getEmailAddress()) | ||
.firstName(userAttributes.getFirstName()) | ||
.lastName(userAttributes.getLastName()) | ||
.userName(userAttributes.getUserName()) | ||
.displayName(userAttributes.getDisplayName()) | ||
.companyName(userAttributes.getCompanyName()) | ||
.department(userAttributes.getDepartment()) | ||
.division(userAttributes.getDivision()) | ||
.title(userAttributes.getTitle()) | ||
.workPhoneNumber(userAttributes.getWorkPhoneNumber()) | ||
.mobilePhoneNumber(userAttributes.getMobilePhoneNumber()) | ||
.smsNumber(userAttributes.getSmsNumber()) | ||
.accountType(toV2AccountType(userAttributes.getAccountType())) | ||
.location(userAttributes.getLocation()) | ||
.jobFunction(userAttributes.getJobFunction()) | ||
.assetClasses(userAttributes.getAssetClasses()) | ||
.industries(userAttributes.getIndustries()); | ||
} | ||
return null; | ||
} | ||
UserDetailMapper INSTANCE = Mappers.getMapper(UserDetailMapper.class); | ||
|
||
public static V2UserDetail toV2UserDetail(UserDetail userDetail) { | ||
if (userDetail != null) { | ||
return new V2UserDetail() | ||
.userAttributes(toV2UserAttribute(userDetail.getUserAttributes())) | ||
.userSystemInfo(userDetail.getUserSystemInfo()) | ||
.features(userDetail.getFeatures()) | ||
.apps(userDetail.getApps()) | ||
.groups(userDetail.getGroups()) | ||
.roles(userDetail.getRoles()) | ||
.disclaimers(userDetail.getDisclaimers()) | ||
.avatar(userDetail.getAvatar()); | ||
} | ||
return null; | ||
} | ||
V2UserDetail userDetailToV2UserDetail(UserDetail userDetail); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters