Search in sources :

Example 36 with CodeSystem

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

the class SnomedExtensionUpgradeTest method upgrade04InternationalAddedDirectlyToExtensionResultsInConflict.

@Test
public void upgrade04InternationalAddedDirectlyToExtensionResultsInConflict() {
    // create extension on the latest SI VERSION
    CodeSystem extension = createExtension(latestInternationalVersion, branchPath.lastSegment());
    // new SI concept
    String newConceptId = createConcept(SnomedContentRule.SNOMEDCT, createConceptRequestBody(Concepts.ROOT_CONCEPT, Concepts.MODULE_SCT_CORE));
    // create a new INT version
    LocalDate effectiveTime = getNextAvailableEffectiveDate(SNOMEDCT);
    createVersion(SNOMEDCT, effectiveTime).statusCode(201);
    ResourceURI upgradeVersion = CodeSystem.uri(SNOMEDCT, effectiveTime.toString());
    // replay SI concept on extension branch, simulating direct import of a preview or release SI RF2
    createConcept(extension.getResourceURI(), createConceptRequestBody(Concepts.ROOT_CONCEPT, Concepts.MODULE_SCT_CORE).with("id", newConceptId));
    createVersion(extension.getId(), "v1", LocalDate.now()).statusCode(201);
    // start upgrade but it fails due to same content present on both sides
    assertCodeSystemUpgrade(extension.getResourceURI(), upgradeVersion).statusCode(409);
}
Also used : ResourceURI(com.b2international.snowowl.core.ResourceURI) CodeSystem(com.b2international.snowowl.core.codesystem.CodeSystem) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 37 with CodeSystem

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

the class SnomedExtensionUpgradeTest method upgrade17UpgradeFromCodeSystemVersionWithPublishedChanges.

@Test
public void upgrade17UpgradeFromCodeSystemVersionWithPublishedChanges() {
    // create extension on the latest SI VERSION
    CodeSystem extension = createExtension(latestInternationalVersion, branchPath.lastSegment());
    // new SI concept
    String newConceptId = 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);
    String newConceptId2 = createConcept(extension.getResourceURI(), createConceptRequestBody(Concepts.ROOT_CONCEPT, extensionModuleId));
    // version extension
    LocalDate effectiveDate2 = getNextAvailableEffectiveDate(extension.getId());
    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);
    assertEquals(upgradeVersion, upgradeCodeSystem.getExtensionOf());
    getComponent(upgradeCodeSystem.getResourceURI(), SnomedComponentType.CONCEPT, newConceptId).statusCode(200);
    getComponent(upgradeCodeSystem.getResourceURI(), SnomedComponentType.CONCEPT, newConceptId2).statusCode(200);
}
Also used : ResourceURI(com.b2international.snowowl.core.ResourceURI) CodeSystem(com.b2international.snowowl.core.codesystem.CodeSystem) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 38 with CodeSystem

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

the class SnomedExtensionUpgradeTest method upgrade15Version.

@Test
public void upgrade15Version() {
    CodeSystem extension = createExtension(latestInternationalVersion, branchPath.lastSegment());
    LocalDate effectiveTime = getNextAvailableEffectiveDate(SNOMEDCT);
    createVersion(SNOMEDCT, effectiveTime).statusCode(201);
    LocalDate newEffectiveDate = getNextAvailableEffectiveDate(SNOMEDCT);
    CodeSystem upgradeCodeSystem = createExtensionUpgrade(extension.getResourceURI(), CodeSystem.uri(SNOMEDCT, effectiveTime.toString()));
    createVersion(upgradeCodeSystem.getId(), newEffectiveDate).statusCode(400);
}
Also used : CodeSystem(com.b2international.snowowl.core.codesystem.CodeSystem) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 39 with CodeSystem

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

the class SnomedExtensionUpgradeTest method upgrade25UpgradeAndSyncOverInactivatedInferredRelationship.

@Test
public void upgrade25UpgradeAndSyncOverInactivatedInferredRelationship() throws Exception {
    // create a new SI parent concept which points to the ROOT and version it
    String intParentConceptId = createConcept(SNOMEDCT_URI, createConceptRequestBody(Concepts.ROOT_CONCEPT, Concepts.MODULE_SCT_CORE));
    // also create the inferred relationship, which will be inactivated
    String intRelationshipIdToInactivate = createRelationship(SNOMEDCT_URI, createRelationshipRequestBody(intParentConceptId, Concepts.IS_A, Concepts.ROOT_CONCEPT, Concepts.INFERRED_RELATIONSHIP));
    LocalDate firstSIVersion = getNextAvailableEffectiveDate(SNOMEDCT);
    createVersion(SNOMEDCT, firstSIVersion).statusCode(201);
    // create extension, a concept pointing to the INT parent concept and a version
    CodeSystem extension = createExtension(SNOMEDCT_URI.withPath(firstSIVersion.toString()), branchPath.lastSegment());
    String extensionModuleId = createModule(extension);
    String extensionConceptId = createConcept(extension.getResourceURI(), createConceptRequestBody(intParentConceptId, extensionModuleId));
    String extensionInferredRelationshipId = createRelationship(extension.getResourceURI(), createRelationshipRequestBody(extensionConceptId, Concepts.IS_A, intParentConceptId, extensionModuleId, Concepts.INFERRED_RELATIONSHIP));
    // verify that extension concept has correct parent/ancestor arrays
    SnomedConcept extensionConceptAfterFirstVersion = getConcept(extension.getResourceURI(), extensionConceptId);
    assertThat(extensionConceptAfterFirstVersion.getParentIdsAsString()).containsOnly(intParentConceptId);
    assertThat(extensionConceptAfterFirstVersion.getAncestorIdsAsString()).containsOnly(IComponent.ROOT_ID, Concepts.ROOT_CONCEPT);
    // inactivate INT inferred relationship
    updateRelationship(SNOMEDCT_URI, intRelationshipIdToInactivate, Json.object(SnomedRf2Headers.FIELD_ACTIVE, false, "commitComment", "Inactivate INT inferred relationship"));
    LocalDate secondSIVersion = getNextAvailableEffectiveDate(SNOMEDCT);
    createVersion(SNOMEDCT, secondSIVersion).statusCode(201);
    CodeSystem upgradeCodeSystem = createExtensionUpgrade(extension.getResourceURI(), SNOMEDCT_URI.withPath(secondSIVersion.toString()));
    // verify that extension concept on upgrade branch, does not have parent info of inactivated things
    SnomedConcept extensionConceptOnUpgrade = getConcept(upgradeCodeSystem.getResourceURI(), extensionConceptId);
    assertThat(extensionConceptOnUpgrade.getParentIdsAsString()).containsOnly(intParentConceptId);
    assertThat(extensionConceptOnUpgrade.getAncestorIdsAsString()).containsOnly(IComponent.ROOT_ID);
    // version the extension and sync the upgrade branch
    LocalDate firstExtensionVersion = getNextAvailableEffectiveDate(extension.getId());
    createVersion(extension.getId(), firstExtensionVersion).statusCode(201);
    Boolean result = CodeSystemRequests.prepareUpgradeSynchronization(upgradeCodeSystem.getResourceURI(), extension.getResourceURI()).buildAsync().execute(getBus()).getSync(1, TimeUnit.MINUTES);
    assertTrue(result);
    // verify that after sync everything looks normal
    SnomedConcept extensionConceptOnUpgradeAfterSync = getConcept(upgradeCodeSystem.getResourceURI(), extensionConceptId);
    assertThat(extensionConceptOnUpgradeAfterSync.getParentIdsAsString()).containsOnly(intParentConceptId);
    assertThat(extensionConceptOnUpgradeAfterSync.getAncestorIdsAsString()).containsOnly(Concepts.ROOT_CONCEPT, IComponent.ROOT_ID);
    assertThat(extensionConceptOnUpgradeAfterSync.getEffectiveTime()).isEqualTo(firstExtensionVersion);
    assertThat(extensionConceptOnUpgradeAfterSync.isReleased()).isTrue();
}
Also used : SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) LocalDate(java.time.LocalDate) CodeSystem(com.b2international.snowowl.core.codesystem.CodeSystem) Test(org.junit.Test)

Example 40 with CodeSystem

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

the class SnomedExtensionUpgradeTest method upgrade08WithBackAndForthDonatedConcept.

@Test
public void upgrade08WithBackAndForthDonatedConcept() {
    // create new version on INT with core module and initial char case insensitive case significance
    String descriptionTerm = "Description term";
    Json initialInternationalDescriptionRequest = Json.object("conceptId", Concepts.ROOT_CONCEPT, "moduleId", Concepts.MODULE_SCT_CORE, "typeId", Concepts.SYNONYM, "term", descriptionTerm, "languageCode", DEFAULT_LANGUAGE_CODE, "acceptability", SnomedApiTestConstants.UK_ACCEPTABLE_MAP, "caseSignificanceId", Concepts.ONLY_INITIAL_CHARACTER_CASE_INSENSITIVE, "commitComment", "Created new synonym");
    String internationalDescriptionId = createDescription(SnomedContentRule.SNOMEDCT, initialInternationalDescriptionRequest);
    LocalDate effectiveTime = getNextAvailableEffectiveDate(SNOMEDCT);
    createVersion(SNOMEDCT, effectiveTime).statusCode(201);
    // create extension on the latest SI VERSION
    CodeSystem extension = createExtension(CodeSystem.uri(SNOMEDCT, effectiveTime.toString()), branchPath.lastSegment());
    String extensionModuleId = createModule(extension);
    // update international description on extension, changing module and case significance
    Json extensionDescriptionUpdateRequest = Json.object("moduleId", extensionModuleId, "caseSignificanceId", Concepts.ENTIRE_TERM_CASE_SENSITIVE, "commitComment", "Changed case significance on description");
    updateDescription(extension.getResourceURI(), internationalDescriptionId, extensionDescriptionUpdateRequest);
    SnomedDescription updatedInternationalDescription = getDescription(extension.getResourceURI(), internationalDescriptionId);
    assertEquals(true, updatedInternationalDescription.isReleased());
    assertEquals(null, updatedInternationalDescription.getEffectiveTime());
    assertEquals(extensionModuleId, updatedInternationalDescription.getModuleId());
    assertEquals(Concepts.ENTIRE_TERM_CASE_SENSITIVE, updatedInternationalDescription.getCaseSignificanceId());
    // create new extension version
    createVersion(extension.getId(), "v1", LocalDate.now()).statusCode(201);
    // donate extension changes to international via RF2 update simulation
    Json descriptionDonateRequest = Json.object("caseSignificanceId", Concepts.ENTIRE_TERM_CASE_SENSITIVE, "commitComment", "Changed case significance on description");
    updateDescription(SnomedContentRule.SNOMEDCT, internationalDescriptionId, descriptionDonateRequest);
    LocalDate donationEffectiveDate = getNextAvailableEffectiveDate(SNOMEDCT);
    createVersion(SNOMEDCT, donationEffectiveDate).statusCode(201);
    // upgrade extension to new INT version with donations
    // start upgrade to the new available upgrade version
    CodeSystem upgradeCodeSystem = createExtensionUpgrade(extension.getResourceURI(), CodeSystem.uri(SNOMEDCT, donationEffectiveDate.toString()));
    SnomedDescription updatedInternationalDescriptionOnUpgrade = getDescription(upgradeCodeSystem.getResourceURI(), internationalDescriptionId);
    assertEquals(true, updatedInternationalDescriptionOnUpgrade.isReleased());
    assertEquals(donationEffectiveDate, updatedInternationalDescriptionOnUpgrade.getEffectiveTime());
    assertEquals(Concepts.MODULE_SCT_CORE, updatedInternationalDescriptionOnUpgrade.getModuleId());
    assertEquals(Concepts.ENTIRE_TERM_CASE_SENSITIVE, updatedInternationalDescriptionOnUpgrade.getCaseSignificanceId());
}
Also used : SnomedDescription(com.b2international.snowowl.snomed.core.domain.SnomedDescription) Json(com.b2international.commons.json.Json) LocalDate(java.time.LocalDate) CodeSystem(com.b2international.snowowl.core.codesystem.CodeSystem) Test(org.junit.Test)

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