Skip to content

Commit

Permalink
[MODCON-78]-added barcode and externelSystemId createPrimaryAffiliati… (
Browse files Browse the repository at this point in the history
#97)

* [MODCON-78]-added barcode and externelSystemId createPrimaryAffiliationEvent

* [MODCON-78]-added barcode and externelSystemId createPrimaryAffiliationEvent

* [MODCON-78]-added barcode and externelSystemId createPrimaryAffiliationEvent
  • Loading branch information
SinghAdes authored Aug 29, 2023
1 parent 5d00d12 commit c1d62c0
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ private PrimaryAffiliationEvent createPrimaryAffiliationEvent(SyncUser user, Str
event.setEmail(user.getEmail());
event.setPhoneNumber(user.getPhoneNumber());
event.setMobilePhoneNumber(user.getMobilePhoneNumber());
event.setBarcode(user.getBarcode());
event.setExternalSystemId(user.getExternalSystemId());
event.setCentralTenantId(centralTenantId);
return event;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ public void updatePrimaryUserAffiliation(String eventPayload) {
log.info("Username in primary affiliation has been updated for the user: {}", userEvent.getUserDto().getId());
}

boolean isPersonalDataChanged = true;
if (isPersonalDataChanged) {
if (Boolean.TRUE.equals(userEvent.getIsPersonalDataChanged())) {
userTenantService.updateShadowUsersFirstAndLastNames(getUserId(userEvent));
}
PrimaryAffiliationEvent affiliationEvent = createPrimaryAffiliationEvent(userEvent, centralTenantId);
Expand Down Expand Up @@ -186,11 +185,16 @@ private PrimaryAffiliationEvent createPrimaryAffiliationEvent(UserEvent userEven
User userDto = userEvent.getUserDto();
if (StringUtils.isNotBlank(userDto.getUsername())) { // for delete event username will be empty
event.setUsername(userEvent.getUserDto().getUsername());
if (ObjectUtils.isNotEmpty(userDto.getPersonal())) {
event.setEmail(userDto.getPersonal().getEmail());
event.setPhoneNumber(userDto.getPersonal().getPhone());
event.setMobilePhoneNumber(userDto.getPersonal().getMobilePhone());

var personalInfo = userDto.getPersonal();
if (ObjectUtils.isNotEmpty(personalInfo)) {
event.setEmail(personalInfo.getEmail());
event.setPhoneNumber(personalInfo.getPhone());
event.setMobilePhoneNumber(personalInfo.getMobilePhone());
}
event.setBarcode(userDto.getBarcode());
event.setExternalSystemId(userDto.getExternalSystemId());

}
event.setTenantId(userEvent.getTenantId());
event.setCentralTenantId(centralTenantId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ SyncUser:
phoneNumber:
description: "The phone number of the user"
type: string
externalSystemId:
description: "External system id of user"
type: string
barcode:
description: "The user's barcode"
type: string
additionalProperties: false


Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ properties:
phoneNumber:
description: "The user's phone number"
type: string
externalSystemId:
description: "External system id of user"
type: string
barcode:
description: "The user's barcode"
type: string
additionalProperties: false
required:
- id
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/swagger.api/schemas/userEvent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ properties:
description: "Date time when user action occurred"
format: "date-time"
type: string
isPersonalDataChanged:
description: "A flag to determine if personal data of a user changed"
type: boolean
userDto:
description: "Full snapshot of the user"
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"active": true,
"departments": [],
"proxyFor": [],
"externalSystemId": "123",
"barcode": "abc123",
"createdDate": 1681984177336,
"updatedDate": 1681984177336
}
Expand Down
4 changes: 3 additions & 1 deletion src/test/resources/mockdata/user_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
"firstName": "Mockey",
"email": "mock@biglibrary.org",
"phone": "2125551212"
}
},
"externalSystemId": "123",
"barcode": "test123"
}
],
"totalRecords": 2
Expand Down

0 comments on commit c1d62c0

Please sign in to comment.