Search in sources :

Example 21 with CodeSystem

use of com.b2international.snowowl.core.codesystem.CodeSystem in project snow-owl by b2ihealthcare.

the class CodeSystemResource method configureCodeSystem.

public static void configureCodeSystem(final TestBranchContext.Builder context) {
    final List<Map<String, Object>> languageMap = Lists.newArrayList();
    languageMap.add(Map.of("languageTag", US_LOCALE.getLanguageTag(), "languageRefSetIds", List.of(Concepts.REFSET_LANGUAGE_TYPE_US)));
    languageMap.add(Map.of("languageTag", GB_LOCALE.getLanguageTag(), "languageRefSetIds", List.of(Concepts.REFSET_LANGUAGE_TYPE_UK)));
    languageMap.add(Map.of("languageTag", SG_LOCALE.getLanguageTag(), "languageRefSetIds", List.of(Concepts.REFSET_LANGUAGE_TYPE_SG)));
    final CodeSystem cs = new CodeSystem();
    cs.setBranchPath(Branch.MAIN_PATH);
    cs.setId(SnomedContentRule.SNOMEDCT_ID);
    cs.setSettings(Map.of(SnomedTerminologyComponentConstants.CODESYSTEM_LANGUAGE_CONFIG_KEY, languageMap));
    context.with(TerminologyResource.class, cs);
}
Also used : Map(java.util.Map) CodeSystem(com.b2international.snowowl.core.codesystem.CodeSystem)

Example 22 with CodeSystem

use of com.b2international.snowowl.core.codesystem.CodeSystem in project snow-owl by b2ihealthcare.

the class BaseSnomedEclEvaluationRequestTest method createCodeSystem.

private CodeSystem createCodeSystem(String main) {
    CodeSystem codeSystem = new CodeSystem();
    codeSystem.setId("SNOMEDCT");
    codeSystem.setBranchPath(main);
    codeSystem.setSettings(Map.of(SnomedTerminologyComponentConstants.CODESYSTEM_LANGUAGE_CONFIG_KEY, List.of(Map.of("languageTag", "en", "languageRefSetIds", List.of(Concepts.REFSET_LANGUAGE_TYPE_UK, Concepts.REFSET_LANGUAGE_TYPE_US)), Map.of("languageTag", "en-us", "languageRefSetIds", List.of(Concepts.REFSET_LANGUAGE_TYPE_US)), Map.of("languageTag", "en-gb", "languageRefSetIds", List.of(Concepts.REFSET_LANGUAGE_TYPE_UK)))));
    return codeSystem;
}
Also used : CodeSystem(com.b2international.snowowl.core.codesystem.CodeSystem)

Example 23 with CodeSystem

use of com.b2international.snowowl.core.codesystem.CodeSystem in project snow-owl by b2ihealthcare.

the class BaseGenericValidationRuleTest method configureContext.

@Override
protected void configureContext(Builder context) {
    super.configureContext(context);
    final CodeSystem cs = new CodeSystem();
    cs.setBranchPath(MAIN);
    cs.setId(CODESYSTEM);
    context.with(TerminologyResource.class, cs).with(EclParser.class, new DefaultEclParser(ECL_INJECTOR.getInstance(IParser.class), ECL_INJECTOR.getInstance(IResourceValidator.class))).with(EclSerializer.class, new DefaultEclSerializer(ECL_INJECTOR.getInstance(ISerializer.class)));
}
Also used : DefaultEclParser(com.b2international.snowowl.snomed.core.ecl.DefaultEclParser) IResourceValidator(org.eclipse.xtext.validation.IResourceValidator) DefaultEclSerializer(com.b2international.snowowl.snomed.core.ecl.DefaultEclSerializer) DefaultEclParser(com.b2international.snowowl.snomed.core.ecl.DefaultEclParser) EclParser(com.b2international.snowowl.snomed.core.ecl.EclParser) CodeSystem(com.b2international.snowowl.core.codesystem.CodeSystem) IParser(org.eclipse.xtext.parser.IParser)

Example 24 with CodeSystem

use of com.b2international.snowowl.core.codesystem.CodeSystem in project snow-owl by b2ihealthcare.

the class CodeSystemRestService method delete.

@Operation(summary = "Delete a CodeSystem", description = "Deletes a CodeSystem permanently from the server")
@ApiResponses({ @ApiResponse(responseCode = "204", description = "No content"), @ApiResponse(responseCode = "400", description = "Bad Request"), @ApiResponse(responseCode = "409", description = "CodeSystem cannot be deleted") })
@DeleteMapping(value = "/{codeSystemId}")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void delete(@Parameter(description = "The code system identifier") @PathVariable(value = "codeSystemId") final String codeSystemId, @RequestHeader(value = X_AUTHOR, required = false) final String author) {
    try {
        final CodeSystem codeSystem = CodeSystemRequests.prepareGetCodeSystem(codeSystemId).buildAsync().execute(getBus()).getSync(1, TimeUnit.MINUTES);
        ResourceRequests.prepareDelete(codeSystemId).build(author, String.format("Deleted Code System %s", codeSystem.getTitle())).execute(getBus()).getSync(COMMIT_TIMEOUT, TimeUnit.MINUTES);
    } catch (NotFoundException e) {
    // already deleted, ignore error
    }
}
Also used : NotFoundException(com.b2international.commons.exceptions.NotFoundException) CodeSystem(com.b2international.snowowl.core.codesystem.CodeSystem) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 25 with CodeSystem

use of com.b2international.snowowl.core.codesystem.CodeSystem in project snow-owl by b2ihealthcare.

the class CodeSystemUpgradeRestService method upgrade.

@Operation(summary = "Start a Code System dependency upgrade (EXPERIMENTAL)", description = "Starts the upgrade process of a Code System to a newer extensionOf Code System dependency than the current extensionOf.")
@ApiResponses({ @ApiResponse(responseCode = "201", description = "Upgrade created"), @ApiResponse(responseCode = "400", description = "Code System cannot be upgraded") })
@PostMapping(consumes = { AbstractRestService.JSON_MEDIA_TYPE })
@ResponseStatus(HttpStatus.CREATED)
public Promise<ResponseEntity<Void>> upgrade(@RequestBody final UpgradeRestInput body) {
    final UriComponentsBuilder uriBuilder = createURIBuilder();
    final ResourceURI upgradeOf = new ResourceURI(body.getUpgradeOf());
    final IEventBus bus = getBus();
    return // TODO move this to generic resource controller
    CodeSystemRequests.prepareGetCodeSystem(upgradeOf.getResourceId()).buildAsync().execute(bus).thenWith(codeSystem -> {
        return CodeSystemRequests.prepareUpgrade(upgradeOf, new ResourceURI(body.getExtensionOf())).setResourceId(body.getCodeSystemId()).buildAsync().execute(bus);
    }).then(upgradeCodeSystemId -> {
        return ResponseEntity.created(uriBuilder.pathSegment(upgradeCodeSystemId).build().toUri()).build();
    });
}
Also used : CodeSystem(com.b2international.snowowl.core.codesystem.CodeSystem) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) AbstractRestService(com.b2international.snowowl.core.rest.AbstractRestService) Promise(com.b2international.snowowl.core.events.util.Promise) IEventBus(com.b2international.snowowl.eventbus.IEventBus) TimeUnit(java.util.concurrent.TimeUnit) Parameter(io.swagger.v3.oas.annotations.Parameter) HttpStatus(org.springframework.http.HttpStatus) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponse(io.swagger.v3.oas.annotations.responses.ApiResponse) Tag(io.swagger.v3.oas.annotations.tags.Tag) org.springframework.web.bind.annotation(org.springframework.web.bind.annotation) ResponseEntity(org.springframework.http.ResponseEntity) CodeSystemRequests(com.b2international.snowowl.core.codesystem.CodeSystemRequests) NotFoundException(com.b2international.commons.exceptions.NotFoundException) ResourceURI(com.b2international.snowowl.core.ResourceURI) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses) ResourceURI(com.b2international.snowowl.core.ResourceURI) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) IEventBus(com.b2international.snowowl.eventbus.IEventBus) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Aggregations

CodeSystem (com.b2international.snowowl.core.codesystem.CodeSystem)45 Test (org.junit.Test)34 LocalDate (java.time.LocalDate)33 ResourceURI (com.b2international.snowowl.core.ResourceURI)21 SnomedConcept (com.b2international.snowowl.snomed.core.domain.SnomedConcept)14 Json (com.b2international.commons.json.Json)8 CodeSystemRestRequests.createCodeSystem (com.b2international.snowowl.test.commons.codesystem.CodeSystemRestRequests.createCodeSystem)6 CodeSystems (com.b2international.snowowl.core.codesystem.CodeSystems)5 SnomedDescription (com.b2international.snowowl.snomed.core.domain.SnomedDescription)5 CodeSystemRequests (com.b2international.snowowl.core.codesystem.CodeSystemRequests)4 TimeUnit (java.util.concurrent.TimeUnit)4 Collectors (java.util.stream.Collectors)4 BadRequestException (com.b2international.commons.exceptions.BadRequestException)3 NotFoundException (com.b2international.commons.exceptions.NotFoundException)3 TerminologyResource (com.b2international.snowowl.core.TerminologyResource)3 SnowowlRuntimeException (com.b2international.snowowl.core.api.SnowowlRuntimeException)3 Attachment (com.b2international.snowowl.core.attachments.Attachment)3 AttachmentRegistry (com.b2international.snowowl.core.attachments.AttachmentRegistry)3 DateFormats (com.b2international.snowowl.core.date.DateFormats)3 EffectiveTimes (com.b2international.snowowl.core.date.EffectiveTimes)3