Search in sources :

Example 1 with TYPE_NOT_FOUND

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);
        }
    });
}
Also used : Pair(com.vaticle.typedb.common.collection.Pair) ILLEGAL_STATE(com.vaticle.typedb.core.common.exception.ErrorMessage.Internal.ILLEGAL_STATE) TraversalEngine(com.vaticle.typedb.core.traversal.TraversalEngine) TypeConstraint(com.vaticle.typedb.core.pattern.constraint.type.TypeConstraint) Collections.set(com.vaticle.typedb.common.collection.Collections.set) Variable(com.vaticle.typedb.core.pattern.variable.Variable) Identifier(com.vaticle.typedb.core.traversal.common.Identifier) UNSATISFIABLE_SUB_PATTERN(com.vaticle.typedb.core.common.exception.ErrorMessage.Pattern.UNSATISFIABLE_SUB_PATTERN) HashMap(java.util.HashMap) UNSATISFIABLE_PATTERN_VARIABLE_VALUE(com.vaticle.typedb.core.common.exception.ErrorMessage.Pattern.UNSATISFIABLE_PATTERN_VARIABLE_VALUE) LogicCache(com.vaticle.typedb.core.logic.LogicCache) PlaysConstraint(com.vaticle.typedb.core.pattern.constraint.type.PlaysConstraint) UNSATISFIABLE_PATTERN_VARIABLE(com.vaticle.typedb.core.common.exception.ErrorMessage.Pattern.UNSATISFIABLE_PATTERN_VARIABLE) IIDConstraint(com.vaticle.typedb.core.pattern.constraint.thing.IIDConstraint) IsConstraint(com.vaticle.typedb.core.pattern.constraint.thing.IsConstraint) ATTRIBUTE(com.vaticle.typeql.lang.common.TypeQLToken.Type.ATTRIBUTE) VertexIID(com.vaticle.typedb.core.graph.iid.VertexIID) Map(java.util.Map) ValueConstraint(com.vaticle.typedb.core.pattern.constraint.thing.ValueConstraint) RelatesConstraint(com.vaticle.typedb.core.pattern.constraint.type.RelatesConstraint) TYPE_NOT_FOUND(com.vaticle.typedb.core.common.exception.ErrorMessage.TypeRead.TYPE_NOT_FOUND) OwnsConstraint(com.vaticle.typedb.core.pattern.constraint.type.OwnsConstraint) ValueTypeConstraint(com.vaticle.typedb.core.pattern.constraint.type.ValueTypeConstraint) GraphTraversal(com.vaticle.typedb.core.traversal.GraphTraversal) Iterators.empty(com.vaticle.typedb.core.common.iterator.Iterators.empty) Label(com.vaticle.typedb.core.common.parameters.Label) Encoding(com.vaticle.typedb.core.graph.common.Encoding) GraphManager(com.vaticle.typedb.core.graph.GraphManager) Conjunction(com.vaticle.typedb.core.pattern.Conjunction) FunctionalIterator(com.vaticle.typedb.core.common.iterator.FunctionalIterator) ThingVariable(com.vaticle.typedb.core.pattern.variable.ThingVariable) IsaConstraint(com.vaticle.typedb.core.pattern.constraint.thing.IsaConstraint) SubConstraint(com.vaticle.typedb.core.pattern.constraint.type.SubConstraint) Set(java.util.Set) RegexConstraint(com.vaticle.typedb.core.pattern.constraint.type.RegexConstraint) Disjunction(com.vaticle.typedb.core.pattern.Disjunction) HasConstraint(com.vaticle.typedb.core.pattern.constraint.thing.HasConstraint) Retrievable(com.vaticle.typedb.core.traversal.common.Identifier.Variable.Retrievable) TraversalVertex(com.vaticle.typedb.core.traversal.graph.TraversalVertex) TypeVariable(com.vaticle.typedb.core.pattern.variable.TypeVariable) RelationConstraint(com.vaticle.typedb.core.pattern.constraint.thing.RelationConstraint) Optional(java.util.Optional) Iterators.iterate(com.vaticle.typedb.core.common.iterator.Iterators.iterate) TypeDBException(com.vaticle.typedb.core.common.exception.TypeDBException) ROLE_TYPE_NOT_FOUND(com.vaticle.typedb.core.common.exception.ErrorMessage.TypeRead.ROLE_TYPE_NOT_FOUND) TypeVertex(com.vaticle.typedb.core.graph.vertex.TypeVertex) Comparator(java.util.Comparator) Label(com.vaticle.typedb.core.common.parameters.Label)

Example 2 with TYPE_NOT_FOUND

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();
    }
}
Also used : ConceptManager(com.vaticle.typedb.core.concept.ConceptManager) Context(com.vaticle.typedb.core.common.parameters.Context) LabelConstraint(com.vaticle.typedb.core.pattern.constraint.type.LabelConstraint) TypeQLUndefine(com.vaticle.typeql.lang.query.TypeQLUndefine) RelationType(com.vaticle.typedb.core.concept.type.RelationType) INVALID_UNDEFINE_SUB(com.vaticle.typedb.core.common.exception.ErrorMessage.TypeWrite.INVALID_UNDEFINE_SUB) LogicManager(com.vaticle.typedb.core.logic.LogicManager) HashSet(java.util.HashSet) PlaysConstraint(com.vaticle.typedb.core.pattern.constraint.type.PlaysConstraint) TYPE_CONSTRAINT_UNACCEPTED(com.vaticle.typedb.core.common.exception.ErrorMessage.TypeWrite.TYPE_CONSTRAINT_UNACCEPTED) INVALID_UNDEFINE_OWNS_KEY(com.vaticle.typedb.core.common.exception.ErrorMessage.TypeWrite.INVALID_UNDEFINE_OWNS_KEY) ThingType(com.vaticle.typedb.core.concept.type.ThingType) RelatesConstraint(com.vaticle.typedb.core.pattern.constraint.type.RelatesConstraint) TYPE_NOT_FOUND(com.vaticle.typedb.core.common.exception.ErrorMessage.TypeRead.TYPE_NOT_FOUND) INVALID_UNDEFINE_RELATES_OVERRIDE(com.vaticle.typedb.core.common.exception.ErrorMessage.TypeWrite.INVALID_UNDEFINE_RELATES_OVERRIDE) OwnsConstraint(com.vaticle.typedb.core.pattern.constraint.type.OwnsConstraint) LinkedList(java.util.LinkedList) IS(com.vaticle.typeql.lang.common.TypeQLToken.Constraint.IS) ROLE_DEFINED_OUTSIDE_OF_RELATION(com.vaticle.typedb.core.common.exception.ErrorMessage.TypeWrite.ROLE_DEFINED_OUTSIDE_OF_RELATION) SubConstraint(com.vaticle.typedb.core.pattern.constraint.type.SubConstraint) Set(java.util.Set) RegexConstraint(com.vaticle.typedb.core.pattern.constraint.type.RegexConstraint) ATTRIBUTE_VALUE_TYPE_UNDEFINED(com.vaticle.typedb.core.common.exception.ErrorMessage.TypeWrite.ATTRIBUTE_VALUE_TYPE_UNDEFINED) RoleType(com.vaticle.typedb.core.concept.type.RoleType) FactoryTracingThreadStatic.traceOnThread(com.vaticle.factory.tracing.client.FactoryTracingThreadStatic.traceOnThread) RULE_NOT_FOUND(com.vaticle.typedb.core.common.exception.ErrorMessage.RuleRead.RULE_NOT_FOUND) INVALID_UNDEFINE_OWNS_OVERRIDE(com.vaticle.typedb.core.common.exception.ErrorMessage.TypeWrite.INVALID_UNDEFINE_OWNS_OVERRIDE) INVALID_UNDEFINE_RULE_BODY(com.vaticle.typedb.core.common.exception.ErrorMessage.RuleWrite.INVALID_UNDEFINE_RULE_BODY) List(java.util.List) TypeVariable(com.vaticle.typedb.core.pattern.variable.TypeVariable) VariableRegistry(com.vaticle.typedb.core.pattern.variable.VariableRegistry) TypeDBException(com.vaticle.typedb.core.common.exception.TypeDBException) AttributeType(com.vaticle.typedb.core.concept.type.AttributeType) ThreadTrace(com.vaticle.factory.tracing.client.FactoryTracingThreadStatic.ThreadTrace) INVALID_UNDEFINE_PLAYS_OVERRIDE(com.vaticle.typedb.core.common.exception.ErrorMessage.TypeWrite.INVALID_UNDEFINE_PLAYS_OVERRIDE) Type(com.vaticle.typedb.core.concept.type.Type) ThreadTrace(com.vaticle.factory.tracing.client.FactoryTracingThreadStatic.ThreadTrace) ThingType(com.vaticle.typedb.core.concept.type.ThingType)

Aggregations

TYPE_NOT_FOUND (com.vaticle.typedb.core.common.exception.ErrorMessage.TypeRead.TYPE_NOT_FOUND)2 TypeDBException (com.vaticle.typedb.core.common.exception.TypeDBException)2 OwnsConstraint (com.vaticle.typedb.core.pattern.constraint.type.OwnsConstraint)2 PlaysConstraint (com.vaticle.typedb.core.pattern.constraint.type.PlaysConstraint)2 RegexConstraint (com.vaticle.typedb.core.pattern.constraint.type.RegexConstraint)2 RelatesConstraint (com.vaticle.typedb.core.pattern.constraint.type.RelatesConstraint)2 SubConstraint (com.vaticle.typedb.core.pattern.constraint.type.SubConstraint)2 TypeVariable (com.vaticle.typedb.core.pattern.variable.TypeVariable)2 Set (java.util.Set)2 ThreadTrace (com.vaticle.factory.tracing.client.FactoryTracingThreadStatic.ThreadTrace)1 FactoryTracingThreadStatic.traceOnThread (com.vaticle.factory.tracing.client.FactoryTracingThreadStatic.traceOnThread)1 Collections.set (com.vaticle.typedb.common.collection.Collections.set)1 Pair (com.vaticle.typedb.common.collection.Pair)1 ILLEGAL_STATE (com.vaticle.typedb.core.common.exception.ErrorMessage.Internal.ILLEGAL_STATE)1 UNSATISFIABLE_PATTERN_VARIABLE (com.vaticle.typedb.core.common.exception.ErrorMessage.Pattern.UNSATISFIABLE_PATTERN_VARIABLE)1 UNSATISFIABLE_PATTERN_VARIABLE_VALUE (com.vaticle.typedb.core.common.exception.ErrorMessage.Pattern.UNSATISFIABLE_PATTERN_VARIABLE_VALUE)1 UNSATISFIABLE_SUB_PATTERN (com.vaticle.typedb.core.common.exception.ErrorMessage.Pattern.UNSATISFIABLE_SUB_PATTERN)1 RULE_NOT_FOUND (com.vaticle.typedb.core.common.exception.ErrorMessage.RuleRead.RULE_NOT_FOUND)1 INVALID_UNDEFINE_RULE_BODY (com.vaticle.typedb.core.common.exception.ErrorMessage.RuleWrite.INVALID_UNDEFINE_RULE_BODY)1 ROLE_TYPE_NOT_FOUND (com.vaticle.typedb.core.common.exception.ErrorMessage.TypeRead.ROLE_TYPE_NOT_FOUND)1