Search in sources :

Example 1 with ConstraintEnforcingEntityOperations

use of org.neo4j.kernel.impl.api.ConstraintEnforcingEntityOperations in project neo4j by neo4j.

the class NeoStoreDataSource method buildStatementOperations.

private StatementOperationContainer buildStatementOperations(StoreReadLayer storeReadLayer, AutoIndexing autoIndexing, ConstraintIndexCreator constraintIndexCreator, UpdateableSchemaState updateableSchemaState, Guard guard, LegacyIndexStore legacyIndexStore) {
    // The passed in StoreReadLayer is the bottom most layer: Read-access to committed data.
    // To it we add:
    // + Transaction state handling
    StateHandlingStatementOperations stateHandlingContext = new StateHandlingStatementOperations(storeReadLayer, autoIndexing, constraintIndexCreator, legacyIndexStore);
    QueryRegistrationOperations queryRegistrationOperations = new StackingQueryRegistrationOperations(clock);
    StatementOperationParts parts = new StatementOperationParts(stateHandlingContext, stateHandlingContext, stateHandlingContext, stateHandlingContext, stateHandlingContext, stateHandlingContext, new SchemaStateConcern(updateableSchemaState), null, stateHandlingContext, stateHandlingContext, stateHandlingContext, queryRegistrationOperations);
    // + Constraints
    ConstraintEnforcingEntityOperations constraintEnforcingEntityOperations = new ConstraintEnforcingEntityOperations(constraintSemantics, parts.entityWriteOperations(), parts.entityReadOperations(), parts.schemaWriteOperations(), parts.schemaReadOperations());
    // + Data integrity
    DataIntegrityValidatingStatementOperations dataIntegrityContext = new DataIntegrityValidatingStatementOperations(parts.keyWriteOperations(), parts.schemaReadOperations(), constraintEnforcingEntityOperations);
    parts = parts.override(null, dataIntegrityContext, constraintEnforcingEntityOperations, constraintEnforcingEntityOperations, null, dataIntegrityContext, null, null, null, null, null, null);
    // + Locking
    LockingStatementOperations lockingContext = new LockingStatementOperations(parts.entityReadOperations(), parts.entityWriteOperations(), parts.schemaReadOperations(), parts.schemaWriteOperations(), parts.schemaStateOperations());
    parts = parts.override(null, null, null, lockingContext, lockingContext, lockingContext, lockingContext, lockingContext, null, null, null, null);
    // + Guard
    GuardingStatementOperations guardingOperations = new GuardingStatementOperations(parts.entityWriteOperations(), parts.entityReadOperations(), guard);
    StatementOperationParts guardedParts = parts.override(null, null, guardingOperations, guardingOperations, null, null, null, null, null, null, null, null);
    return new StatementOperationContainer(guardedParts, parts);
}
Also used : StackingQueryRegistrationOperations(org.neo4j.kernel.impl.api.StackingQueryRegistrationOperations) QueryRegistrationOperations(org.neo4j.kernel.impl.api.operations.QueryRegistrationOperations) SchemaStateConcern(org.neo4j.kernel.impl.api.SchemaStateConcern) StatementOperationParts(org.neo4j.kernel.impl.api.StatementOperationParts) LockingStatementOperations(org.neo4j.kernel.impl.api.LockingStatementOperations) StateHandlingStatementOperations(org.neo4j.kernel.impl.api.StateHandlingStatementOperations) ConstraintEnforcingEntityOperations(org.neo4j.kernel.impl.api.ConstraintEnforcingEntityOperations) StackingQueryRegistrationOperations(org.neo4j.kernel.impl.api.StackingQueryRegistrationOperations) GuardingStatementOperations(org.neo4j.kernel.impl.api.GuardingStatementOperations) StatementOperationContainer(org.neo4j.kernel.impl.api.StatementOperationContainer) DataIntegrityValidatingStatementOperations(org.neo4j.kernel.impl.api.DataIntegrityValidatingStatementOperations)

Example 2 with ConstraintEnforcingEntityOperations

use of org.neo4j.kernel.impl.api.ConstraintEnforcingEntityOperations in project neo4j by neo4j.

the class ConstraintEnforcingEntityOperationsTest method given_ConstraintEnforcingEntityOperations_with_OnlineIndex.

@Before
public void given_ConstraintEnforcingEntityOperations_with_OnlineIndex() throws Exception {
    this.readOps = mock(EntityReadOperations.class);
    SchemaReadOperations schemaReadOps = mock(SchemaReadOperations.class);
    SchemaWriteOperations schemaWriteOps = mock(SchemaWriteOperations.class);
    this.state = mock(KernelStatement.class);
    when(schemaReadOps.indexGetState(state, index)).thenReturn(InternalIndexState.ONLINE);
    this.locks = mock(Locks.Client.class);
    when(state.locks()).thenReturn(new SimpleStatementLocks(locks));
    when(state.lockTracer()).thenReturn(LockTracer.NONE);
    this.ops = new ConstraintEnforcingEntityOperations(new StandardConstraintSemantics(), null, readOps, schemaWriteOps, schemaReadOps);
}
Also used : KernelStatement(org.neo4j.kernel.impl.api.KernelStatement) ConstraintEnforcingEntityOperations(org.neo4j.kernel.impl.api.ConstraintEnforcingEntityOperations) SimpleStatementLocks(org.neo4j.kernel.impl.locking.SimpleStatementLocks) StandardConstraintSemantics(org.neo4j.kernel.impl.constraints.StandardConstraintSemantics) Before(org.junit.Before)

Example 3 with ConstraintEnforcingEntityOperations

use of org.neo4j.kernel.impl.api.ConstraintEnforcingEntityOperations in project neo4j by neo4j.

the class IndexQueryTransactionStateTest method before.

@Before
public void before() throws Exception {
    TransactionState txState = new TxState();
    state = StatementOperationsTestHelper.mockedState(txState);
    store = mock(StoreReadLayer.class);
    when(store.indexGetState(newIndexDescriptor)).thenReturn(InternalIndexState.ONLINE);
    when(store.indexesGetForLabel(labelId)).then(answerAsIteratorFrom(indexes));
    when(store.indexesGetAll()).then(answerAsIteratorFrom(indexes));
    when(store.constraintsGetForLabel(labelId)).thenReturn(Collections.emptyIterator());
    when(store.indexGetForLabelAndPropertyKey(newIndexDescriptor.schema())).thenReturn(newIndexDescriptor);
    statement = mock(StoreStatement.class);
    when(state.getStoreStatement()).thenReturn(statement);
    indexReader = mock(IndexReader.class);
    when(statement.getIndexReader(newIndexDescriptor)).thenReturn(indexReader);
    when(statement.getFreshIndexReader(newIndexDescriptor)).thenReturn(indexReader);
    StateHandlingStatementOperations stateHandlingOperations = new StateHandlingStatementOperations(store, new InternalAutoIndexing(Config.empty(), null), mock(ConstraintIndexCreator.class), mock(LegacyIndexStore.class));
    txContext = new ConstraintEnforcingEntityOperations(new StandardConstraintSemantics(), stateHandlingOperations, stateHandlingOperations, stateHandlingOperations, stateHandlingOperations);
}
Also used : TransactionState(org.neo4j.kernel.api.txstate.TransactionState) StoreReadLayer(org.neo4j.storageengine.api.StoreReadLayer) LegacyIndexStore(org.neo4j.kernel.impl.index.LegacyIndexStore) StoreStatement(org.neo4j.kernel.impl.api.store.StoreStatement) InternalAutoIndexing(org.neo4j.kernel.impl.api.legacyindex.InternalAutoIndexing) IndexReader(org.neo4j.storageengine.api.schema.IndexReader) StateHandlingStatementOperations(org.neo4j.kernel.impl.api.StateHandlingStatementOperations) ConstraintEnforcingEntityOperations(org.neo4j.kernel.impl.api.ConstraintEnforcingEntityOperations) StandardConstraintSemantics(org.neo4j.kernel.impl.constraints.StandardConstraintSemantics) Before(org.junit.Before)

Aggregations

ConstraintEnforcingEntityOperations (org.neo4j.kernel.impl.api.ConstraintEnforcingEntityOperations)3 Before (org.junit.Before)2 StateHandlingStatementOperations (org.neo4j.kernel.impl.api.StateHandlingStatementOperations)2 StandardConstraintSemantics (org.neo4j.kernel.impl.constraints.StandardConstraintSemantics)2 TransactionState (org.neo4j.kernel.api.txstate.TransactionState)1 DataIntegrityValidatingStatementOperations (org.neo4j.kernel.impl.api.DataIntegrityValidatingStatementOperations)1 GuardingStatementOperations (org.neo4j.kernel.impl.api.GuardingStatementOperations)1 KernelStatement (org.neo4j.kernel.impl.api.KernelStatement)1 LockingStatementOperations (org.neo4j.kernel.impl.api.LockingStatementOperations)1 SchemaStateConcern (org.neo4j.kernel.impl.api.SchemaStateConcern)1 StackingQueryRegistrationOperations (org.neo4j.kernel.impl.api.StackingQueryRegistrationOperations)1 StatementOperationContainer (org.neo4j.kernel.impl.api.StatementOperationContainer)1 StatementOperationParts (org.neo4j.kernel.impl.api.StatementOperationParts)1 InternalAutoIndexing (org.neo4j.kernel.impl.api.legacyindex.InternalAutoIndexing)1 QueryRegistrationOperations (org.neo4j.kernel.impl.api.operations.QueryRegistrationOperations)1 StoreStatement (org.neo4j.kernel.impl.api.store.StoreStatement)1 LegacyIndexStore (org.neo4j.kernel.impl.index.LegacyIndexStore)1 SimpleStatementLocks (org.neo4j.kernel.impl.locking.SimpleStatementLocks)1 StoreReadLayer (org.neo4j.storageengine.api.StoreReadLayer)1 IndexReader (org.neo4j.storageengine.api.schema.IndexReader)1