Search in sources :

Example 1 with CodeSystems

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

the class SnomedExtensionUpgradeTest method upgrade23UpgradeSychronizeVersion.

@Test
public void upgrade23UpgradeSychronizeVersion() throws Exception {
    // create extension on the latest SI VERSION
    CodeSystem extension = createExtension(latestInternationalVersion, branchPath.lastSegment());
    // new SI concept
    createConcept(SnomedContentRule.SNOMEDCT, createConceptRequestBody(Concepts.ROOT_CONCEPT, Concepts.MODULE_SCT_CORE));
    // create a new INT version
    LocalDate effectiveDate = getNextAvailableEffectiveDate(SNOMEDCT);
    createVersion(SNOMEDCT, effectiveDate).statusCode(201);
    ResourceURI upgradeVersion = CodeSystem.uri(SNOMEDCT, effectiveDate.toString());
    // new SE concept
    String extensionModuleId = createModule(extension);
    createConcept(extension.getResourceURI(), createConceptRequestBody(Concepts.ROOT_CONCEPT, extensionModuleId));
    // version extension
    LocalDate effectiveDate2 = LocalDate.now();
    createVersion(extension.getId(), effectiveDate2).statusCode(201);
    ResourceURI extensionVersion = CodeSystem.uri(extension.getId(), effectiveDate2.toString());
    // new SE concept
    createConcept(extension.getResourceURI(), createConceptRequestBody(Concepts.ROOT_CONCEPT, extensionModuleId));
    // version extension
    LocalDate effectiveDate3 = getNextAvailableEffectiveDate(extension.getId());
    createVersion(extension.getId(), effectiveDate3).statusCode(201);
    ResourceURI extensionVersion2 = CodeSystem.uri(extension.getId(), effectiveDate3.toString());
    // new SE concept
    createConcept(extension.getResourceURI(), createConceptRequestBody(Concepts.ROOT_CONCEPT, extensionModuleId));
    // version extension
    LocalDate effectiveDate4 = getNextAvailableEffectiveDate(extension.getId());
    createVersion(extension.getId(), effectiveDate4).statusCode(201);
    ResourceURI extensionVersion3 = CodeSystem.uri(extension.getId(), effectiveDate4.toString());
    // start upgrade to the new available upgrade version
    CodeSystem upgradeCodeSystem = createExtensionUpgrade(extensionVersion, upgradeVersion);
    CodeSystems expandedCodeSystems = CodeSystemRestRequests.search(upgradeCodeSystem.getId(), CodeSystem.Expand.UPGRADE_INFO + "()");
    assertEquals(upgradeVersion, upgradeCodeSystem.getExtensionOf());
    assertThat(expandedCodeSystems.first().get().getUpgradeInfo().getAvailableVersions()).doesNotContainSequence(extensionVersion);
    assertThat(expandedCodeSystems.first().get().getUpgradeInfo().getAvailableVersions()).contains(extensionVersion2);
    Boolean result = CodeSystemRequests.prepareUpgradeSynchronization(upgradeCodeSystem.getResourceURI(), extensionVersion2).buildAsync().execute(getBus()).getSync(1, TimeUnit.MINUTES);
    assertTrue(result);
    CodeSystems expandedCodeSystemsAfterMerge = CodeSystemRestRequests.search(upgradeCodeSystem.getId(), CodeSystem.Expand.UPGRADE_INFO + "()");
    assertThat(expandedCodeSystemsAfterMerge.first().get().getUpgradeInfo().getAvailableVersions()).containsOnly(extensionVersion3);
}
Also used : ResourceURI(com.b2international.snowowl.core.ResourceURI) CodeSystems(com.b2international.snowowl.core.codesystem.CodeSystems) CodeSystem(com.b2international.snowowl.core.codesystem.CodeSystem) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 2 with CodeSystems

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

the class SnomedExtensionUpgradeTest method upgrade22UpgradeSychronizeHead.

@Test
public void upgrade22UpgradeSychronizeHead() throws Exception {
    // create extension on the latest SI VERSION
    CodeSystem extension = createExtension(latestInternationalVersion, branchPath.lastSegment());
    // new SI concept
    createConcept(SnomedContentRule.SNOMEDCT, createConceptRequestBody(Concepts.ROOT_CONCEPT, Concepts.MODULE_SCT_CORE));
    // create a new INT version
    LocalDate effectiveDate = getNextAvailableEffectiveDate(SNOMEDCT);
    createVersion(SNOMEDCT, effectiveDate).statusCode(201);
    ResourceURI upgradeVersion = CodeSystem.uri(SNOMEDCT, effectiveDate.toString());
    // new SE concept
    String extensionModuleId = createModule(extension);
    createConcept(extension.getResourceURI(), createConceptRequestBody(Concepts.ROOT_CONCEPT, extensionModuleId));
    // version extension
    LocalDate effectiveDate2 = LocalDate.now();
    createVersion(extension.getId(), effectiveDate2).statusCode(201);
    ResourceURI extensionVersion = CodeSystem.uri(extension.getId(), effectiveDate2.toString());
    // new SE concept
    createConcept(extension.getResourceURI(), createConceptRequestBody(Concepts.ROOT_CONCEPT, extensionModuleId));
    // version extension
    LocalDate effectiveDate3 = getNextAvailableEffectiveDate(extension.getId());
    createVersion(extension.getId(), effectiveDate3).statusCode(201);
    ResourceURI extensionVersion2 = CodeSystem.uri(extension.getId(), effectiveDate3.toString());
    // start upgrade to the new available upgrade version
    CodeSystem upgradeCodeSystem = createExtensionUpgrade(extensionVersion, upgradeVersion);
    CodeSystems expandedCodeSystems = CodeSystemRestRequests.search(upgradeCodeSystem.getId(), CodeSystem.Expand.UPGRADE_INFO + "()");
    assertEquals(upgradeVersion, upgradeCodeSystem.getExtensionOf());
    assertThat(expandedCodeSystems.first().get().getUpgradeInfo().getAvailableVersions()).doesNotContainSequence(extensionVersion);
    assertThat(expandedCodeSystems.first().get().getUpgradeInfo().getAvailableVersions()).contains(extensionVersion2);
    IBranchPath extensionBranch = BranchPathUtils.createPath(extension.getBranchPath());
    IBranchPath upgradeBranch = BranchPathUtils.createPath(upgradeCodeSystem.getBranchPath());
    merge(extensionBranch, upgradeBranch, "Merged new concept from child branch").body("status", equalTo(Merge.Status.COMPLETED.name()));
    Boolean result = CodeSystemRequests.prepareUpgradeSynchronization(upgradeCodeSystem.getResourceURI(), extension.getResourceURI()).buildAsync().execute(getBus()).getSync(1, TimeUnit.MINUTES);
    assertTrue(result);
    CodeSystems expandedCodeSystemsAfterMerge = CodeSystemRestRequests.search(upgradeCodeSystem.getId(), CodeSystem.Expand.UPGRADE_INFO + "()");
    assertThat(expandedCodeSystemsAfterMerge.first().get().getUpgradeInfo().getAvailableVersions()).isEmpty();
}
Also used : ResourceURI(com.b2international.snowowl.core.ResourceURI) CodeSystems(com.b2international.snowowl.core.codesystem.CodeSystems) CodeSystem(com.b2international.snowowl.core.codesystem.CodeSystem) LocalDate(java.time.LocalDate) IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test)

Example 3 with CodeSystems

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

the class SnomedContentRule method createCodeSystemIfNotExist.

private void createCodeSystemIfNotExist() {
    final IEventBus eventBus = Services.bus();
    final CodeSystems codeSystems = CodeSystemRequests.prepareSearchCodeSystem().setLimit(0).filterById(codeSystemId.getResourceId()).buildAsync().execute(eventBus).getSync();
    if (codeSystems.getTotal() > 0) {
        return;
    }
    final ResourceURI extensionOf = Optional.ofNullable(this.extensionOf).or(() -> {
        return ResourceRequests.prepareSearchVersion().filterByResource(SNOMEDCT).sortBy(Sort.fieldDesc(VersionDocument.Fields.EFFECTIVE_TIME)).setLimit(1).buildAsync().execute(eventBus).getSync().first().map(Version::getVersionResourceURI);
    }).orElse(null);
    CodeSystemRequests.prepareNewCodeSystem().setId(codeSystemId.getResourceId()).setBranchPath(SNOMEDCT.equals(codeSystemId) ? Branch.MAIN_PATH : null).setUrl(SNOMEDCT.equals(codeSystemId) ? SnomedTerminologyComponentConstants.SNOMED_URI_SCT + "/" + Concepts.MODULE_SCT_CORE : SnomedTerminologyComponentConstants.SNOMED_URI_SCT + "/" + codeSystemId.getResourceId()).setDescription("description").setExtensionOf(extensionOf).setLanguage("ENG").setTitle(codeSystemId.getResourceId()).setOid("oid:" + codeSystemId).setOwner("https://b2i.sg").setToolingId(SnomedTerminologyComponentConstants.TOOLING_ID).setSettings(Map.of(SnomedTerminologyComponentConstants.CODESYSTEM_LANGUAGE_CONFIG_KEY, List.of(Map.of("languageTag", "en", "languageRefSetIds", Lists.newArrayList(Concepts.REFSET_LANGUAGE_TYPE_UK, Concepts.REFSET_LANGUAGE_TYPE_US))))).build(RestExtensions.USER, String.format("Create code system %s", codeSystemId)).execute(eventBus).getSync(1, TimeUnit.MINUTES);
}
Also used : ResourceURI(com.b2international.snowowl.core.ResourceURI) CodeSystems(com.b2international.snowowl.core.codesystem.CodeSystems) IEventBus(com.b2international.snowowl.eventbus.IEventBus)

Example 4 with CodeSystems

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

the class SnomedExtensionUpgradeTest method upgrade21ExpandUpgradeInfo.

@Test
public void upgrade21ExpandUpgradeInfo() throws Exception {
    // create extension on the latest SI VERSION
    CodeSystem extension = createExtension(latestInternationalVersion, branchPath.lastSegment());
    // new SI concept
    createConcept(SnomedContentRule.SNOMEDCT, createConceptRequestBody(Concepts.ROOT_CONCEPT, Concepts.MODULE_SCT_CORE));
    // create a new INT version
    LocalDate effectiveDate = getNextAvailableEffectiveDate(SNOMEDCT);
    createVersion(SNOMEDCT, effectiveDate).statusCode(201);
    ResourceURI upgradeVersion = CodeSystem.uri(SNOMEDCT, effectiveDate.toString());
    // new SE concept
    String extensionModuleId = createModule(extension);
    createConcept(extension.getResourceURI(), createConceptRequestBody(Concepts.ROOT_CONCEPT, extensionModuleId));
    // version extension
    LocalDate effectiveDate2 = LocalDate.now();
    createVersion(extension.getId(), effectiveDate2).statusCode(201);
    ResourceURI extensionVersion = CodeSystem.uri(extension.getId(), effectiveDate2.toString());
    // start upgrade to the new available upgrade version
    CodeSystem upgradeCodeSystem = createExtensionUpgrade(extensionVersion, upgradeVersion);
    // new SE concept
    createConcept(extension.getResourceURI(), createConceptRequestBody(Concepts.ROOT_CONCEPT, extensionModuleId));
    // version extension
    LocalDate effectiveDate3 = getNextAvailableEffectiveDate(extension.getId());
    createVersion(extension.getId(), effectiveDate3).statusCode(201);
    ResourceURI extensionVersion2 = CodeSystem.uri(extension.getId(), effectiveDate3.toString());
    CodeSystems expandedCodeSystems = CodeSystemRestRequests.search(upgradeCodeSystem.getId(), CodeSystem.Expand.UPGRADE_INFO + "()");
    assertEquals(upgradeVersion, upgradeCodeSystem.getExtensionOf());
    assertThat(expandedCodeSystems.first().get().getUpgradeInfo().getAvailableVersions()).doesNotContainSequence(extensionVersion);
    assertThat(expandedCodeSystems.first().get().getUpgradeInfo().getAvailableVersions()).contains(extensionVersion2);
}
Also used : ResourceURI(com.b2international.snowowl.core.ResourceURI) CodeSystems(com.b2international.snowowl.core.codesystem.CodeSystems) CodeSystem(com.b2international.snowowl.core.codesystem.CodeSystem) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 5 with CodeSystems

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

the class SnomedExtensionUpgradeTest method upgrade20ExpandUpgradeInfo.

@Test
public void upgrade20ExpandUpgradeInfo() throws Exception {
    // create extension on the latest SI VERSION
    CodeSystem extension = createExtension(latestInternationalVersion, branchPath.lastSegment());
    // new SI concept
    createConcept(SnomedContentRule.SNOMEDCT, createConceptRequestBody(Concepts.ROOT_CONCEPT, Concepts.MODULE_SCT_CORE));
    // create a new INT version
    LocalDate effectiveDate = getNextAvailableEffectiveDate(SNOMEDCT);
    createVersion(SNOMEDCT, effectiveDate).statusCode(201);
    ResourceURI upgradeVersion = CodeSystem.uri(SNOMEDCT, effectiveDate.toString());
    // new SE concept
    String extensionModuleId = createModule(extension);
    createConcept(extension.getResourceURI(), createConceptRequestBody(Concepts.ROOT_CONCEPT, extensionModuleId));
    // version extension
    LocalDate effectiveDate2 = LocalDate.now();
    createVersion(extension.getId(), effectiveDate2).statusCode(201);
    ResourceURI extensionVersion = CodeSystem.uri(extension.getId(), effectiveDate2.toString());
    // new SE concept
    createConcept(extension.getResourceURI(), createConceptRequestBody(Concepts.ROOT_CONCEPT, extensionModuleId));
    // version extension
    LocalDate effectiveDate3 = getNextAvailableEffectiveDate(extension.getId());
    createVersion(extension.getId(), effectiveDate3).statusCode(201);
    ResourceURI extensionVersion2 = CodeSystem.uri(extension.getId(), effectiveDate3.toString());
    // start upgrade to the new available upgrade version
    CodeSystem upgradeCodeSystem = createExtensionUpgrade(extensionVersion, upgradeVersion);
    CodeSystems expandedCodeSystems = CodeSystemRestRequests.search(upgradeCodeSystem.getId(), CodeSystem.Expand.UPGRADE_INFO + "()");
    assertEquals(upgradeVersion, upgradeCodeSystem.getExtensionOf());
    assertThat(expandedCodeSystems.first().get().getUpgradeInfo().getAvailableVersions()).doesNotContainSequence(extensionVersion);
    assertThat(expandedCodeSystems.first().get().getUpgradeInfo().getAvailableVersions()).contains(extensionVersion2);
}
Also used : ResourceURI(com.b2international.snowowl.core.ResourceURI) CodeSystems(com.b2international.snowowl.core.codesystem.CodeSystems) CodeSystem(com.b2international.snowowl.core.codesystem.CodeSystem) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Aggregations

ResourceURI (com.b2international.snowowl.core.ResourceURI)5 CodeSystems (com.b2international.snowowl.core.codesystem.CodeSystems)5 CodeSystem (com.b2international.snowowl.core.codesystem.CodeSystem)4 LocalDate (java.time.LocalDate)4 Test (org.junit.Test)4 IBranchPath (com.b2international.snowowl.core.api.IBranchPath)1 IEventBus (com.b2international.snowowl.eventbus.IEventBus)1