use of org.whole.lang.bindings.ITransactionScope in project whole by wholeplatform.
the class IEntityIterator method evaluateRemaining.
public default E evaluateRemaining() {
E result = null;
IBindingManager bm = getBindings();
ITransactionScope resettableScope = BindingManagerFactory.instance.createTransactionScope();
bm.wEnterScope(resettableScope);
try {
while (hasNext()) {
bm.setResult(result = next());
resettableScope.commit();
}
} finally {
resettableScope.rollback();
bm.wExitScope();
}
return result;
}
use of org.whole.lang.bindings.ITransactionScope in project whole by wholeplatform.
the class TestsInterpreterVisitor method evaluate.
protected void evaluate(SubjectStatement entity) {
ITransactionScope ts = BindingManagerFactory.instance.createTransactionScope();
getBindings().wEnterScope(ts);
try {
IEntity subject = evaluate(entity.getSubject(), true);
if (!EntityUtils.isNull(subject))
subject = applyFilterRule(subject);
IVisitor constraint = evaluate(entity.getConstraint());
boolean result = Matcher.match(constraint, subject);
if (getBindings().wIsSet("thrownException"))
throw (RuntimeException) getBindings().wGetValue("thrownException");
if (!result)
throw new TestsException(entity, subject, constraint, getBindings());
} finally {
ts.rollback();
getBindings().wExitScope();
}
}
use of org.whole.lang.bindings.ITransactionScope in project whole by wholeplatform.
the class TestCase method evaluate.
protected static IEntity evaluate(IEntity model, boolean rollbackScope, boolean catchExceptions) {
IEntity entity = NullEntity.instance;
RuntimeException thrownException = null;
ITransactionScope ts = BindingManagerFactory.instance.createTransactionScope();
try {
if (rollbackScope)
bindings().wEnterScope(ts);
entity = BehaviorUtils.evaluate(model, 0, bindings());
} catch (RuntimeException e) {
if (catchExceptions)
// save exception for later evaluation
thrownException = e;
else
throw e;
} finally {
if (rollbackScope) {
ts.rollback();
bindings().wExitScope();
}
}
if (thrownException != null)
bindings().wDefValue("thrownException", thrownException);
return entity;
}
use of org.whole.lang.bindings.ITransactionScope in project whole by wholeplatform.
the class FragmentModelTransactionHandler method execute.
@Execute
public void execute(@Named(FRAGMENT_XWL_PARAMETER_ID) String fragmentXwl, @Named(PREDICATE_XWL_PARAMETER_ID) String predicateXwl, @Optional @Named(IServiceConstants.ACTIVE_SELECTION) IBindingManager bm, IEntityPartViewer viewer) throws Exception {
CommandStack commandStack = viewer.getEditDomain().getCommandStack();
ModelTransactionCommand mtc = new ModelTransactionCommand(bm.wGet("focusEntity"));
ITransactionScope ts = BindingManagerFactory.instance.createTransactionScope();
try {
bm.wEnterScope(ts);
defineBindings(fragmentXwl, predicateXwl, bm);
mtc.setLabel(getLabel(bm));
mtc.begin();
run(bm);
mtc.commit();
if (mtc.canUndo())
commandStack.execute(mtc);
} catch (RuntimeException e) {
mtc.rollbackIfNeeded();
throw e;
} finally {
ts.rollback();
bm.wExitScope();
}
}
use of org.whole.lang.bindings.ITransactionScope in project whole by wholeplatform.
the class FragmentModelTransactionHandler method canExecute.
@CanExecute
public boolean canExecute(@Named(FRAGMENT_XWL_PARAMETER_ID) String fragmentXwl, @Named(PREDICATE_XWL_PARAMETER_ID) String predicateXwl, @Optional @Named(IServiceConstants.ACTIVE_SELECTION) IBindingManager bm) throws Exception {
ITransactionScope ts = BindingManagerFactory.instance.createTransactionScope();
try {
bm.wEnterScope(ts);
defineBindings(fragmentXwl, predicateXwl, bm);
return isEnabled(bm);
} catch (Exception e) {
return false;
} finally {
ts.rollback();
bm.wExitScope();
}
}
Aggregations