Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added localityCode in individual while creation #1324

Merged
merged 2 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ public class EmployeeService {
@Autowired
private ObjectMapper objectMapper;

@Autowired
private IndividualService individualService;

/**
* Service method for create employee. Does following:
* 1. Sets ids to all the objects using idgen service.
Expand Down Expand Up @@ -264,7 +267,15 @@ private void createUser(Employee employee, RequestInfo requestInfo) {
enrichUser(employee);
UserRequest request = UserRequest.builder().requestInfo(requestInfo).user(employee.getUser()).build();
try {
UserResponse response = userService.createUser(request);
UserResponse response;
if(userService instanceof IndividualService) {
String localityCode = (employee.getJurisdictions()!=null && !employee.getJurisdictions().isEmpty())? employee.getJurisdictions().get(0).getBoundary() : null;
response = individualService.createUserByLocality(request, localityCode);
}
else{
response = userService.createUser(request);
}

User user = response.getUser().get(0);
employee.setId(UUID.fromString(user.getUuid()).getMostSignificantBits());
employee.setUuid(user.getUuid());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public IndividualService(PropertiesManager propertiesManager,

@Override
public UserResponse createUser(UserRequest userRequest) {
IndividualRequest request = mapToIndividualRequest(userRequest);
IndividualRequest request = mapToIndividualRequest(userRequest, null);
StringBuilder uri = new StringBuilder();
uri.append(propertiesManager.getIndividualHost());
uri.append(propertiesManager.getIndividualCreateEndpoint());
Expand All @@ -63,6 +63,21 @@ public UserResponse createUser(UserRequest userRequest) {
return userResponse;
}

public UserResponse createUserByLocality(UserRequest userRequest, String localityCode) {
IndividualRequest request = mapToIndividualRequest(userRequest,localityCode);
StringBuilder uri = new StringBuilder();
uri.append(propertiesManager.getIndividualHost());
uri.append(propertiesManager.getIndividualCreateEndpoint());
IndividualResponse response = restCallRepository
.fetchResult(uri, request, IndividualResponse.class);
UserResponse userResponse = null;
if (response != null && response.getIndividual() != null) {
log.info("response received from individual service");
userResponse = mapToUserResponse(response);
}
return userResponse;
}

/**
* Updates a user by searching for the corresponding individual and updating their details.
*
Expand Down Expand Up @@ -250,7 +265,7 @@ private static Date convertMillisecondsToDate(long milliseconds) {
}
}

private static IndividualRequest mapToIndividualRequest(UserRequest userRequest) {
private static IndividualRequest mapToIndividualRequest(UserRequest userRequest, String localityCode) {
Individual individual = Individual.builder()
.id(userRequest.getUser().getUuid())
.userId(userRequest.getUser().getId() != null ?
Expand All @@ -270,6 +285,7 @@ private static IndividualRequest mapToIndividualRequest(UserRequest userRequest)
.type(AddressType.CORRESPONDENCE)
.addressLine1(userRequest.getUser().getCorrespondenceAddress())
.clientReferenceId(String.valueOf(UUID.randomUUID()))
.locality(Boundary.builder().code(localityCode).build())
yashita-egov marked this conversation as resolved.
Show resolved Hide resolved
.isDeleted(Boolean.FALSE)
.build()))
/*
Expand Down