use of com.vaticle.typedb.core.common.exception.ErrorMessage.TypeRead.TYPE_NOT_FOUND in project grakn by graknlabs.
the class TypeInference method propagateLabels.
private void propagateLabels(Conjunction conj) {
iterate(conj.variables()).filter(v -> v.isType() && v.asType().label().isPresent()).forEachRemaining(typeVar -> {
Label label = typeVar.asType().label().get().properLabel();
if (label.scope().isPresent()) {
Set<Label> labels = graphMgr.schema().resolveRoleTypeLabels(label);
if (labels.isEmpty())
throw TypeDBException.of(ROLE_TYPE_NOT_FOUND, label.name(), label.scope().get());
typeVar.addInferredTypes(labels);
} else {
if (graphMgr.schema().getType(label) == null)
throw TypeDBException.of(TYPE_NOT_FOUND, label);
typeVar.addInferredTypes(label);
}
});
}
use of com.vaticle.typedb.core.common.exception.ErrorMessage.TypeRead.TYPE_NOT_FOUND in project grakn by graknlabs.
the class Undefiner method undefineSub.
private void undefineSub(ThingType thingType, SubConstraint subConstraint) {
try (ThreadTrace ignored = traceOnThread(TRACE_PREFIX + "undefine_sub")) {
if (thingType.isRoleType()) {
throw TypeDBException.of(ROLE_DEFINED_OUTSIDE_OF_RELATION, thingType.getLabel());
}
ThingType supertype = getThingType(subConstraint.type().label().get());
if (supertype == null) {
throw TypeDBException.of(TYPE_NOT_FOUND, subConstraint.type().label().get());
} else if (thingType.getSupertypes().noneMatch(t -> t.equals(supertype))) {
throw TypeDBException.of(INVALID_UNDEFINE_SUB, thingType.getLabel(), supertype.getLabel());
}
if (thingType.isRelationType()) {
variables.stream().filter(v -> v.label().isPresent() && v.label().get().scope().isPresent() && v.label().get().scope().get().equals(thingType.getLabel().name())).forEach(undefined::add);
}
thingType.delete();
}
}
Aggregations