use of com.b2international.snowowl.fhir.core.model.operationdefinition.OperationDefinition in project snow-owl by b2ihealthcare.
the class OperationDefinitionTest method deserialize.
@Test
public void deserialize() throws Exception {
OperationDefinition readOperationDefinition = objectMapper.readValue(objectMapper.writeValueAsString(operationDefinition), OperationDefinition.class);
validate(readOperationDefinition);
}
use of com.b2international.snowowl.fhir.core.model.operationdefinition.OperationDefinition in project snow-owl by b2ihealthcare.
the class FhirMetadataController method collectOperationDefinitions.
private Collection<OperationDefinition> collectOperationDefinitions(final OpenAPI openAPI) {
final Paths paths = openAPI.getPaths();
// Collect GET requests within the FHIR services hierarchy where the request path contains a '$' character
return paths.entrySet().stream().filter(e -> {
final String key = e.getKey();
final PathItem value = e.getValue();
return key.startsWith(config.getApiBaseUrl()) && key.contains("$") && (value.getGet() != null);
}).map(e -> buildOperationDefinition(e.getKey(), e.getValue())).collect(Collectors.toList());
}
use of com.b2international.snowowl.fhir.core.model.operationdefinition.OperationDefinition in project snow-owl by b2ihealthcare.
the class FhirMetadataController method initCache.
private Holder initCache() {
final Holder holder = new Holder();
// XXX: we know that the subclass is instantiated (in SnowOwlApiConfig)
final OpenAPI openAPI = ((SnowOwlOpenApiWebMvcResource) openApiWebMvcResource).getOpenApi();
final Collection<Resource> resources = collectResources(openAPI);
final Collection<OperationDefinition> operationDefinitions = collectOperationDefinitions(openAPI);
final Rest.Builder restBuilder = Rest.builder().mode(RestfulCapabilityMode.SERVER).resources(resources);
holder.operationMap = newHashMap();
for (final OperationDefinition operationDefinition : operationDefinitions) {
for (final Code code : operationDefinition.getResources()) {
final String key = code.getCodeValue() + operationDefinition.getName();
holder.operationMap.put(key, operationDefinition);
restBuilder.addOperation(com.b2international.snowowl.fhir.core.model.capabilitystatement.Operation.builder().name(operationDefinition.getName()).definition(buildOperationUrl(code, operationDefinition)).build());
}
}
final String serverVersion = Platform.getBundle(CoreActivator.PLUGIN_ID).getVersion().toString();
String description = ApplicationContext.getServiceForClass(SnowOwlConfiguration.class).getDescription();
holder.capabilityStatement = CapabilityStatement.builder().name("FHIR Capability statement for Snow Owl© Terminology Server").status(PublicationStatus.ACTIVE).experimental(false).kind(CapabilityStatementKind.INSTANCE.getCode()).fhirVersion("4.0.1").addInstantiate(new Uri("http://hl7.org/fhir/CapabilityStatement/terminology-server")).software(Software.builder().name("Snow Owl©").version(serverVersion).build()).implementation(Implementation.builder().url("https://b2i.sg").description(description).build()).addFormat(new Code(AbstractFhirController.APPLICATION_FHIR_JSON)).addRest(restBuilder.build()).build();
return holder;
}
use of com.b2international.snowowl.fhir.core.model.operationdefinition.OperationDefinition in project snow-owl by b2ihealthcare.
the class FhirMetadataController method operationDefinition.
/**
* Returns the {@link OperationDefinition} for a given operation.
* @param operation
* @return
*/
@Operation(summary = "Retrieve an operation definition by its name", description = "Retrieves an operation definition by its compound name (resource$operation).")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "404", description = "Operation definition not found") })
@GetMapping(value = "/OperationDefinition/{operation}")
public OperationDefinition operationDefinition(@PathVariable(value = "operation") final String operation) {
final Map<String, OperationDefinition> operationMap = capabilityStatementSupplier.get().operationMap;
final OperationDefinition operationDefinition = operationMap.get(operation);
if (operationDefinition == null) {
throw new NotFoundException("OperationDefinition", operation);
}
return operationDefinition;
}
Aggregations