Search in sources :

Example 1 with Pair

use of com.b2international.commons.Pair in project snow-owl by b2ihealthcare.

the class SnomedExportApiTest method exportConceptsAndRelationshipsOnly.

// until external classification service support is ready
@Ignore
@Test
public void exportConceptsAndRelationshipsOnly() throws Exception {
    final String codeSystemShortName = "SNOMEDCT-CONCEPTS-AND-RELATIONSHIPS-ONLY";
    createCodeSystem(branchPath, codeSystemShortName).statusCode(201);
    // create new concept
    final String conceptId = createNewConcept(branchPath);
    createNewDescription(branchPath, conceptId, Concepts.SYNONYM, UK_ACCEPTABLE_MAP, "en");
    String statedRelationshipId = createNewRelationship(branchPath, Concepts.ROOT_CONCEPT, Concepts.PART_OF, Concepts.NAMESPACE_ROOT, Concepts.STATED_RELATIONSHIP);
    String inferredRelationshipId = createNewRelationship(branchPath, Concepts.ROOT_CONCEPT, Concepts.PART_OF, Concepts.NAMESPACE_ROOT, Concepts.INFERRED_RELATIONSHIP);
    String additionalRelationshipId = createNewRelationship(branchPath, Concepts.ROOT_CONCEPT, Concepts.PART_OF, Concepts.NAMESPACE_ROOT, Concepts.ADDITIONAL_RELATIONSHIP);
    createNewRefSet(branchPath, SnomedRefSetType.OWL_AXIOM, Concepts.REFSET_OWL_AXIOM);
    String owlExpression = "";
    Json memberRequestBody = createRefSetMemberRequestBody(Concepts.REFSET_OWL_AXIOM, Concepts.ROOT_CONCEPT).with("owlExpression", owlExpression).with("commitComment", "Created new OWL axiom reference set member");
    String memberId = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, memberRequestBody));
    // export delta rf2
    final Map<String, Object> config = ImmutableMap.<String, Object>builder().put("type", Rf2ReleaseType.DELTA.name()).put("conceptsAndRelationshipsOnly", true).put("includeUnpublished", true).build();
    final File exportArchive = doExport(branchPath, config);
    String conceptLine = TAB_JOINER.join(conceptId, "", "1", Concepts.MODULE_SCT_CORE, Concepts.PRIMITIVE);
    String statedLine = TAB_JOINER.join(statedRelationshipId, "", "1", Concepts.MODULE_SCT_CORE, Concepts.ROOT_CONCEPT, Concepts.NAMESPACE_ROOT, "0", Concepts.PART_OF, Concepts.STATED_RELATIONSHIP, Concepts.EXISTENTIAL_RESTRICTION_MODIFIER);
    String inferredLine = TAB_JOINER.join(inferredRelationshipId, "", "1", Concepts.MODULE_SCT_CORE, Concepts.ROOT_CONCEPT, Concepts.NAMESPACE_ROOT, "0", Concepts.PART_OF, Concepts.INFERRED_RELATIONSHIP, Concepts.EXISTENTIAL_RESTRICTION_MODIFIER);
    String additionalLine = TAB_JOINER.join(additionalRelationshipId, "", "1", Concepts.MODULE_SCT_CORE, Concepts.ROOT_CONCEPT, Concepts.NAMESPACE_ROOT, "0", Concepts.PART_OF, Concepts.ADDITIONAL_RELATIONSHIP, Concepts.EXISTENTIAL_RESTRICTION_MODIFIER);
    String owlMemberLine = TAB_JOINER.join(memberId, "", "1", Concepts.MODULE_SCT_CORE, Concepts.REFSET_OWL_AXIOM, Concepts.ROOT_CONCEPT, owlExpression);
    final Map<String, Boolean> files = ImmutableMap.<String, Boolean>builder().put("sct2_Concept", true).put("sct2_StatedRelationship", true).put("sct2_Relationship", true).put("sct2_Description", false).put("sct2_TextDefinition", false).put("der2_cRefset_LanguageDelta", false).put("der2_ssRefset_ModuleDependency", false).put("sct2_sRefset_OWLExpression", true).build();
    assertArchiveContainsFiles(exportArchive, files);
    final Multimap<String, Pair<Boolean, String>> fileToLinesMap = ArrayListMultimap.create();
    fileToLinesMap.put("sct2_Concept", Pair.of(true, conceptLine));
    fileToLinesMap.put("sct2_StatedRelationship", Pair.of(true, statedLine));
    fileToLinesMap.put("sct2_Relationship", Pair.of(true, inferredLine));
    fileToLinesMap.put("sct2_Relationship", Pair.of(false, additionalLine));
    fileToLinesMap.put("sct2_sRefset_OWLExpression", Pair.of(true, owlMemberLine));
    assertArchiveContainsLines(exportArchive, fileToLinesMap);
}
Also used : Json(com.b2international.commons.json.Json) File(java.io.File) Pair(com.b2international.commons.Pair) Ignore(org.junit.Ignore) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest) Test(org.junit.Test)

Example 2 with Pair

use of com.b2international.commons.Pair in project snow-owl by b2ihealthcare.

the class SnomedExportApiTest method exportUnpublishedOWLExpressionRefsetMembers.

@Test
public void exportUnpublishedOWLExpressionRefsetMembers() throws Exception {
    Json owlOntologyRequestBody = createRefSetMemberRequestBody(Concepts.REFSET_OWL_ONTOLOGY, Concepts.ROOT_CONCEPT).with(SnomedRf2Headers.FIELD_OWL_EXPRESSION, SnomedApiTestConstants.OWL_ONTOLOGY_1).with("commitComment", "Created new OWL Ontology reference set member");
    String owlOntologyRefsetMemberId = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, owlOntologyRequestBody));
    Json owlAxiomRequestBody = createRefSetMemberRequestBody(Concepts.REFSET_OWL_AXIOM, Concepts.ROOT_CONCEPT).with(SnomedRf2Headers.FIELD_OWL_EXPRESSION, SnomedApiTestConstants.owlAxiom1(Concepts.ROOT_CONCEPT)).with("commitComment", "Created new OWL Axiom reference set member");
    String owlAxiomRefsetMemberId = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, owlAxiomRequestBody));
    File exportArchive = doExport(branchPath, Json.object("type", Rf2ReleaseType.DELTA.name()));
    String owlOntologyMemberLine = TAB_JOINER.join(owlOntologyRefsetMemberId, "", "1", Concepts.MODULE_SCT_CORE, Concepts.REFSET_OWL_ONTOLOGY, Concepts.ROOT_CONCEPT, SnomedApiTestConstants.OWL_ONTOLOGY_1);
    String owlAxiomMemberLine = TAB_JOINER.join(owlAxiomRefsetMemberId, "", "1", Concepts.MODULE_SCT_CORE, Concepts.REFSET_OWL_AXIOM, Concepts.ROOT_CONCEPT, SnomedApiTestConstants.owlAxiom1(Concepts.ROOT_CONCEPT));
    String expectedOwlExpressionDeltaFile = "sct2_sRefset_OWLExpressionDelta";
    final Map<String, Boolean> files = ImmutableMap.<String, Boolean>builder().put(expectedOwlExpressionDeltaFile, true).build();
    assertArchiveContainsFiles(exportArchive, files);
    Multimap<String, Pair<Boolean, String>> fileToLinesMap = ArrayListMultimap.<String, Pair<Boolean, String>>create();
    fileToLinesMap.put(expectedOwlExpressionDeltaFile, Pair.of(true, owlOntologyMemberLine));
    fileToLinesMap.put(expectedOwlExpressionDeltaFile, Pair.of(true, owlAxiomMemberLine));
    assertArchiveContainsLines(exportArchive, fileToLinesMap);
}
Also used : Json(com.b2international.commons.json.Json) File(java.io.File) Pair(com.b2international.commons.Pair) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest) Test(org.junit.Test)

Example 3 with Pair

use of com.b2international.commons.Pair in project snow-owl by b2ihealthcare.

the class SnomedExportApiTest method exportUnpublishedMRCMReferenceSetMembers.

@Test
public void exportUnpublishedMRCMReferenceSetMembers() throws Exception {
    Json mrcmDomainRequestBody = createRefSetMemberRequestBody(Concepts.REFSET_MRCM_DOMAIN_INTERNATIONAL, Concepts.ROOT_CONCEPT).with(Json.object(SnomedRf2Headers.FIELD_MRCM_DOMAIN_CONSTRAINT, "domainConstraint", SnomedRf2Headers.FIELD_MRCM_PARENT_DOMAIN, "parentDomain", SnomedRf2Headers.FIELD_MRCM_PROXIMAL_PRIMITIVE_CONSTRAINT, "proximalPrimitiveConstraint", SnomedRf2Headers.FIELD_MRCM_PROXIMAL_PRIMITIVE_REFINEMENT, "proximalPrimitiveRefinement", SnomedRf2Headers.FIELD_MRCM_DOMAIN_TEMPLATE_FOR_PRECOORDINATION, "domainTemplateForPrecoordination", SnomedRf2Headers.FIELD_MRCM_DOMAIN_TEMPLATE_FOR_POSTCOORDINATION, "domainTemplateForPostcoordination", SnomedRf2Headers.FIELD_MRCM_GUIDEURL, "guideURL", "commitComment", "Created new MRCM domain reference set member"));
    String mrcmDomainRefsetMemberId = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, mrcmDomainRequestBody));
    Map<?, ?> mrcmAttributeDomainRequestBody = createRefSetMemberRequestBody(Concepts.REFSET_MRCM_ATTRIBUTE_DOMAIN_INTERNATIONAL, Concepts.ROOT_CONCEPT).with(Json.object(SnomedRf2Headers.FIELD_MRCM_DOMAIN_ID, Concepts.ROOT_CONCEPT, SnomedRf2Headers.FIELD_MRCM_GROUPED, Boolean.TRUE, SnomedRf2Headers.FIELD_MRCM_ATTRIBUTE_CARDINALITY, "attributeCardinality", SnomedRf2Headers.FIELD_MRCM_ATTRIBUTE_IN_GROUP_CARDINALITY, "attributeInGroupCardinality", SnomedRf2Headers.FIELD_MRCM_RULE_STRENGTH_ID, Concepts.ROOT_CONCEPT, SnomedRf2Headers.FIELD_MRCM_CONTENT_TYPE_ID, Concepts.ROOT_CONCEPT, "commitComment", "Created new MRCM attribute domain reference set member"));
    String mrcmAttributeDomainRefsetMemberId = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, mrcmAttributeDomainRequestBody));
    Map<?, ?> mrcmAttributeRangeRequestBody = createRefSetMemberRequestBody(Concepts.REFSET_MRCM_ATTRIBUTE_RANGE_INTERNATIONAL, Concepts.ROOT_CONCEPT).with(Json.object(SnomedRf2Headers.FIELD_MRCM_RANGE_CONSTRAINT, "rangeConstraint", SnomedRf2Headers.FIELD_MRCM_ATTRIBUTE_RULE, "attributeRule", SnomedRf2Headers.FIELD_MRCM_RULE_STRENGTH_ID, Concepts.ROOT_CONCEPT, SnomedRf2Headers.FIELD_MRCM_CONTENT_TYPE_ID, Concepts.ROOT_CONCEPT, "commitComment", "Created new MRCM attribute range reference set member"));
    String mrcmAttributeRangeRefsetMemberId = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, mrcmAttributeRangeRequestBody));
    Json mrcmModuleScopeRequestBody = createRefSetMemberRequestBody(Concepts.REFSET_MRCM_MODULE_SCOPE, Concepts.ROOT_CONCEPT).with(SnomedRf2Headers.FIELD_MRCM_RULE_REFSET_ID, Concepts.ROOT_CONCEPT).with("commitComment", "Created new MRCM module scope reference set member");
    String mrcmModuleScopeRefsetMemberId = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, mrcmModuleScopeRequestBody));
    Json config = Json.object("type", Rf2ReleaseType.DELTA.name());
    File exportArchive = doExport(branchPath, config);
    String mrcmDomainMemberLine = TAB_JOINER.join(mrcmDomainRefsetMemberId, "", "1", Concepts.MODULE_SCT_CORE, Concepts.REFSET_MRCM_DOMAIN_INTERNATIONAL, Concepts.ROOT_CONCEPT, "domainConstraint", "parentDomain", "proximalPrimitiveConstraint", "proximalPrimitiveRefinement", "domainTemplateForPrecoordination", "domainTemplateForPostcoordination", "guideURL");
    String mrcmAttributeDomainLine = TAB_JOINER.join(mrcmAttributeDomainRefsetMemberId, "", "1", Concepts.MODULE_SCT_CORE, Concepts.REFSET_MRCM_ATTRIBUTE_DOMAIN_INTERNATIONAL, Concepts.ROOT_CONCEPT, Concepts.ROOT_CONCEPT, "1", "attributeCardinality", "attributeInGroupCardinality", Concepts.ROOT_CONCEPT, Concepts.ROOT_CONCEPT);
    String mrcmAttributeRangeLine = TAB_JOINER.join(mrcmAttributeRangeRefsetMemberId, "", "1", Concepts.MODULE_SCT_CORE, Concepts.REFSET_MRCM_ATTRIBUTE_RANGE_INTERNATIONAL, Concepts.ROOT_CONCEPT, "rangeConstraint", "attributeRule", Concepts.ROOT_CONCEPT, Concepts.ROOT_CONCEPT);
    String mrcmModuleScopeLine = TAB_JOINER.join(mrcmModuleScopeRefsetMemberId, "", "1", Concepts.MODULE_SCT_CORE, Concepts.REFSET_MRCM_MODULE_SCOPE, Concepts.ROOT_CONCEPT, Concepts.ROOT_CONCEPT);
    final Map<String, Boolean> files = ImmutableMap.<String, Boolean>builder().put("der2_sssssssRefset_MRCMDomainDelta", true).put("der2_cissccRefset_MRCMAttributeDomainDelta", true).put("der2_ssccRefset_MRCMAttributeRangeDelta", true).put("der2_cRefset_MRCMModuleScopeDelta", true).build();
    assertArchiveContainsFiles(exportArchive, files);
    Multimap<String, Pair<Boolean, String>> fileToLinesMap = ArrayListMultimap.<String, Pair<Boolean, String>>create();
    fileToLinesMap.put("der2_sssssssRefset_MRCMDomainDelta", Pair.of(true, mrcmDomainMemberLine));
    fileToLinesMap.put("der2_cissccRefset_MRCMAttributeDomainDelta", Pair.of(true, mrcmAttributeDomainLine));
    fileToLinesMap.put("der2_ssccRefset_MRCMAttributeRangeDelta", Pair.of(true, mrcmAttributeRangeLine));
    fileToLinesMap.put("der2_cRefset_MRCMModuleScopeDelta", Pair.of(true, mrcmModuleScopeLine));
    assertArchiveContainsLines(exportArchive, fileToLinesMap);
}
Also used : Json(com.b2international.commons.json.Json) File(java.io.File) Pair(com.b2international.commons.Pair) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest) Test(org.junit.Test)

Example 4 with Pair

use of com.b2international.commons.Pair in project snow-owl by b2ihealthcare.

the class SnomedExportApiTest method exportContentFromVersionFixerTaskTransEffTime.

@Test
public void exportContentFromVersionFixerTaskTransEffTime() throws Exception {
    String codeSystemShortName = "SNOMEDCT-FIXERTASK-TRANSIENT";
    createCodeSystem(branchPath, codeSystemShortName).statusCode(201);
    // create a refset, a concept, and reference the concept from the refset
    final String createdRefSetId = createNewRefSet(branchPath, SnomedRefSetType.SIMPLE);
    final String createdConceptId = createNewConcept(branchPath, ROOT_CONCEPT);
    final String memberId = createNewRefSetMember(branchPath, createdConceptId, createdRefSetId);
    final String versionEffectiveTime = "20170301";
    createVersion(codeSystemShortName, "v1", EffectiveTimes.parse(versionEffectiveTime, DateFormats.SHORT)).statusCode(201);
    IBranchPath versionPath = BranchPathUtils.createPath(branchPath, "v1");
    IBranchPath taskBranch = BranchPathUtils.createPath(versionPath, "Fix01");
    // create fixer branch for version branch
    branching.createBranch(taskBranch).statusCode(201);
    // change an existing component
    Map<?, ?> updateRequest = ImmutableMap.builder().put("active", false).put("commitComment", "Inactivated reference set member").build();
    updateRefSetComponent(taskBranch, SnomedComponentType.MEMBER, memberId, updateRequest, false).statusCode(204);
    getComponent(taskBranch, SnomedComponentType.MEMBER, memberId).statusCode(200).body("active", equalTo(false)).body("effectiveTime", equalTo(null)).body("released", equalTo(true));
    // add a new component
    String newMemberId = createNewRefSetMember(taskBranch, createdConceptId, createdRefSetId);
    final Map<String, Object> config = ImmutableMap.<String, Object>builder().put("type", Rf2ReleaseType.SNAPSHOT.name()).put("startEffectiveTime", versionEffectiveTime).put("transientEffectiveTime", versionEffectiveTime).put("includeUnpublished", true).build();
    final File exportArchive = doExport(taskBranch, config);
    String refsetMemberLine = getComponentLine(List.<String>of(memberId, versionEffectiveTime, "0", MODULE_SCT_CORE, createdRefSetId, createdConceptId));
    String invalidRefsetMemberLine = getComponentLine(List.<String>of(memberId, versionEffectiveTime, "1", MODULE_SCT_CORE, createdRefSetId, createdConceptId));
    String newRefsetMemberLine = getComponentLine(List.<String>of(newMemberId, versionEffectiveTime, "1", MODULE_SCT_CORE, createdRefSetId, createdConceptId));
    final Multimap<String, Pair<Boolean, String>> fileToLinesMap = ArrayListMultimap.<String, Pair<Boolean, String>>create();
    String refsetFileName = "der2_Refset_SimpleSnapshot";
    fileToLinesMap.put(refsetFileName, Pair.of(true, refsetMemberLine));
    fileToLinesMap.put(refsetFileName, Pair.of(true, newRefsetMemberLine));
    fileToLinesMap.put(refsetFileName, Pair.of(false, invalidRefsetMemberLine));
    assertArchiveContainsLines(exportArchive, fileToLinesMap);
}
Also used : File(java.io.File) IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Pair(com.b2international.commons.Pair) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest) Test(org.junit.Test)

Example 5 with Pair

use of com.b2international.commons.Pair in project snow-owl by b2ihealthcare.

the class SnomedExportApiTest method exportUnpublishedDeltaRelationships.

@Test
public void exportUnpublishedDeltaRelationships() throws Exception {
    String statedRelationshipId = createNewRelationship(branchPath, Concepts.ROOT_CONCEPT, Concepts.PART_OF, Concepts.NAMESPACE_ROOT, Concepts.STATED_RELATIONSHIP);
    String inferredRelationshipId = createNewRelationship(branchPath, Concepts.ROOT_CONCEPT, Concepts.PART_OF, Concepts.NAMESPACE_ROOT, Concepts.INFERRED_RELATIONSHIP);
    String additionalRelationshipId = createNewRelationship(branchPath, Concepts.ROOT_CONCEPT, Concepts.PART_OF, Concepts.NAMESPACE_ROOT, Concepts.ADDITIONAL_RELATIONSHIP);
    String valueRelationshipId = createNewConcreteValue(branchPath, Concepts.ROOT_CONCEPT, Concepts.PART_OF, new RelationshipValue(99));
    String transientEffectiveTime = "20170301";
    Map<String, ?> config = ImmutableMap.<String, Object>builder().put("type", Rf2ReleaseType.DELTA.name()).put("transientEffectiveTime", transientEffectiveTime).build();
    File exportArchive = doExport(branchPath, config);
    String statedLine = TAB_JOINER.join(statedRelationshipId, transientEffectiveTime, "1", Concepts.MODULE_SCT_CORE, Concepts.ROOT_CONCEPT, Concepts.NAMESPACE_ROOT, "0", Concepts.PART_OF, Concepts.STATED_RELATIONSHIP, Concepts.EXISTENTIAL_RESTRICTION_MODIFIER);
    String inferredLine = TAB_JOINER.join(inferredRelationshipId, transientEffectiveTime, "1", Concepts.MODULE_SCT_CORE, Concepts.ROOT_CONCEPT, Concepts.NAMESPACE_ROOT, "0", Concepts.PART_OF, Concepts.INFERRED_RELATIONSHIP, Concepts.EXISTENTIAL_RESTRICTION_MODIFIER);
    String additionalLine = TAB_JOINER.join(additionalRelationshipId, transientEffectiveTime, "1", Concepts.MODULE_SCT_CORE, Concepts.ROOT_CONCEPT, Concepts.NAMESPACE_ROOT, "0", Concepts.PART_OF, Concepts.ADDITIONAL_RELATIONSHIP, Concepts.EXISTENTIAL_RESTRICTION_MODIFIER);
    String valueLine = TAB_JOINER.join(valueRelationshipId, transientEffectiveTime, "1", Concepts.MODULE_SCT_CORE, Concepts.ROOT_CONCEPT, "#99", "0", Concepts.PART_OF, Concepts.INFERRED_RELATIONSHIP, Concepts.EXISTENTIAL_RESTRICTION_MODIFIER);
    Multimap<String, Pair<Boolean, String>> fileToLinesMap = ArrayListMultimap.<String, Pair<Boolean, String>>create();
    fileToLinesMap.put("sct2_StatedRelationship", Pair.of(true, statedLine));
    fileToLinesMap.put("sct2_StatedRelationship", Pair.of(false, inferredLine));
    fileToLinesMap.put("sct2_StatedRelationship", Pair.of(false, additionalLine));
    fileToLinesMap.put("sct2_StatedRelationship", Pair.of(false, valueLine));
    fileToLinesMap.put("sct2_Relationship", Pair.of(false, statedLine));
    fileToLinesMap.put("sct2_Relationship", Pair.of(true, inferredLine));
    fileToLinesMap.put("sct2_Relationship", Pair.of(true, additionalLine));
    fileToLinesMap.put("sct2_Relationship", Pair.of(false, valueLine));
    fileToLinesMap.put("sct2_RelationshipConcreteValues", Pair.of(false, statedLine));
    fileToLinesMap.put("sct2_RelationshipConcreteValues", Pair.of(false, inferredLine));
    fileToLinesMap.put("sct2_RelationshipConcreteValues", Pair.of(false, additionalLine));
    fileToLinesMap.put("sct2_RelationshipConcreteValues", Pair.of(true, valueLine));
    assertArchiveContainsLines(exportArchive, fileToLinesMap);
}
Also used : File(java.io.File) Pair(com.b2international.commons.Pair) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest) Test(org.junit.Test)

Aggregations

Pair (com.b2international.commons.Pair)15 AbstractSnomedApiTest (com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)14 File (java.io.File)14 Test (org.junit.Test)14 IBranchPath (com.b2international.snowowl.core.api.IBranchPath)5 Json (com.b2international.commons.json.Json)3 CommitResult (com.b2international.snowowl.core.request.CommitResult)1 SnomedReferenceSetMembers (com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMembers)1 IOException (java.io.IOException)1 BasicFileAttributes (java.nio.file.attribute.BasicFileAttributes)1 Ignore (org.junit.Ignore)1