% ------------------------------------------------------------------------------------------------------
% Demonstrates the use of transactional updates and integrity constraints resp. test cases

% Uses the \ContractLog\ecaruntime.prova implementation of the ContractLog framework
% ------------------------------------------------------------------------------------------------------

:-eval(consult('./ContractLog/math.prova')).
:-eval(consult('./ContractLog/list.prova')).
:-eval(consult('./ContractLog/list_math.prova')).
:-eval(consult('./ContractLog/datetime.prova')).
:-eval(consult('./ContractLog/timeinterval.prova')).
:-eval(consult('./ContractLog/ecaruntime.prova')).
:-eval(consult('./ContractLog/testcase.prova')).
:-eval(consult('./ContractLog/integrity.prova')).
:-eval(consult('./ContractLog/update.prova')).
:-eval(consult('./ContractLog/utils.prova')).


% integrity constraint
integrity(xor(e(),f())).

% transactional update not allowed, because of integrity constraint
:-eval(transaction(add("module1","e(). f()."))). % transactional update + test Integrity
:-solve(f()).

% transactional update from external file is allowed by test case
:-eval(transaction(add("examples/function_tests/transaction/update1.prova"),"examples/function_tests/transaction/transactionTestCase.prova")). % transactional update + test Integrity
:-solve(c()).

% transactional remove not allowed because of test case
:-eval(transaction(remove("examples/function_tests/transaction/update1.prova"),"examples/function_tests/transaction/transactionTestCase.prova")).
:-solve(c()).

