Skip to content

Commit

Permalink
PR Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilDigitalJustice committed Jan 9, 2024
1 parent ecddd5c commit ab370b9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,15 @@ public ResponseEntity<Void> createApplication(
/**
* Retrieves the details of a specific application.
*
* @param applicationId the unique identifier of the application
* @return a ResponseEntity containing the details of the application
* @param caseReferenceNumber Unique reference number for the case.
* @param providerCaseRef Reference provided by the case provider.
* @param clientSurname Surname of the client associated with the case.
* @param clientReference Client's personal reference for the case.
* @param feeEarner The individual responsible for handling the case fees.
* @param officeId Identifier for the office managing the case.
* @param status Current status of the application.
* @param pageable Pagination information for the response.
* @return ResponseEntity containing the application details.
*/
@Override
public ResponseEntity<ApplicationDetails> getApplications(
Expand Down Expand Up @@ -170,7 +177,7 @@ public ResponseEntity<Void> putApplicationProviderDetails(
//application type

/**
* Retrieves the type of a specific application.
* Retrieves the application type for a specific application.
*
* @param applicationId the unique identifier of the application
* @return a ResponseEntity containing the type of the application
Expand All @@ -184,7 +191,7 @@ public ResponseEntity<ApplicationType> getApplicationType(
}

/**
* Updates the type of a specific application.
* Updates the application type for a specific application.
*
* @param applicationId the unique identifier of the application
* @param caabUserLoginId the user login ID used for audit trail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ public List<LinkedCase> getLinkedCasesForApplication(final Long id) {
* Creates and associates a new linked case with a specified application.
* If the application is not found, a CaabApiException is thrown.
*
* @param id The unique identifier of the application.
* @param applicationId The unique identifier of the application.
* @param linkedCase The LinkedCase object containing the details of the case to be linked.
* @throws CaabApiException If the application with the specified ID is not found.
*/
@Transactional
public void createLinkedCaseForApplication(final Long id, final LinkedCase linkedCase) {
Application application = applicationRepository.findById(id)
public void createLinkedCaseForApplication(final Long applicationId, final LinkedCase linkedCase) {
Application application = applicationRepository.findById(applicationId)
.orElseThrow(() -> new CaabApiException(
String.format("Application with id %s not found", id), HttpStatus.NOT_FOUND));
String.format("Application with id %s not found", applicationId), HttpStatus.NOT_FOUND));

uk.gov.laa.ccms.caab.api.entity.LinkedCase linkedCaseEntity =
applicationMapper.toLinkedCase(linkedCase);
Expand All @@ -143,23 +143,25 @@ public void createLinkedCaseForApplication(final Long id, final LinkedCase linke
* Removes a linked case from the specified application.
* If either the application or the linked case is not found, a CaabApiException is thrown.
*
* @param id The unique identifier of the application.
* @param applicationId The unique identifier of the application.
* @param linkedCaseId The unique identifier of the linked case to be removed.
* @throws CaabApiException If the application or the linked case with the specified IDs are
* not found.
*/
@Transactional
public void removeLinkedCaseFromApplication(final Long id, final Long linkedCaseId) {
Application application = applicationRepository.findById(id)
public void removeLinkedCaseFromApplication(final Long applicationId, final Long linkedCaseId) {
Application application = applicationRepository.findById(applicationId)
.orElseThrow(() -> new CaabApiException(
String.format("Application with id %s not found", id), HttpStatus.NOT_FOUND));
String.format("Application with id %s not found", applicationId),
HttpStatus.NOT_FOUND));

uk.gov.laa.ccms.caab.api.entity.LinkedCase linkedCaseEntity =
application.getLinkedCases().stream()
.filter(linkedCase -> linkedCase.getId().equals(linkedCaseId))
.findFirst()
.orElseThrow(() -> new CaabApiException(
String.format("Linked case with id %s not found", linkedCaseId), HttpStatus.NOT_FOUND));
String.format("Linked case with id %s not found", linkedCaseId),
HttpStatus.NOT_FOUND));

application.getLinkedCases().remove(linkedCaseEntity);
applicationRepository.save(application);
Expand All @@ -169,26 +171,28 @@ public void removeLinkedCaseFromApplication(final Long id, final Long linkedCase
* Updates a linked case of a specified application.
* If either the application or the linked case is not found, a CaabApiException is thrown.
*
* @param id The unique identifier of the application.
* @param applicationId The unique identifier of the application.
* @param linkedCaseId The unique identifier of the linked case to be updated.
* @param linkedCaseModel The LinkedCase object containing the details of the case to be updated.
* @throws CaabApiException If the application or the linked case with the specified IDs are not
* found.
*/
@Transactional
public void updateLinkedCaseForApplication(
final Long id, final Long linkedCaseId,
final Long applicationId, final Long linkedCaseId,
final LinkedCase linkedCaseModel) {
Application application = applicationRepository.findById(id)
Application application = applicationRepository.findById(applicationId)
.orElseThrow(() -> new CaabApiException(
String.format("Application with id %s not found", id), HttpStatus.NOT_FOUND));
String.format("Application with id %s not found", applicationId),
HttpStatus.NOT_FOUND));

uk.gov.laa.ccms.caab.api.entity.LinkedCase linkedCaseEntity =
application.getLinkedCases().stream()
.filter(linkedCase -> linkedCase.getId().equals(linkedCaseId))
.findFirst()
.orElseThrow(() -> new CaabApiException(
String.format("Linked case with id %s not found", linkedCaseId), HttpStatus.NOT_FOUND));
String.format("Linked case with id %s not found", linkedCaseId),
HttpStatus.NOT_FOUND));

applicationMapper.updateLinkedCase(linkedCaseEntity, linkedCaseModel);
applicationRepository.save(application);
Expand Down

0 comments on commit ab370b9

Please sign in to comment.