use of com.b2international.snowowl.core.ResourceURI in project snow-owl by b2ihealthcare.
the class SnomedExtensionUpgradeTest method upgrade24UpgradeWithEmptyExtension.
@Test
public void upgrade24UpgradeWithEmptyExtension() throws Exception {
// new SI concept
ResourceURI base = CodeSystem.uri(SNOMEDCT);
createConcept(base, createConceptRequestBody(Concepts.ROOT_CONCEPT, Concepts.MODULE_SCT_CORE));
// create a new INT version
LocalDate effectiveDate1 = getNextAvailableEffectiveDate(SNOMEDCT);
createVersion(SNOMEDCT, effectiveDate1).statusCode(201);
ResourceURI upgradeVersion1 = base.withPath(effectiveDate1.toString());
// new SI concept
String conceptId = createConcept(base, createConceptRequestBody(Concepts.ROOT_CONCEPT, Concepts.MODULE_SCT_CORE));
// create a new INT version
LocalDate effectiveDate2 = getNextAvailableEffectiveDate(SNOMEDCT);
createVersion(SNOMEDCT, effectiveDate2).statusCode(201);
ResourceURI upgradeVersion2 = base.withPath(effectiveDate2.toString());
// new SI concept
createConcept(base, createConceptRequestBody(Concepts.ROOT_CONCEPT, Concepts.MODULE_SCT_CORE));
// create a new INT version
LocalDate effectiveDate3 = getNextAvailableEffectiveDate(SNOMEDCT);
createVersion(SNOMEDCT, effectiveDate3).statusCode(201);
ResourceURI upgradeVersion3 = base.withPath(effectiveDate3.toString());
// create extension on the latest SI VERSION
CodeSystem extension = createExtension(upgradeVersion1, branchPath.lastSegment());
// start upgrade to the new available upgrade version
CodeSystem upgradeCodeSystem = createExtensionUpgrade(extension.getResourceURI(), upgradeVersion2);
assertState(upgradeCodeSystem.getBranchPath(), extension.getBranchPath(), BranchState.FORWARD);
Boolean result = CodeSystemRequests.prepareUpgradeSynchronization(upgradeCodeSystem.getResourceURI(), extension.getResourceURI()).buildAsync().execute(getBus()).getSync(1, TimeUnit.MINUTES);
assertTrue(result);
assertState(upgradeCodeSystem.getBranchPath(), extension.getBranchPath(), BranchState.FORWARD);
Boolean successComplete = CodeSystemRequests.prepareComplete(upgradeCodeSystem.getId()).buildAsync().execute(getBus()).getSync(1, TimeUnit.MINUTES);
assertTrue(successComplete);
getComponent(extension.getResourceURI(), SnomedComponentType.CONCEPT, conceptId).statusCode(200);
}
use of com.b2international.snowowl.core.ResourceURI 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);
}
use of com.b2international.snowowl.core.ResourceURI in project snow-owl by b2ihealthcare.
the class SnomedComponentEffectiveTimeRestoreTest method restoreExtensionEffectiveTimeOnExtensionVersionUpgrade.
@Test
public void restoreExtensionEffectiveTimeOnExtensionVersionUpgrade() throws Exception {
final String codeSystemId = branchPath.lastSegment();
// create extension on the base SI VERSION
final CodeSystem extension = createExtension(baseInternationalCodeSystem, codeSystemId);
// create the module concept to represent the extension
String moduleId = createModule(extension);
// create an extension version, concept receives effective time
LocalDate effectiveTime = getNextAvailableEffectiveDate(codeSystemId);
createVersion(codeSystemId, effectiveTime).statusCode(201);
ResourceURI upgradeExtVersion = CodeSystem.uri(codeSystemId, effectiveTime.toString());
SnomedConcept concept = getConcept(extension.getResourceURI(), moduleId);
assertEquals(effectiveTime, concept.getEffectiveTime());
// Update extension concept
updateConcept(extension.getResourceURI(), concept.getId(), Map.of("moduleId", Concepts.MODULE_SCT_MODEL_COMPONENT));
// Create second version
LocalDate effectiveDate2 = getNextAvailableEffectiveDate(codeSystemId);
createVersion(codeSystemId, effectiveDate2).statusCode(201);
// start the extension upgrade process
CodeSystem upgradeCodeSystem = createExtensionUpgrade(upgradeExtVersion, upgradeInternationalCodeSystem);
// create a change on the concept, like change the definition status
updateConcept(upgradeCodeSystem.getResourceURI(), concept.getId(), Map.of("definitionStatusId", Concepts.FULLY_DEFINED));
concept = getConcept(upgradeCodeSystem.getResourceURI(), moduleId);
assertEquals(null, concept.getEffectiveTime());
// revert the change, so it reverts the effective time to the 'effectiveDate' effective time
updateConcept(upgradeCodeSystem.getResourceURI(), moduleId, Map.of("definitionStatusId", Concepts.PRIMITIVE));
concept = getConcept(upgradeCodeSystem.getResourceURI(), moduleId);
assertEquals(effectiveTime, concept.getEffectiveTime());
}
use of com.b2international.snowowl.core.ResourceURI 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();
}
use of com.b2international.snowowl.core.ResourceURI in project snow-owl by b2ihealthcare.
the class SnomedExtensionUpgradeTest method upgrade13SemanticallySameChangesAppliedTwiceBeforeUpgradeAndAfterUpgrade.
@Test
public void upgrade13SemanticallySameChangesAppliedTwiceBeforeUpgradeAndAfterUpgrade() throws Exception {
// create extension on the latest SI VERSION
CodeSystem extension = createExtension(latestInternationalVersion, branchPath.lastSegment());
// create new extension version with one new concept and one member on INT concept
String moduleId = createModule(extension);
SnomedConcept concept = searchConcepts(baseInternationalCodeSystem, Map.of("module", Concepts.MODULE_SCT_CORE, "expand", "descriptions()"), 1).stream().findFirst().get();
String descriptionId = concept.getDescriptions().stream().findFirst().get().getId();
// create new inactivation indicator for one of the description, pending move
createMember(extension.getResourceURI(), Map.of("moduleId", moduleId, "refsetId", Concepts.REFSET_DESCRIPTION_INACTIVITY_INDICATOR, "referencedComponentId", descriptionId, "valueId", Concepts.PENDING_MOVE));
// version extension
createVersion(extension.getId(), "v1", LocalDate.now()).statusCode(201);
// add another member on INT representing a change in INT and allow extension to upgrade
createMember(SnomedContentRule.SNOMEDCT, Map.of("moduleId", Concepts.MODULE_SCT_CORE, "refsetId", Concepts.REFSET_DESCRIPTION_INACTIVITY_INDICATOR, "referencedComponentId", descriptionId, "valueId", Concepts.PENDING_MOVE));
LocalDate effectiveTime = getNextAvailableEffectiveDate(SNOMEDCT);
createVersion(SNOMEDCT, effectiveTime).statusCode(201);
ResourceURI upgradeVersion = CodeSystem.uri(SNOMEDCT, effectiveTime.toString());
// start the upgrade
CodeSystem upgradeCodeSystem = createExtensionUpgrade(extension.getResourceURI(), upgradeVersion);
// add another extension member to the same int concept with same meaning to the original extension branch
createMember(extension.getResourceURI(), Map.of("moduleId", moduleId, "refsetId", Concepts.REFSET_DESCRIPTION_INACTIVITY_INDICATOR, "referencedComponentId", descriptionId, "valueId", Concepts.AMBIGUOUS));
// synchronize upgrade
final String mergeLocation = createMerge(extension.getBranchPath(), upgradeCodeSystem.getBranchPath(), "Sync Upgrade CodeSystem", false).statusCode(202).extract().header("Location");
waitForMergeJob(lastPathSegment(mergeLocation));
// each component should have a single revision after successful sync
getConcept(upgradeCodeSystem.getResourceURI(), concept.getId());
}
Aggregations