use of org.neo4j.internal.kernel.api.Token in project neo4j by neo4j.
the class Operations method constraintDrop.
@Override
public void constraintDrop(SchemaDescriptor schema, ConstraintType type) throws SchemaKernelException {
ktx.assertOpen();
Iterator<ConstraintDescriptor> constraints = ktx.schemaRead().constraintsGetForSchema(schema);
constraints = Iterators.filter(constraint -> constraint.type() == type, constraints);
if (constraints.hasNext()) {
ConstraintDescriptor constraint = constraints.next();
if (!constraints.hasNext()) {
constraintDrop(constraint);
} else {
String schemaDescription = schema.userDescription(token);
String constraintDescription = constraints.next().userDescription(token);
throw new DropConstraintFailureException(constraint, new IllegalArgumentException("More than one " + type + " constraint was found with the '" + schemaDescription + "' schema: " + constraintDescription + ", please drop constraint by name instead."));
}
} else {
throw new DropConstraintFailureException(schema, new NoSuchConstraintException(schema, token));
}
}
Aggregations