Search in sources :

Example 1 with TokenWriteOperations

use of org.neo4j.kernel.api.TokenWriteOperations in project neo4j by neo4j.

the class IndexIT method createLabelAndProperty.

@Before
public void createLabelAndProperty() throws Exception {
    TokenWriteOperations tokenWrites = tokenWriteOperationsInNewTransaction();
    labelId = tokenWrites.labelGetOrCreateForName(LABEL);
    propertyKeyId = tokenWrites.propertyKeyGetOrCreateForName(PROPERTY_KEY);
    descriptor = new NodePropertyDescriptor(labelId, propertyKeyId);
    commit();
}
Also used : TokenWriteOperations(org.neo4j.kernel.api.TokenWriteOperations) NodePropertyDescriptor(org.neo4j.kernel.api.schema.NodePropertyDescriptor) Before(org.junit.Before)

Example 2 with TokenWriteOperations

use of org.neo4j.kernel.api.TokenWriteOperations in project neo4j by neo4j.

the class NodeGetUniqueFromIndexSeekIT method createKeys.

@Before
public void createKeys() throws Exception {
    TokenWriteOperations tokenWriteOperations = tokenWriteOperationsInNewTransaction();
    this.labelId = tokenWriteOperations.labelGetOrCreateForName("Person");
    this.propertyId1 = tokenWriteOperations.propertyKeyGetOrCreateForName("foo");
    this.propertyId2 = tokenWriteOperations.propertyKeyGetOrCreateForName("bar");
    commit();
}
Also used : TokenWriteOperations(org.neo4j.kernel.api.TokenWriteOperations) Before(org.junit.Before)

Example 3 with TokenWriteOperations

use of org.neo4j.kernel.api.TokenWriteOperations in project neo4j by neo4j.

the class AbstractConstraintCreationIT method createKeys.

@Before
public void createKeys() throws Exception {
    TokenWriteOperations tokenWriteOperations = tokenWriteOperationsInNewTransaction();
    this.typeId = initializeLabelOrRelType(tokenWriteOperations, KEY);
    this.propertyKeyId = tokenWriteOperations.propertyKeyGetOrCreateForName(PROP);
    this.descriptor = makeDescriptor(typeId, propertyKeyId);
    commit();
}
Also used : TokenWriteOperations(org.neo4j.kernel.api.TokenWriteOperations) Before(org.junit.Before)

Example 4 with TokenWriteOperations

use of org.neo4j.kernel.api.TokenWriteOperations in project neo4j by neo4j.

the class BuiltInProceduresIT method listPropertyKeys.

@Test
public void listPropertyKeys() throws Throwable {
    // Given
    TokenWriteOperations ops = tokenWriteOperationsInNewTransaction();
    ops.propertyKeyGetOrCreateForName("MyProp");
    commit();
    // When
    RawIterator<Object[], ProcedureException> stream = procedureCallOpsInNewTx().procedureCallRead(procedureName("db", "propertyKeys"), new Object[0]);
    // Then
    assertThat(asList(stream), contains(equalTo(new Object[] { "MyProp" })));
}
Also used : TokenWriteOperations(org.neo4j.kernel.api.TokenWriteOperations) ProcedureException(org.neo4j.kernel.api.exceptions.ProcedureException) Test(org.junit.Test)

Example 5 with TokenWriteOperations

use of org.neo4j.kernel.api.TokenWriteOperations in project neo4j by neo4j.

the class UniquenessConstraintValidationIT method createConstraint.

private void createConstraint(String label, String propertyKey) throws KernelException {
    //TODO: Consider testing composite indexes
    int labelId, propertyKeyId;
    TokenWriteOperations tokenWriteOperations = tokenWriteOperationsInNewTransaction();
    labelId = tokenWriteOperations.labelGetOrCreateForName(label);
    propertyKeyId = tokenWriteOperations.propertyKeyGetOrCreateForName(propertyKey);
    commit();
    SchemaWriteOperations schemaWriteOperations = schemaWriteOperationsInNewTransaction();
    schemaWriteOperations.uniquePropertyConstraintCreate(forLabel(labelId, propertyKeyId));
    commit();
}
Also used : TokenWriteOperations(org.neo4j.kernel.api.TokenWriteOperations) SchemaWriteOperations(org.neo4j.kernel.api.SchemaWriteOperations)

Aggregations

TokenWriteOperations (org.neo4j.kernel.api.TokenWriteOperations)5 Before (org.junit.Before)3 Test (org.junit.Test)1 SchemaWriteOperations (org.neo4j.kernel.api.SchemaWriteOperations)1 ProcedureException (org.neo4j.kernel.api.exceptions.ProcedureException)1 NodePropertyDescriptor (org.neo4j.kernel.api.schema.NodePropertyDescriptor)1