public override void VisitNodeKeyConstraint(NodeKeyConstraintDescriptor constraint, string userDescription) { if (!_nodeKeyConstraints.Add(constraint)) { throw new System.ArgumentException(format("Duplicated node key constraint %s for %s", constraint, userDescription)); } }
private void ShowUniqueConstraints(DbStructureVisitor visitor, KernelTransaction ktx, TokenNameLookup nameLookup) { IEnumerator <ConstraintDescriptor> constraints = ktx.SchemaRead().constraintsGetAll(); while (constraints.MoveNext()) { ConstraintDescriptor constraint = constraints.Current; string userDescription = constraint.PrettyPrint(nameLookup); if (constraint is UniquenessConstraintDescriptor) { visitor.VisitUniqueConstraint(( UniquenessConstraintDescriptor )constraint, userDescription); } else if (constraint is NodeExistenceConstraintDescriptor) { NodeExistenceConstraintDescriptor existenceConstraint = ( NodeExistenceConstraintDescriptor )constraint; visitor.VisitNodePropertyExistenceConstraint(existenceConstraint, userDescription); } else if (constraint is RelExistenceConstraintDescriptor) { RelExistenceConstraintDescriptor existenceConstraint = ( RelExistenceConstraintDescriptor )constraint; visitor.VisitRelationshipPropertyExistenceConstraint(existenceConstraint, userDescription); } else if (constraint is NodeKeyConstraintDescriptor) { NodeKeyConstraintDescriptor nodeKeyConstraint = ( NodeKeyConstraintDescriptor )constraint; visitor.VisitNodeKeyConstraint(nodeKeyConstraint, userDescription); } else { throw new System.ArgumentException("Unknown constraint type: " + constraint.GetType() + ", " + "constraint: " + constraint); } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void visitAddedNodeKeyConstraint(org.neo4j.kernel.api.schema.constraints.NodeKeyConstraintDescriptor uniqueConstraint, long constraintId) throws org.neo4j.internal.kernel.api.exceptions.schema.CreateConstraintFailureException private void VisitAddedNodeKeyConstraint(NodeKeyConstraintDescriptor uniqueConstraint, long constraintId) { StoreIndexDescriptor indexRule = _schemaStorage.indexGetForSchema(uniqueConstraint.OwnedIndexDescriptor()); _recordState.createSchemaRule(_constraintSemantics.createNodeKeyConstraintRule(constraintId, uniqueConstraint, indexRule.Id)); _recordState.setConstraintIndexOwner(indexRule, constraintId); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void constraintPropertyIdsNotUpdatedByConstraintEnforcer() public virtual void ConstraintPropertyIdsNotUpdatedByConstraintEnforcer() { UniquenessConstraintDescriptor uniquenessConstraint = ConstraintDescriptorFactory.uniqueForLabel(1, 1, 70, 8); NodeKeyConstraintDescriptor nodeKeyConstraint = ConstraintDescriptorFactory.nodeKeyForLabel(2, 12, 7, 13); RelExistenceConstraintDescriptor relTypeConstraint = ConstraintDescriptorFactory.existsForRelType(3, 5, 13, 8); IList <ConstraintDescriptor> descriptors = Arrays.asList(uniquenessConstraint, nodeKeyConstraint, relTypeConstraint); StorageReader storageReader = PrepareStorageReaderMock(descriptors); PropertyExistenceEnforcer.GetOrCreatePropertyExistenceEnforcerFrom(storageReader); assertArrayEquals("Property ids should remain untouched.", new int[] { 1, 70, 8 }, uniquenessConstraint.Schema().PropertyIds); assertArrayEquals("Property ids should remain untouched.", new int[] { 12, 7, 13 }, nodeKeyConstraint.Schema().PropertyIds); assertArrayEquals("Property ids should remain untouched.", new int[] { 5, 13, 8 }, relTypeConstraint.Schema().PropertyIds); }