use of com.b2international.commons.Pair in project snow-owl by b2ihealthcare.
the class SnomedExportApiTest method exportPublishedAndUnpublishedTextDef.
@Test
public void exportPublishedAndUnpublishedTextDef() throws Exception {
final String codeSystemShortName = "SNOMEDCT-PUB-UNPUB-TEXTDEF";
createCodeSystem(branchPath, codeSystemShortName).statusCode(201);
// create new concept
final String conceptId = createNewConcept(branchPath, ROOT_CONCEPT);
// create new text definition
final String textDefinitionId = createNewDescription(branchPath, conceptId, Concepts.TEXT_DEFINITION, UK_ACCEPTABLE_MAP);
// version new concept
final String versionEffectiveTime = "20170301";
createVersion(codeSystemShortName, "v1", EffectiveTimes.parse(versionEffectiveTime, DateFormats.SHORT)).statusCode(201);
// create new text definition
final String unpublishedTextDefinitionId = createNewDescription(branchPath, conceptId, Concepts.TEXT_DEFINITION, UK_ACCEPTABLE_MAP);
// do not create new version
final Map<String, Object> config = ImmutableMap.<String, Object>builder().put("type", Rf2ReleaseType.DELTA.name()).put("startEffectiveTime", versionEffectiveTime).put("endEffectiveTime", versionEffectiveTime).put("includeUnpublished", true).build();
final File exportArchive = doExport(branchPath, config);
String textDefinitionLine = getComponentLine(List.<String>of(textDefinitionId, versionEffectiveTime, "1", MODULE_SCT_CORE, conceptId, "en", Concepts.TEXT_DEFINITION, "Description term", Concepts.ONLY_INITIAL_CHARACTER_CASE_INSENSITIVE));
String unpublishedTextDefinitionLine = getComponentLine(List.<String>of(unpublishedTextDefinitionId, "", "1", MODULE_SCT_CORE, conceptId, "en", Concepts.TEXT_DEFINITION, "Description term", Concepts.ONLY_INITIAL_CHARACTER_CASE_INSENSITIVE));
final Multimap<String, Pair<Boolean, String>> fileToLinesMap = ArrayListMultimap.<String, Pair<Boolean, String>>create();
fileToLinesMap.put("sct2_Description", Pair.of(false, textDefinitionLine));
fileToLinesMap.put("sct2_Description", Pair.of(false, unpublishedTextDefinitionLine));
fileToLinesMap.put("sct2_TextDefinition", Pair.of(true, textDefinitionLine));
fileToLinesMap.put("sct2_TextDefinition", Pair.of(true, unpublishedTextDefinitionLine));
assertArchiveContainsLines(exportArchive, fileToLinesMap);
}
use of com.b2international.commons.Pair in project snow-owl by b2ihealthcare.
the class SnomedExportApiTest method exportLangRefset_acceptabilityChangesOnly.
@Test
public void exportLangRefset_acceptabilityChangesOnly() throws Exception {
final String codeSystemShortName = "SNOMEDCT-EXPORT-UNPUBLISHED-LANG-REFSET-MEMBERS";
createCodeSystem(branchPath, codeSystemShortName).statusCode(201);
// create new concept
final String conceptId = createNewConcept(branchPath);
Map<String, Acceptability> acceptabilityMap = ImmutableMap.<String, Acceptability>builder().put(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED).put(Concepts.REFSET_LANGUAGE_TYPE_US, Acceptability.ACCEPTABLE).build();
final String descriptionId = createNewDescription(branchPath, conceptId, Concepts.SYNONYM, acceptabilityMap, "en");
// version new concept
final String versionEffectiveTime = "20170801";
createVersion(codeSystemShortName, "v1", EffectiveTimes.parse(versionEffectiveTime, DateFormats.SHORT)).statusCode(201);
SnomedReferenceSetMembers versionedMembers = getComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId, "members()").statusCode(200).extract().as(SnomedDescription.class).getMembers();
assertEquals(2, versionedMembers.getTotal());
versionedMembers.forEach(m -> assertEquals(EffectiveTimes.parse(versionEffectiveTime, DateFormats.SHORT), m.getEffectiveTime()));
Map<String, Acceptability> updatedAcceptabilityMap = ImmutableMap.<String, Acceptability>builder().put(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.ACCEPTABLE).put(Concepts.REFSET_LANGUAGE_TYPE_US, Acceptability.PREFERRED).build();
Map<?, ?> requestBody = ImmutableMap.builder().put("acceptability", updatedAcceptabilityMap).put("commitComment", "Updated description acceptability").build();
updateComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId, requestBody).statusCode(204);
SnomedReferenceSetMembers unpublishedMembers = getComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId, "members()").statusCode(200).extract().as(SnomedDescription.class).getMembers();
assertEquals(2, unpublishedMembers.getTotal());
unpublishedMembers.forEach(m -> assertNull(m.getEffectiveTime()));
// do not create new version
final Map<String, Object> config = ImmutableMap.<String, Object>builder().put("type", Rf2ReleaseType.DELTA.name()).put("includeUnpublished", true).build();
final File exportArchive = doExport(branchPath, config);
String englishDescriptionLine = createDescriptionLine(descriptionId, versionEffectiveTime, conceptId, "en", Concepts.SYNONYM, DEFAULT_TERM);
String ukMember = createLanguageRefsetMemberLine(branchPath, descriptionId, "", Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.ACCEPTABLE.getConceptId());
String usMember = createLanguageRefsetMemberLine(branchPath, descriptionId, "", Concepts.REFSET_LANGUAGE_TYPE_US, Acceptability.PREFERRED.getConceptId());
final Multimap<String, Pair<Boolean, String>> fileToLinesMap = ArrayListMultimap.<String, Pair<Boolean, String>>create();
fileToLinesMap.put("sct2_Description_Delta-en", Pair.of(false, englishDescriptionLine));
fileToLinesMap.put("der2_cRefset_LanguageDelta-en", Pair.of(true, ukMember));
fileToLinesMap.put("der2_cRefset_LanguageDelta-en", Pair.of(true, usMember));
assertArchiveContainsLines(exportArchive, fileToLinesMap);
}
use of com.b2international.commons.Pair in project snow-owl by b2ihealthcare.
the class SnomedExportApiTest method exportLangRefset_acceptabilityAndDescChanges.
@Test
public void exportLangRefset_acceptabilityAndDescChanges() throws Exception {
final String codeSystemShortName = "SNOMEDCT-ACCEPTABILITY-CHANGES";
createCodeSystem(branchPath, codeSystemShortName).statusCode(201);
// create new concept
final String conceptId = createNewConcept(branchPath);
final String descriptionIdA = createNewDescription(branchPath, conceptId, Concepts.SYNONYM, UK_ACCEPTABLE_MAP, "en");
final String descriptionIdB = createNewDescription(branchPath, conceptId, Concepts.SYNONYM, UK_ACCEPTABLE_MAP, "da");
final String descriptionIdC = createNewDescription(branchPath, conceptId, Concepts.SYNONYM, UK_ACCEPTABLE_MAP, "en");
final String descriptionIdD = createNewDescription(branchPath, conceptId, Concepts.SYNONYM, UK_ACCEPTABLE_MAP, "da");
final String descriptionIdE = createNewDescription(branchPath, conceptId, Concepts.SYNONYM, UK_PREFERRED_MAP, "en");
final String descriptionIdF = createNewDescription(branchPath, conceptId, Concepts.SYNONYM, UK_PREFERRED_MAP, "da");
// version new concept
final String versionEffectiveTime = "20170801";
createVersion(codeSystemShortName, "v1", EffectiveTimes.parse(versionEffectiveTime, DateFormats.SHORT)).statusCode(201);
Map<?, ?> caseSignificanceChangeRequestBody = ImmutableMap.builder().put("caseSignificance", Concepts.ENTIRE_TERM_CASE_SENSITIVE).put("commitComment", "Updated description case significance").build();
Map<?, ?> acceptabilityChangeRequestBody = ImmutableMap.builder().put("acceptability", UK_PREFERRED_MAP).put("commitComment", "Updated description acceptability").build();
// Update description A
updateComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionIdA, caseSignificanceChangeRequestBody).statusCode(204);
// Update language refset member of description A
updateComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionIdA, acceptabilityChangeRequestBody).statusCode(204);
// Update description B
updateComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionIdB, caseSignificanceChangeRequestBody).statusCode(204);
// Update language refset member of description B
updateComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionIdB, acceptabilityChangeRequestBody).statusCode(204);
// Update language refset member of description C
updateComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionIdC, acceptabilityChangeRequestBody).statusCode(204);
// Update language refset member of description D
updateComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionIdD, acceptabilityChangeRequestBody).statusCode(204);
// Update description E
updateComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionIdE, caseSignificanceChangeRequestBody).statusCode(204);
// Update description F
updateComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionIdF, caseSignificanceChangeRequestBody).statusCode(204);
// export delta rf2
final Map<String, Object> config = ImmutableMap.<String, Object>builder().put("type", Rf2ReleaseType.DELTA.name()).put("startEffectiveTime", versionEffectiveTime).put("endEffectiveTime", versionEffectiveTime).put("includeUnpublished", true).build();
final File exportArchive = doExport(branchPath, config);
String descriptionLineA = createDescriptionLine(descriptionIdA, "", conceptId, "en", Concepts.SYNONYM, DEFAULT_TERM, Concepts.ENTIRE_TERM_CASE_SENSITIVE);
String descriptionLineB = createDescriptionLine(descriptionIdB, "", conceptId, "da", Concepts.SYNONYM, DEFAULT_TERM, Concepts.ENTIRE_TERM_CASE_SENSITIVE);
String descriptionLineC = createDescriptionLine(descriptionIdC, versionEffectiveTime, conceptId, "en", Concepts.SYNONYM, DEFAULT_TERM);
String descriptionLineD = createDescriptionLine(descriptionIdD, versionEffectiveTime, conceptId, "da", Concepts.SYNONYM, DEFAULT_TERM);
String descriptionLineE = createDescriptionLine(descriptionIdE, "", conceptId, "en", Concepts.SYNONYM, DEFAULT_TERM, Concepts.ENTIRE_TERM_CASE_SENSITIVE);
String descriptionLineF = createDescriptionLine(descriptionIdF, "", conceptId, "da", Concepts.SYNONYM, DEFAULT_TERM, Concepts.ENTIRE_TERM_CASE_SENSITIVE);
String languageMemberLineA = createLanguageRefsetMemberLine(branchPath, descriptionIdA, "", Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED.getConceptId());
String languageMemberLineB = createLanguageRefsetMemberLine(branchPath, descriptionIdB, "", Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED.getConceptId());
String languageMemberLineC = createLanguageRefsetMemberLine(branchPath, descriptionIdC, "", Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED.getConceptId());
String languageMemberLineD = createLanguageRefsetMemberLine(branchPath, descriptionIdD, "", Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED.getConceptId());
String languageMemberLineE = createLanguageRefsetMemberLine(branchPath, descriptionIdE, versionEffectiveTime, Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED.getConceptId());
String languageMemberLineF = createLanguageRefsetMemberLine(branchPath, descriptionIdF, versionEffectiveTime, Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED.getConceptId());
final Multimap<String, Pair<Boolean, String>> fileToLinesMap = ArrayListMultimap.create();
fileToLinesMap.put("sct2_Description_Delta-en", Pair.of(true, descriptionLineA));
fileToLinesMap.put("sct2_Description_Delta-en", Pair.of(true, descriptionLineE));
fileToLinesMap.put("sct2_Description_Delta-en", Pair.of(true, descriptionLineC));
fileToLinesMap.put("sct2_Description_Delta-da", Pair.of(true, descriptionLineB));
fileToLinesMap.put("sct2_Description_Delta-da", Pair.of(true, descriptionLineF));
fileToLinesMap.put("sct2_Description_Delta-da", Pair.of(true, descriptionLineD));
fileToLinesMap.put("der2_cRefset_LanguageDelta-en", Pair.of(true, languageMemberLineA));
fileToLinesMap.put("der2_cRefset_LanguageDelta-en", Pair.of(true, languageMemberLineC));
fileToLinesMap.put("der2_cRefset_LanguageDelta-en", Pair.of(true, languageMemberLineE));
fileToLinesMap.put("der2_cRefset_LanguageDelta-da", Pair.of(true, languageMemberLineB));
fileToLinesMap.put("der2_cRefset_LanguageDelta-da", Pair.of(true, languageMemberLineD));
fileToLinesMap.put("der2_cRefset_LanguageDelta-da", Pair.of(true, languageMemberLineF));
assertArchiveContainsLines(exportArchive, fileToLinesMap);
}
use of com.b2international.commons.Pair in project snow-owl by b2ihealthcare.
the class SnomedExportApiTest method exportSnapshotWithBranchPoint.
@Test
public void exportSnapshotWithBranchPoint() throws Exception {
final String codeSystemId = "SNOMEDCT-snapshot-with-branch-at";
createCodeSystem(branchPath, codeSystemId).statusCode(201);
final CommitResult commitResult = SnomedRequests.prepareCommit().setBody(SnomedRequests.prepareNewRelationship().setId(new NamespaceIdStrategy("")).setActive(true).setCharacteristicTypeId(Concepts.INFERRED_RELATIONSHIP).setDestinationId(Concepts.ROOT_CONCEPT).setModifierId(Concepts.EXISTENTIAL_RESTRICTION_MODIFIER).setModuleId(Concepts.MODULE_SCT_CORE).setRelationshipGroup(0).setSourceId(Concepts.ACCEPTABILITY).setTypeId(Concepts.IS_A).setUnionGroup(0)).setCommitComment("Created new relationship").setAuthor(RestExtensions.USER).build(ResourceURI.of(CodeSystem.RESOURCE_TYPE, codeSystemId)).execute(getBus()).getSync(1L, TimeUnit.MINUTES);
final long timestamp = commitResult.getCommitTimestamp() - 1L;
final String relationshipId = commitResult.getResultAs(String.class);
// id, effectiveTime, active, moduleId, sourceId, destinationId, relationshipGroup, typeId, characteristicTypeId, modifierId
final String relationshipLine = getComponentLine(List.of(relationshipId, "", "1", Concepts.MODULE_SCT_CORE, Concepts.ACCEPTABILITY, Concepts.ROOT_CONCEPT, "0", Concepts.IS_A, Concepts.INFERRED_RELATIONSHIP, Concepts.EXISTENTIAL_RESTRICTION_MODIFIER));
final Map<String, Object> config = Map.of("type", Rf2ReleaseType.SNAPSHOT.name(), "includeUnpublished", true);
final File exportArchive = doExport(codeSystemId, config);
final String relationshipFileName = "sct2_Relationship_Snapshot";
final Multimap<String, Pair<Boolean, String>> fileToLinesMap = ArrayListMultimap.<String, Pair<Boolean, String>>create();
fileToLinesMap.put(relationshipFileName, Pair.of(true, relationshipLine));
assertArchiveContainsLines(exportArchive, fileToLinesMap);
/*
* A snapshot export with a timestamp set before creating the relationship should result in the relationship
* not appearing in the export file.
*/
final File exportArchiveWithTimestamp = doExport(codeSystemId + "@" + timestamp, config);
fileToLinesMap.clear();
fileToLinesMap.put(relationshipFileName, Pair.of(false, relationshipLine));
assertArchiveContainsLines(exportArchiveWithTimestamp, fileToLinesMap);
}
use of com.b2international.commons.Pair 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);
}
Aggregations