use of com.vaticle.typedb.core.concept.type.AttributeType.ValueType in project grakn by graknlabs.
the class Definer method defineSub.
private ThingType defineSub(ThingType thingType, SubConstraint subConstraint, TypeVariable var) {
try (ThreadTrace ignored = traceOnThread(TRACE_PREFIX + "define_sub")) {
LabelConstraint labelConstraint = var.label().get();
ThingType supertype = define(subConstraint.type()).asThingType();
if (supertype.isEntityType()) {
if (thingType == null)
thingType = conceptMgr.putEntityType(labelConstraint.label());
thingType.asEntityType().setSupertype(supertype.asEntityType());
} else if (supertype.isRelationType()) {
if (thingType == null)
thingType = conceptMgr.putRelationType(labelConstraint.label());
thingType.asRelationType().setSupertype(supertype.asRelationType());
} else if (supertype.isAttributeType()) {
ValueType valueType;
if (var.valueType().isPresent())
valueType = ValueType.of(var.valueType().get().valueType());
else if (!supertype.isRoot())
valueType = supertype.asAttributeType().getValueType();
else
throw TypeDBException.of(ATTRIBUTE_VALUE_TYPE_MISSING, labelConstraint.label());
if (thingType == null)
thingType = conceptMgr.putAttributeType(labelConstraint.label(), valueType);
thingType.asAttributeType().setSupertype(supertype.asAttributeType());
} else {
throw TypeDBException.of(INVALID_DEFINE_SUB, labelConstraint.scopedLabel(), supertype.getLabel());
}
return thingType;
}
}
Aggregations