//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private long createPersonNode(org.neo4j.kernel.api.KernelTransaction ktx, Object value) throws org.neo4j.internal.kernel.api.exceptions.KernelException private long CreatePersonNode(KernelTransaction ktx, object value) { int labelId = ktx.TokenWrite().labelGetOrCreateForName(PERSON_LABEL); int propertyKeyId = ktx.TokenWrite().propertyKeyGetOrCreateForName(NAME_PROPERTY); long nodeId = ktx.DataWrite().nodeCreate(); ktx.DataWrite().nodeAddLabel(nodeId, labelId); ktx.DataWrite().nodeSetProperty(nodeId, propertyKeyId, Values.of(value)); return(nodeId); }
public override ConstraintDefinition CreatePropertyExistenceConstraint(RelationshipType type, string propertyKey) { KernelTransaction transaction = SafeAcquireTransaction(TransactionSupplier); using (Statement ignore = transaction.AcquireStatement()) { try { TokenWrite tokenWrite = transaction.TokenWrite(); int typeId = tokenWrite.RelationshipTypeGetOrCreateForName(type.Name()); int[] propertyKeyId = getOrCreatePropertyKeyIds(tokenWrite, propertyKey); transaction.SchemaWrite().relationshipPropertyExistenceConstraintCreate(SchemaDescriptorFactory.forRelType(typeId, propertyKeyId)); return(new RelationshipPropertyExistenceConstraintDefinition(this, type, propertyKey)); } catch (Exception e) when(e is AlreadyConstrainedException || e is CreateConstraintFailureException || e is RepeatedSchemaComponentException) { throw new ConstraintViolationException(e.getUserMessage(new SilentTokenNameLookup(transaction.TokenRead())), e); } catch (IllegalTokenNameException e) { throw new System.ArgumentException(e); } catch (Exception e) when(e is InvalidTransactionTypeKernelException || e is SchemaKernelException) { throw new ConstraintViolationException(e.Message, e); } } }
public override ConstraintDefinition CreatePropertyExistenceConstraint(Label label, params string[] propertyKeys) { KernelTransaction transaction = SafeAcquireTransaction(TransactionSupplier); using (Statement ignore = transaction.AcquireStatement()) { try { TokenWrite tokenWrite = transaction.TokenWrite(); int labelId = tokenWrite.LabelGetOrCreateForName(label.Name()); int[] propertyKeyIds = getOrCreatePropertyKeyIds(tokenWrite, propertyKeys); transaction.SchemaWrite().nodePropertyExistenceConstraintCreate(forLabel(labelId, propertyKeyIds)); return(new NodePropertyExistenceConstraintDefinition(this, label, propertyKeys)); } catch (Exception e) when(e is AlreadyConstrainedException || e is CreateConstraintFailureException || e is RepeatedSchemaComponentException) { throw new ConstraintViolationException(e.getUserMessage(new SilentTokenNameLookup(transaction.TokenRead())), e); } catch (IllegalTokenNameException e) { throw new System.ArgumentException(e); } catch (TooManyLabelsException e) { throw new System.InvalidOperationException(e); } catch (Exception e) when(e is InvalidTransactionTypeKernelException || e is SchemaKernelException) { throw new ConstraintViolationException(e.Message, e); } } }
public override IndexDefinition CreateIndexDefinition(Label label, Optional <string> indexName, params string[] propertyKeys) { KernelTransaction transaction = SafeAcquireTransaction(TransactionSupplier); using (Statement ignore = transaction.AcquireStatement()) { try { TokenWrite tokenWrite = transaction.TokenWrite(); int labelId = tokenWrite.LabelGetOrCreateForName(label.Name()); int[] propertyKeyIds = getOrCreatePropertyKeyIds(tokenWrite, propertyKeys); LabelSchemaDescriptor descriptor = forLabel(labelId, propertyKeyIds); IndexReference indexReference = transaction.SchemaWrite().indexCreate(descriptor, indexName); return(new IndexDefinitionImpl(this, indexReference, new Label[] { label }, propertyKeys, false)); } catch (IllegalTokenNameException e) { throw new System.ArgumentException(e); } catch (Exception e) when(e is InvalidTransactionTypeKernelException || e is SchemaKernelException) { throw new ConstraintViolationException(e.GetUserMessage(new SilentTokenNameLookup(transaction.TokenRead())), e); } } }
public override void AddLabel(Label label) { KernelTransaction transaction = _spi.kernelTransaction(); try { using (Statement ignore = transaction.AcquireStatement()) { transaction.DataWrite().nodeAddLabel(Id, transaction.TokenWrite().labelGetOrCreateForName(label.Name())); } } catch (ConstraintValidationException e) { throw new ConstraintViolationException(e.GetUserMessage(new SilentTokenNameLookup(transaction.TokenRead())), e); } catch (IllegalTokenNameException e) { throw new ConstraintViolationException(format("Invalid label name '%s'.", label.Name()), e); } catch (TooManyLabelsException e) { throw new ConstraintViolationException("Unable to add label.", e); } catch (EntityNotFoundException e) { throw new NotFoundException("No node with id " + Id + " found.", e); } catch (KernelException e) { throw new ConstraintViolationException(e.Message, e); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public Object removeProperty(String key) throws org.neo4j.graphdb.NotFoundException public override object RemoveProperty(string key) { KernelTransaction transaction = _spi.kernelTransaction(); try { using (Statement ignore = transaction.AcquireStatement()) { int propertyKeyId = transaction.TokenWrite().propertyKeyGetOrCreateForName(key); return(transaction.DataWrite().nodeRemoveProperty(_nodeId, propertyKeyId).asObjectCopy()); } } catch (EntityNotFoundException e) { throw new NotFoundException(e); } catch (IllegalTokenNameException e) { throw new System.ArgumentException(format("Invalid property key '%s'.", key), e); } catch (InvalidTransactionTypeKernelException e) { throw new ConstraintViolationException(e.Message, e); } catch (AutoIndexingKernelException e) { throw new System.InvalidOperationException("Auto indexing encountered a failure while removing property: " + e.Message, e); } }
public override object RemoveProperty(string key) { KernelTransaction transaction = SafeAcquireTransaction(); int propertyKeyId; try { propertyKeyId = transaction.TokenWrite().propertyKeyGetOrCreateForName(key); } catch (IllegalTokenNameException e) { throw new System.ArgumentException(format("Invalid property key '%s'.", key), e); } try { using (Statement ignore = transaction.AcquireStatement()) { return(transaction.DataWrite().graphRemoveProperty(propertyKeyId).asObjectCopy()); } } catch (InvalidTransactionTypeKernelException e) { throw new ConstraintViolationException(e.Message, e); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.neo4j.internal.kernel.api.IndexReference createPersonNameIndex() throws org.neo4j.internal.kernel.api.exceptions.KernelException private IndexReference CreatePersonNameIndex() { using (Transaction tx = _db.beginTx()) { IndexReference index; KernelTransaction ktx = _bridge.getKernelTransactionBoundToThisThread(true); using (Statement ignore = ktx.AcquireStatement()) { int labelId = ktx.TokenWrite().labelGetOrCreateForName(PERSON_LABEL); int propertyKeyId = ktx.TokenWrite().propertyKeyGetOrCreateForName(NAME_PROPERTY); LabelSchemaDescriptor descriptor = forLabel(labelId, propertyKeyId); index = ktx.SchemaWrite().indexCreate(descriptor); } tx.Success(); return(index); } }
public override void SetProperty(string key, object value) { KernelTransaction transaction = _spi.kernelTransaction(); int propertyKeyId; try { propertyKeyId = transaction.TokenWrite().propertyKeyGetOrCreateForName(key); } catch (IllegalTokenNameException e) { throw new System.ArgumentException(format("Invalid property key '%s'.", key), e); } try { using (Statement ignore = transaction.AcquireStatement()) { transaction.DataWrite().nodeSetProperty(_nodeId, propertyKeyId, Values.of(value, false)); } } catch (ConstraintValidationException e) { throw new ConstraintViolationException(e.GetUserMessage(new SilentTokenNameLookup(transaction.TokenRead())), e); } catch (System.ArgumentException e) { // Trying to set an illegal value is a critical error - fail this transaction _spi.failTransaction(); throw e; } catch (EntityNotFoundException e) { throw new NotFoundException(e); } catch (InvalidTransactionTypeKernelException e) { throw new ConstraintViolationException(e.Message, e); } catch (AutoIndexingKernelException e) { throw new System.InvalidOperationException("Auto indexing encountered a failure while setting property: " + e.Message, e); } catch (KernelException e) { throw new ConstraintViolationException(e.Message, e); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public long makeNode(String label) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException public virtual long MakeNode(string label) { long result; try { using (Transaction tx = _graph.beginTransaction(KernelTransaction.Type.@explicit, AnonymousContext.write())) { KernelTransaction ktx = _txBridge.getKernelTransactionBoundToThisThread(true); long nodeId = ktx.DataWrite().nodeCreate(); int labelId = ktx.TokenWrite().labelGetOrCreateForName(label); ktx.DataWrite().nodeAddLabel(nodeId, labelId); result = nodeId; tx.Success(); } } catch (Exception e) { _log.error("Failed to create node: " + e.Message); throw new ProcedureException(Org.Neo4j.Kernel.Api.Exceptions.Status_Procedure.ProcedureCallFailed, "Failed to create node: " + e.Message, e); } return(result); }
public override ConstraintDefinition CreateNodeKeyConstraint(IndexDefinition indexDefinition) { if (indexDefinition.MultiTokenIndex) { throw new ConstraintViolationException("A node key constraint does not support multi-token index definitions. " + "That is, only a single label is supported, but the following labels were provided: " + labelNameList(indexDefinition.Labels, "", ".")); } KernelTransaction transaction = SafeAcquireTransaction(TransactionSupplier); using (Statement ignore = transaction.AcquireStatement()) { try { TokenWrite tokenWrite = transaction.TokenWrite(); int labelId = tokenWrite.LabelGetOrCreateForName(single(indexDefinition.Labels).name()); int[] propertyKeyIds = getOrCreatePropertyKeyIds(tokenWrite, indexDefinition); transaction.SchemaWrite().nodeKeyConstraintCreate(forLabel(labelId, propertyKeyIds)); return(new NodeKeyConstraintDefinition(this, indexDefinition)); } catch (Exception e) when(e is AlreadyConstrainedException || e is CreateConstraintFailureException || e is AlreadyIndexedException || e is RepeatedSchemaComponentException) { throw new ConstraintViolationException(e.getUserMessage(new SilentTokenNameLookup(transaction.TokenRead())), e); } catch (IllegalTokenNameException e) { throw new System.ArgumentException(e); } catch (TooManyLabelsException e) { throw new System.InvalidOperationException(e); } catch (Exception e) when(e is InvalidTransactionTypeKernelException || e is SchemaKernelException) { throw new ConstraintViolationException(e.Message, e); } } }
public override Relationship CreateRelationshipTo(Node otherNode, RelationshipType type) { if (otherNode == null) { throw new System.ArgumentException("Other node is null."); } // TODO: This is the checks we would like to do, but we have tests that expect to mix nodes... //if ( !(otherNode instanceof NodeProxy) || (((NodeProxy) otherNode).actions != actions) ) //{ // throw new IllegalArgumentException( "Nodes do not belong to same graph database." ); //} KernelTransaction transaction = SafeAcquireTransaction(); try { using (Statement ignore = transaction.AcquireStatement()) { int relationshipTypeId = transaction.TokenWrite().relationshipTypeGetOrCreateForName(type.Name()); long relationshipId = transaction.DataWrite().relationshipCreate(_nodeId, relationshipTypeId, otherNode.Id); return(_spi.newRelationshipProxy(relationshipId, _nodeId, relationshipTypeId, otherNode.Id)); } } catch (IllegalTokenNameException e) { throw new System.ArgumentException(e); } catch (EntityNotFoundException e) { throw new NotFoundException("Node[" + e.entityId() + "] is deleted and cannot be used to create a relationship"); } catch (InvalidTransactionTypeKernelException e) { throw new ConstraintViolationException(e.Message, e); } }