use of com.b2international.snowowl.fhir.core.model.dt.Code 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.dt.Code in project snow-owl by b2ihealthcare.
the class FhirParametersRequestEntryProcessor method doProcess.
@Override
public void doProcess(ArrayNode arrayNode, HttpServletRequest request) throws JsonMappingException, JsonProcessingException {
BatchRequest batchRequest = requestEntry.getRequest();
Code requestMethod = batchRequest.getMethod();
if (!requestMethod.equals(HttpVerb.POST.getCode())) {
createInvalidMethodResponse(arrayNode, requestMethod);
return;
}
HttpHeaders headers = getHeaders(request);
RestTemplate restTemplate = getRestTemplate();
StringBuilder uriBuilder = new StringBuilder(request.getScheme()).append("://").append(request.getServerName()).append(":").append(request.getLocalPort()).append(request.getRequestURI()).append(batchRequest.getUrl().getUriValue());
// TODO: change the RequestEntry to accommodate resources for non-operation bulk support
HttpEntity<?> httpEntity = new HttpEntity<>(requestEntry.getRequestResource(), headers);
ResponseEntity<String> response = restTemplate.exchange(uriBuilder.toString(), HttpMethod.POST, httpEntity, String.class);
String json = response.getBody();
ObjectNode resourceNode = (ObjectNode) objectMapper.readTree(json);
addResponse(arrayNode, resourceNode, String.valueOf(response.getStatusCode().value()));
}
Aggregations