use of com.vaticle.typedb.core.concept.type.ThingType 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;
}
}
use of com.vaticle.typedb.core.concept.type.ThingType in project grakn by graknlabs.
the class ThingTypeSteps method thing_type_get_supertype.
@Then("{root_label}\\( ?{type_label} ?) get supertype: {type_label}")
public void thing_type_get_supertype(RootLabel rootLabel, String typeLabel, String superLabel) {
ThingType supertype = get_thing_type(rootLabel, superLabel);
assertEquals(supertype, get_thing_type(rootLabel, typeLabel).getSupertype());
}
use of com.vaticle.typedb.core.concept.type.ThingType in project grakn by graknlabs.
the class AttributeTypeSteps method attribute_type_get_owners_as_key_do_not_contains.
@Then("attribute\\( ?{type_label} ?) get key owners do not contain:")
public void attribute_type_get_owners_as_key_do_not_contains(String typeLabel, List<String> ownerLabels) {
AttributeType attributeType = tx().concepts().getAttributeType(typeLabel);
Set<String> actuals = attributeType.getOwners(true).map(ThingType::getLabel).map(Label::toString).toSet();
for (String ownerLabel : ownerLabels) {
assertFalse(actuals.contains(ownerLabel));
}
}
use of com.vaticle.typedb.core.concept.type.ThingType in project grakn by graknlabs.
the class AttributeTypeSteps method attribute_type_get_owners_as_key_contains.
@Then("attribute\\( ?{type_label} ?) get key owners contain:")
public void attribute_type_get_owners_as_key_contains(String typeLabel, List<String> ownerLabels) {
AttributeType attributeType = tx().concepts().getAttributeType(typeLabel);
Set<String> actuals = attributeType.getOwners(true).map(ThingType::getLabel).map(Label::toString).toSet();
assertTrue(actuals.containsAll(ownerLabels));
}
use of com.vaticle.typedb.core.concept.type.ThingType in project grakn by graknlabs.
the class ThingSteps method thing_has_type.
@Then("{root_label} {var} has type: {type_label}")
public void thing_has_type(RootLabel rootLabel, String var, String typeLabel) {
ThingType type = get_thing_type(rootLabel, typeLabel);
assertEquals(type, get(var).getType());
}
Aggregations