use of com.yahoo.elide.core.datastore.DataStoreTransaction in project elide by yahoo.
the class MultiplexTransaction method getToManyRelation.
@Override
public <T, R> DataStoreIterable<R> getToManyRelation(DataStoreTransaction tx, T entity, Relationship relation, RequestScope scope) {
DataStoreTransaction relationTx = getRelationTransaction(entity, relation.getName());
Type<Object> entityType = EntityDictionary.getType(entity);
DataStoreTransaction entityTransaction = getTransaction(entityType);
return entityTransaction.getToManyRelation(relationTx, entity, relation, scope);
}
use of com.yahoo.elide.core.datastore.DataStoreTransaction in project elide by yahoo.
the class MultiplexTransaction method getToOneRelation.
@Override
public <T, R> R getToOneRelation(DataStoreTransaction tx, T entity, Relationship relation, RequestScope scope) {
DataStoreTransaction relationTx = getRelationTransaction(entity, relation.getName());
Type<Object> entityType = EntityDictionary.getType(entity);
DataStoreTransaction entityTransaction = getTransaction(entityType);
return entityTransaction.getToOneRelation(relationTx, entity, relation, scope);
}
use of com.yahoo.elide.core.datastore.DataStoreTransaction in project elide by yahoo.
the class MultiplexWriteTransaction method reverseTransactions.
/**
* Attempt to reverse changes of last commit since not all transactions successfully committed.
* @param restoreList List of database managers to reverse the last commit
* @param cause cause to add any suppressed exceptions
*/
private void reverseTransactions(ArrayList<DataStore> restoreList, Throwable cause, RequestScope requestScope) {
for (DataStore dataStore : restoreList) {
try (DataStoreTransaction transaction = dataStore.beginTransaction()) {
List<Object> list = dirtyObjects.get(dataStore);
for (Object dirtyObject : list == null ? Collections.emptyList() : list) {
Object cloned = clonedObjects.get(dirtyObject);
if (cloned == NEWLY_CREATED_OBJECT) {
transaction.delete(dirtyObject, requestScope);
} else {
transaction.save(cloned, requestScope);
}
}
transaction.commit(requestScope);
} catch (RuntimeException | IOException e) {
cause.addSuppressed(e);
}
}
}
use of com.yahoo.elide.core.datastore.DataStoreTransaction in project elide by yahoo.
the class DataStoreLoadTest method testTabCharacter.
@Test
public void testTabCharacter() throws Exception {
DataStoreTransaction testTransaction = searchStore.beginReadTransaction();
// Case sensitive query against case insensitive index must lowercase
FilterExpression filter = filterParser.parseFilterExpression("name=ini='*est\tTa*'", ClassType.of(Item.class), false);
Iterable<Object> loaded = testTransaction.loadObjects(EntityProjection.builder().type(Item.class).filterExpression(filter).build(), mockScope);
assertListContains(loaded, Lists.newArrayList(7L));
verify(wrappedTransaction, never()).loadObjects(any(), any());
}
use of com.yahoo.elide.core.datastore.DataStoreTransaction in project elide by yahoo.
the class DataStoreLoadTest method testPrefixPredicateWithInMemoryFiltering.
@Test
public void testPrefixPredicateWithInMemoryFiltering() throws Exception {
DataStoreTransaction testTransaction = searchStore.beginReadTransaction();
testTransaction = new InMemoryStoreTransaction(testTransaction);
// Case sensitive query against case insensitive index must lowercase
FilterExpression filter = filterParser.parseFilterExpression("name==dru*", ClassType.of(Item.class), false);
Iterable<Object> loaded = testTransaction.loadObjects(EntityProjection.builder().type(Item.class).filterExpression(filter).build(), mockScope);
assertListContains(loaded, Lists.newArrayList());
verify(wrappedTransaction, never()).loadObjects(any(), any());
}
Aggregations