Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- asyncTest("BizLogic switch with default case and next operation", function() {
- var logic = new apv.BizLogic();
- logic.variables.push(new apv.Variable({ name: "var1", parameter: true }));
- logic.variables.push(new apv.Variable({ name: "var2", parameter: false }));
- logic.calls = [
- new apv.Switch({
- expr: "test",
- cases: [
- {
- value: true,
- valueType: "boolean",
- calls: [new apv.Event(apv.Flow.Return, false)]
- },
- {
- value: false,
- valueType: "boolean",
- calls: [new apv.Event(apv.Flow.Return, false)]
- }
- ],
- otherwise: [new apv.SetValue({ variableName: "var2", valueExpr: true })]
- }),
- new apv.Event({ flow: apv.Flow.Return, returnExpr: "var2" })
- ];
- var compiler = new apv.BizLogicCompiler(logic);
- var promise = compiler.run({ test: { name: "test", value: null } });
- promise.done(function(result) {
- equal(result, true);
- start();
- });
- });
- export class BizLogicCompiler {
- private functions: any;
- logic: BizLogic;
- constructor(logic: BizLogic, functions?: any) {
- this.functions = functions;
- this.logic = logic;
- }
- run(params: { [key: string]: any }): JQueryPromise<any> {
- var variables: { [key: string]: any } = {};
- this.logic.variables.forEach(variable => {
- var value = variable.parameter ? params[variable.name] : variable;
- variables[variable.name] = value;
- });
- return this.logic.run(variables, this.functions);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement