use of com.b2international.snowowl.core.api.IBranchPath in project snow-owl by b2ihealthcare.
the class SnomedImportApiTest method import01InvalidBranchPath.
@Test
public void import01InvalidBranchPath() throws Exception {
final IBranchPath branchPath = BranchPathUtils.createPath("MAIN/notfound");
final Map<String, ?> importConfiguration = ImmutableMap.<String, Object>builder().put("type", Rf2ReleaseType.DELTA.name()).put("createVersions", false).build();
final String importId = lastPathSegment(doImport(branchPath, importConfiguration, getClass(), "SnomedCT_Release_INT_20150131_new_concept.zip").statusCode(201).extract().header("Location"));
waitForImportJob(branchPath, importId).statusCode(200).body("status", equalTo(RemoteJobState.FAILED.name()));
}
use of com.b2international.snowowl.core.api.IBranchPath 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.api.IBranchPath in project snow-owl by b2ihealthcare.
the class SnomedExportApiTest method exportSnapshotWithBranchRange.
@Test
public void exportSnapshotWithBranchRange() throws Exception {
final IBranchPath taskBranchPath = BranchPathUtils.createPath(branchPath, "task");
branching.createBranch(taskBranchPath).statusCode(201);
final Json exportConfig = Json.object("type", Rf2ReleaseType.SNAPSHOT.name());
export(RevisionIndex.toRevisionRange(branchPath.getPath(), taskBranchPath.getPath()), exportConfig).then().statusCode(400);
}
use of com.b2international.snowowl.core.api.IBranchPath in project snow-owl by b2ihealthcare.
the class SnomedExportApiTest method exportDeltaWithBranchRange.
@Test
public void exportDeltaWithBranchRange() throws Exception {
final String relationshipOnParent = createNewRelationship(branchPath);
final IBranchPath taskBranchPath = BranchPathUtils.createPath(branchPath, "task");
branching.createBranch(taskBranchPath).statusCode(201);
final String relationshipOnTask = createNewRelationship(taskBranchPath);
final Map<String, Object> config = Map.of("type", Rf2ReleaseType.DELTA.name(), "includeUnpublished", true);
// A "standard" delta export should include both unpublished lines
final File exportArchive = doExport(taskBranchPath, config);
final String relationshipFileName = "sct2_StatedRelationship_Delta";
final Multimap<String, Pair<Boolean, String>> fileToLinesMap = ArrayListMultimap.<String, Pair<Boolean, String>>create();
fileToLinesMap.put(relationshipFileName, Pair.of(true, createRelationshipLine(relationshipOnParent)));
fileToLinesMap.put(relationshipFileName, Pair.of(true, createRelationshipLine(relationshipOnTask)));
assertArchiveContainsLines(exportArchive, fileToLinesMap);
// Delta export with a path range can restrict the set of visible components
final IBranchPath branchRange = BranchPathUtils.createPath(branchPath.getPath() + RevisionIndex.REV_RANGE + taskBranchPath.getPath());
final File exportArchiveWithBranchRange = doExport(branchRange, config);
fileToLinesMap.clear();
fileToLinesMap.put(relationshipFileName, Pair.of(false, createRelationshipLine(relationshipOnParent)));
fileToLinesMap.put(relationshipFileName, Pair.of(true, createRelationshipLine(relationshipOnTask)));
assertArchiveContainsLines(exportArchiveWithBranchRange, fileToLinesMap);
}
use of com.b2international.snowowl.core.api.IBranchPath in project snow-owl by b2ihealthcare.
the class SnomedMergePerformanceTest method testPerf.
@Test
public void testPerf() throws Exception {
IBranchPath branch = BranchPathUtils.createPath(branchPath, "merge-test");
branching.createBranch(branch).statusCode(201);
BulkRequestBuilder<TransactionContext> bulk = BulkRequest.create();
final int numberOfConceptsToWorkWith = 10_000;
for (int i = 0; i < numberOfConceptsToWorkWith; i++) {
bulk.add(SnomedRequests.prepareNewConcept().setIdFromNamespace(null).setActive(true).setModuleId(Concepts.MODULE_SCT_CORE).addDescription(SnomedRequests.prepareNewDescription().setIdFromNamespace(null).setTerm("MergeTest FSN " + i).setTypeId(Concepts.FULLY_SPECIFIED_NAME).setLanguageCode("en").preferredIn(Concepts.REFSET_LANGUAGE_TYPE_UK)).addDescription(SnomedRequests.prepareNewDescription().setIdFromNamespace(null).setTerm("MergeTest PT " + i).setTypeId(Concepts.SYNONYM).setLanguageCode("en").preferredIn(Concepts.REFSET_LANGUAGE_TYPE_UK)).addRelationship(SnomedRequests.prepareNewRelationship().setIdFromNamespace(null).setCharacteristicTypeId(Concepts.STATED_RELATIONSHIP).setTypeId(Concepts.IS_A).setDestinationId(Concepts.ROOT_CONCEPT)));
}
Stopwatch w = Stopwatch.createStarted();
// commit large changeset
CommitResult createCommitResult = SnomedRequests.prepareCommit().setBody(bulk).setCommitComment("Commit large bulk request").build(branch.getPath()).execute(getBus()).getSync();
System.err.println("Bulk create 10_000 concepts commit took: " + w);
w.reset().start();
// extract the new IDs assigned to the concepts
Set<String> idsOfCreatedConcepts = createCommitResult.getResultAs(BulkResponse.class).stream().filter(String.class::isInstance).map(String.class::cast).collect(Collectors.toSet());
// retrieve the first 100 created concepts back, check the module
SnomedConcepts first100 = SnomedRequests.prepareSearchConcept().setLimit(100).filterByIds(idsOfCreatedConcepts).build(branch.getPath()).execute(getBus()).getSync();
assertThat(first100.getTotal()).isEqualTo(numberOfConceptsToWorkWith);
first100.forEach(concept -> {
assertThat(concept.getModuleId()).isEqualTo(Concepts.MODULE_SCT_CORE);
});
// check that SNOMED CT ROOT has 10_000
int totalDescendants = SnomedRequests.prepareSearchConcept().setLimit(0).filterByStatedParent(Concepts.ROOT_CONCEPT).build(branch.getPath()).execute(getBus()).getSync().getTotal();
assertThat(totalDescendants).isGreaterThanOrEqualTo(numberOfConceptsToWorkWith);
// find the relationship IDs of the concepts
final Set<String> conceptRelationshipIds = SnomedRequests.prepareSearchRelationship().all().filterByActive(true).filterBySources(idsOfCreatedConcepts).filterByDestination(Concepts.ROOT_CONCEPT).setFields(SnomedRelationshipIndexEntry.Fields.ID).build(branch.getPath()).execute(getBus()).getSync().stream().map(SnomedRelationship::getId).collect(Collectors.toSet());
System.err.println("Verify creation of 10_000 concepts took: " + w);
w.reset().start();
// prepare module bulk update
bulk = BulkRequest.create();
for (String conceptIdToUpdate : idsOfCreatedConcepts) {
bulk.add(SnomedRequests.prepareUpdateConcept(conceptIdToUpdate).setModuleId(Concepts.MODULE_SCT_MODEL_COMPONENT));
}
// commit module bulk update
SnomedRequests.prepareCommit().setBody(bulk).setCommitComment("Commit update bulk request").build(branch.getPath()).execute(getBus()).getSync();
System.err.println("Bulk update 10_000 concepts commit took: " + w);
w.reset().start();
// prepare move concepts in hierarchy to clinical finding update
bulk = BulkRequest.create();
// inactivate all current relationships
for (String relationshipIdToInactive : conceptRelationshipIds) {
bulk.add(SnomedRequests.prepareUpdateRelationship(relationshipIdToInactive).setActive(false));
}
// add new relationships to concepts
for (String conceptIdToUpdate : idsOfCreatedConcepts) {
bulk.add(SnomedRequests.prepareNewRelationship().setIdFromNamespace(null).setSourceId(conceptIdToUpdate).setTypeId(Concepts.IS_A).setDestinationId("404684003").setModuleId(Concepts.MODULE_SCT_MODEL_COMPONENT));
}
// commit move concepts in hierarchy to clinical finding update
SnomedRequests.prepareCommit().setBody(bulk).setCommitComment("Commit update bulk request").build(branch.getPath()).execute(getBus()).getSync();
System.err.println("Bulk move 10_000 concepts to Clinical Finding took: " + w);
w.reset().start();
SnomedRestFixtures.merge(branch, branchPath, "Promote changes from task...").body("status", CoreMatchers.equalTo(Merge.Status.COMPLETED.name()));
System.err.println("Merge took: " + w);
}
Aggregations