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));
}
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);
}
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);
}
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());
}
});
}
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 + "'.");
}
}
Aggregations