Skip to content

Commit 69b8c1b

Browse files
committed
SO-4900: Create code system upgrade sync and complete end-points
1 parent 9de144a commit 69b8c1b

File tree

1 file changed

+56
-2
lines changed

1 file changed

+56
-2
lines changed

core/com.b2international.snowowl.core.rest/src/com/b2international/snowowl/core/rest/codesystem/CodeSystemUpgradeRestService.java

+56-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class CodeSystemUpgradeRestService extends AbstractRestService {
4444
notes="Starts the upgrade process of a Code System to a newer extensionOf Code System dependency than the current extensionOf."
4545
)
4646
@ApiResponses({
47-
@ApiResponse(code = 204, message = "Upgrade ", response = Void.class),
47+
@ApiResponse(code = 201, message = "Upgrade ", response = Void.class),
4848
@ApiResponse(code = 400, message = "Code System cannot be upgraded", response = RestApiError.class)
4949
})
5050
@PostMapping(consumes = { AbstractRestService.JSON_MEDIA_TYPE })
@@ -70,5 +70,59 @@ public Promise<ResponseEntity<Void>> upgrade(
7070
return ResponseEntity.created(uriBuilder.pathSegment(upgradeCodeSystemId).build().toUri()).build();
7171
});
7272
}
73-
73+
74+
@ApiOperation(
75+
value="Synchronize upgrade codesystem with the original codesystem (EXPERIMENTAL)",
76+
notes="Synchroinze any changes on the original code system with the upgrade code system."
77+
)
78+
@ApiResponses({
79+
@ApiResponse(code = 204, message = "Synchronization "),
80+
@ApiResponse(code = 400, message = "Code system could not be synchronized with the downstream code system", response = RestApiError.class)
81+
})
82+
@PostMapping("/sync/{id}")
83+
@ResponseStatus(HttpStatus.NO_CONTENT)
84+
public void sync(
85+
@ApiParam(value = "Code System identifier", required = true)
86+
@PathVariable("id")
87+
final String codeSystemId) {
88+
final CodeSystem codeSystem = CodeSystemRequests.prepareSearchAllCodeSystems()
89+
.filterById(codeSystemId)
90+
.buildAsync()
91+
.execute(getBus())
92+
.getSync(1, TimeUnit.MINUTES)
93+
.first()
94+
.orElseThrow(() -> new NotFoundException("Code System", codeSystemId));
95+
96+
CodeSystemRequests.prepareUpgradeSynchronization(codeSystem.getCodeSystemURI(), codeSystem.getUpgradeOf())
97+
.build(codeSystem.getRepositoryId())
98+
.execute(getBus());
99+
}
100+
101+
@ApiOperation(
102+
value="Complete a codesystem upgrade (EXPERIMENTAL)",
103+
notes="Completes the upgrade process of a Code System to the newer extensionOf Code System dependency."
104+
)
105+
@ApiResponses({
106+
@ApiResponse(code = 204, message = "Complete "),
107+
@ApiResponse(code = 400, message = "Code System upgrade cannot be completed", response = RestApiError.class)
108+
})
109+
@PostMapping("/complete/{id}")
110+
@ResponseStatus(HttpStatus.NO_CONTENT)
111+
public void complete(
112+
@ApiParam(value = "Code System identifier", required = true)
113+
@PathVariable("id")
114+
final String codeSystemId) {
115+
final CodeSystem codeSystem = CodeSystemRequests.prepareSearchAllCodeSystems()
116+
.filterById(codeSystemId)
117+
.buildAsync()
118+
.execute(getBus())
119+
.getSync(1, TimeUnit.MINUTES)
120+
.first()
121+
.orElseThrow(() -> new NotFoundException("Code System", codeSystemId));
122+
123+
CodeSystemRequests.prepareComplete(codeSystemId)
124+
.build(codeSystem.getRepositoryId())
125+
.execute(getBus());
126+
}
127+
74128
}

0 commit comments

Comments
 (0)