Search in sources :

Example 6 with RelationshipValue

use of com.b2international.snowowl.snomed.core.domain.RelationshipValue in project snow-owl by b2ihealthcare.

the class SnomedConcreteValueApiTest method createInactiveConcreteValue.

@Test
public void createInactiveConcreteValue() {
    Json requestBody = createConcreteValueRequestBody(Concepts.ROOT_CONCEPT, Concepts.PART_OF, new RelationshipValue(5)).with("active", false).with("commitComment", "Created inactive concrete value");
    String relationshipId = assertCreated(createComponent(branchPath, SnomedComponentType.RELATIONSHIP, requestBody));
    getComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationshipId).statusCode(200).body("active", equalTo(false));
}
Also used : Json(com.b2international.commons.json.Json) RelationshipValue(com.b2international.snowowl.snomed.core.domain.RelationshipValue) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 7 with RelationshipValue

use of com.b2international.snowowl.snomed.core.domain.RelationshipValue in project snow-owl by b2ihealthcare.

the class SnomedConcreteValueApiTest method createConcreteValueInvalidValue.

@Test
public void createConcreteValueInvalidValue() {
    Json requestBody = createConcreteValueRequestBody(Concepts.ROOT_CONCEPT, Concepts.PART_OF, new RelationshipValue(20)).with("value", "2021-06-05").with("commitComment", "Created new concrete value with invalid value");
    createComponent(branchPath, SnomedComponentType.RELATIONSHIP, requestBody).statusCode(400);
}
Also used : Json(com.b2international.commons.json.Json) RelationshipValue(com.b2international.snowowl.snomed.core.domain.RelationshipValue) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 8 with RelationshipValue

use of com.b2international.snowowl.snomed.core.domain.RelationshipValue in project snow-owl by b2ihealthcare.

the class SnomedConcreteValueApiTest method createDuplicateConcreteValue.

@Test
public void createDuplicateConcreteValue() {
    String relationshipId = createNewConcreteValue(branchPath);
    Json requestBody = createConcreteValueRequestBody(Concepts.ROOT_CONCEPT, Concepts.PART_OF, new RelationshipValue("string value")).with("id", relationshipId).with("commitComment", "Created new concrete value with duplicate identifier");
    createComponent(branchPath, SnomedComponentType.RELATIONSHIP, requestBody).statusCode(409);
}
Also used : Json(com.b2international.commons.json.Json) RelationshipValue(com.b2international.snowowl.snomed.core.domain.RelationshipValue) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 9 with RelationshipValue

use of com.b2international.snowowl.snomed.core.domain.RelationshipValue in project snow-owl by b2ihealthcare.

the class NormalFormGenerator method relationshipsFromUnionGroup.

private Iterable<StatementFragment> relationshipsFromUnionGroup(final NormalFormUnionGroup unionGroup, final int groupNumber, final int unionGroupNumber) {
    return FluentIterable.from(unionGroup.getProperties()).filter(Predicates.or(Predicates.instanceOf(NormalFormRelationship.class), Predicates.instanceOf(NormalFormValue.class))).transform(property -> {
        if (property instanceof NormalFormRelationship) {
            final NormalFormRelationship r = (NormalFormRelationship) property;
            return new StatementFragmentWithDestination(r.getTypeId(), groupNumber, unionGroupNumber, r.isUniversal(), r.getStatementId(), -1L, r.isReleased(), r.getDestinationId(), r.isDestinationNegated());
        } else {
            final NormalFormValue v = (NormalFormValue) property;
            final RelationshipValue relationshipValue = v.getValue();
            return new StatementFragmentWithValue(v.getTypeId(), groupNumber, unionGroupNumber, false, v.getStatementId(), -1L, v.isReleased(), relationshipValue.type(), relationshipValue.toRawValue());
        }
    });
}
Also used : StatementFragmentWithValue(com.b2international.snowowl.snomed.datastore.StatementFragmentWithValue) StatementFragmentWithDestination(com.b2international.snowowl.snomed.datastore.StatementFragmentWithDestination) RelationshipValue(com.b2international.snowowl.snomed.core.domain.RelationshipValue)

Example 10 with RelationshipValue

use of com.b2international.snowowl.snomed.core.domain.RelationshipValue in project snow-owl by b2ihealthcare.

the class SnomedOWLExpressionConverter method toRelationshipValue.

private RelationshipValue toRelationshipValue(ConcreteValue value) {
    /*
		 * XXX: preserve the OWL2 XSD type, but use the exact numeric representation
		 * given; eg. "50"^^decimal should have decimal type, with "50", a fraction-less
		 * BigDecimal as its value.
		 * 
		 * It is an implementation-dependent feature that "asString" returns the
		 * raw value for numbers as well, this might change in the future!
		 */
    final String rawValue = value.asString();
    final ConcreteValue.Type type = value.getType();
    switch(type) {
        case DECIMAL:
            return RelationshipValue.fromTypeAndObjects(RelationshipValueType.DECIMAL, new BigDecimal(rawValue), null);
        case INTEGER:
            return RelationshipValue.fromTypeAndObjects(RelationshipValueType.INTEGER, new BigDecimal(rawValue), null);
        case STRING:
            return new RelationshipValue(rawValue);
        default:
            throw new IllegalStateException("Unexpected concrete value type '" + type + "'.");
    }
}
Also used : RelationshipValue(com.b2international.snowowl.snomed.core.domain.RelationshipValue) BigDecimal(java.math.BigDecimal) ConcreteValue(org.snomed.otf.owltoolkit.domain.Relationship.ConcreteValue)

Aggregations

RelationshipValue (com.b2international.snowowl.snomed.core.domain.RelationshipValue)20 Test (org.junit.Test)13 AbstractSnomedApiTest (com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)12 Json (com.b2international.commons.json.Json)11 BigDecimal (java.math.BigDecimal)4 SearchResourceRequest (com.b2international.snowowl.core.request.SearchResourceRequest)3 Expressions (com.b2international.index.query.Expressions)2 ExpressionBuilder (com.b2international.index.query.Expressions.ExpressionBuilder)2 Expressions (com.b2international.snowowl.snomed.datastore.index.entry.SnomedRelationshipIndexEntry.Expressions)2 ArrayList (java.util.ArrayList)2 CompareUtils (com.b2international.commons.CompareUtils)1 BadRequestException (com.b2international.commons.exceptions.BadRequestException)1 NotImplementedException (com.b2international.commons.exceptions.NotImplementedException)1 Options (com.b2international.commons.options.Options)1 Expression (com.b2international.index.query.Expression)1 Query (com.b2international.index.query.Query)1 BaseRevisionIndexTest (com.b2international.index.revision.BaseRevisionIndexTest)1 ID (com.b2international.index.revision.Revision.Fields.ID)1 RevisionSearcher (com.b2international.index.revision.RevisionSearcher)1 com.b2international.snomed.ecl.ecl (com.b2international.snomed.ecl.ecl)1