Skip to content
New issue

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

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

Already on GitHub? # to your account

SO-4900: Create code system upgrade sync and complete end-points #872

Merged
merged 1 commit into from
Aug 5, 2021
Merged
Changes from all commits
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 @@ -44,7 +44,7 @@ public class CodeSystemUpgradeRestService extends AbstractRestService {
notes="Starts the upgrade process of a Code System to a newer extensionOf Code System dependency than the current extensionOf."
)
@ApiResponses({
@ApiResponse(code = 204, message = "Upgrade ", response = Void.class),
@ApiResponse(code = 201, message = "Upgrade ", response = Void.class),
@ApiResponse(code = 400, message = "Code System cannot be upgraded", response = RestApiError.class)
})
@PostMapping(consumes = { AbstractRestService.JSON_MEDIA_TYPE })
Expand All @@ -70,5 +70,59 @@ public Promise<ResponseEntity<Void>> upgrade(
return ResponseEntity.created(uriBuilder.pathSegment(upgradeCodeSystemId).build().toUri()).build();
});
}


@ApiOperation(
value="Synchronize upgrade codesystem with the original codesystem (EXPERIMENTAL)",
notes="Synchroinze any changes on the original code system with the upgrade code system."
)
@ApiResponses({
@ApiResponse(code = 204, message = "Synchronization "),
@ApiResponse(code = 400, message = "Code system could not be synchronized with the downstream code system", response = RestApiError.class)
})
@PostMapping("/sync/{id}")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void sync(
@ApiParam(value = "Code System identifier", required = true)
@PathVariable("id")
final String codeSystemId) {
final CodeSystem codeSystem = CodeSystemRequests.prepareSearchAllCodeSystems()
.filterById(codeSystemId)
.buildAsync()
.execute(getBus())
.getSync(1, TimeUnit.MINUTES)
.first()
.orElseThrow(() -> new NotFoundException("Code System", codeSystemId));

CodeSystemRequests.prepareUpgradeSynchronization(codeSystem.getCodeSystemURI(), codeSystem.getUpgradeOf())
.build(codeSystem.getRepositoryId())
.execute(getBus());
}

@ApiOperation(
value="Complete a codesystem upgrade (EXPERIMENTAL)",
notes="Completes the upgrade process of a Code System to the newer extensionOf Code System dependency."
)
@ApiResponses({
@ApiResponse(code = 204, message = "Complete "),
@ApiResponse(code = 400, message = "Code System upgrade cannot be completed", response = RestApiError.class)
})
@PostMapping("/complete/{id}")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void complete(
@ApiParam(value = "Code System identifier", required = true)
@PathVariable("id")
final String codeSystemId) {
final CodeSystem codeSystem = CodeSystemRequests.prepareSearchAllCodeSystems()
.filterById(codeSystemId)
.buildAsync()
.execute(getBus())
.getSync(1, TimeUnit.MINUTES)
.first()
.orElseThrow(() -> new NotFoundException("Code System", codeSystemId));

CodeSystemRequests.prepareComplete(codeSystemId)
.build(codeSystem.getRepositoryId())
.execute(getBus());
}

}