use of cz.o2.proxima.direct.transaction.TransactionalCachedView in project proxima-platform by O2-Czech-Republic.
the class DirectDataOperator method getCachedView.
/**
* Retrieve {@link CachedView} for given {@link AttributeDescriptor}s.
*
* @param attrs the attributes to find cached view for
* @return optional cached view
*/
public Optional<CachedView> getCachedView(Collection<AttributeDescriptor<?>> attrs) {
boolean hasTransactions = attrs.stream().anyMatch(a -> a.getTransactionMode() != TransactionMode.NONE);
Optional<CachedView> view = getFamilyForAttributes(attrs, DirectAttributeFamilyDescriptor::hasCachedView).flatMap(DirectAttributeFamilyDescriptor::getCachedView);
if (hasTransactions) {
return view.map(v -> new TransactionalCachedView(this, v));
}
return view;
}
use of cz.o2.proxima.direct.transaction.TransactionalCachedView in project proxima-platform by O2-Czech-Republic.
the class TransactionalCachedViewTest method testInvariants.
@Test
public void testInvariants() {
try (CachedView view = Optionals.get(direct.getCachedView(status, device))) {
Factory factory = view.asFactory();
try (CachedView newView = factory.apply(repo)) {
assertTrue(newView instanceof TransactionalCachedView);
}
assertEquals(Type.ONLINE, view.getType());
assertSame(view, view.online());
}
}
Aggregations