"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.notSimpleRule = exports.lessThanEqualToSimpleRule = exports.lessThanSimpleRule = exports.isTrueSimpleRule = exports.isFalseSimpleRule = exports.getExistsSimpleRule = exports.getIfElseSimpleRule = exports.getIfSimpleRule = exports.getLogicExpression = exports.getLogicExpressionElseIf = exports.getLogicExpressionElseIfElseWithSub = exports.getLogicExpressionElseIfElseWithSubWithBlanks = exports.getLogicExpressionResultAtEnd = exports.getLogicExpressionResultElseIfAtEnd = void 0;
const ExpressionConfiguration_1 = require("@appglue/common/dist/Expressions/ExpressionConfiguration");
const NumberDataDefinition_1 = require("@appglue/common/dist/Common/Data/Definitions/NumberDataDefinition");
const IsTrue_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/IsTrue");
const StringLengthExpression_1 = require("@appglue/common/dist/Expressions/Expressions/String/StringLengthExpression");
const Exists_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/Exists");
const MultiplyExpression_1 = require("@appglue/common/dist/Expressions/Expressions/Math/MultiplyExpression");
const GreaterThan_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/GreaterThan");
const IsFalse_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/IsFalse");
const NotExpression_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/NotExpression");
const IfThenExpression_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/IfThenExpression");
const LessThanEqualToExpression_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/LessThanEqualToExpression");
const LessThanExpression_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/LessThanExpression");
const BooleanDataDefinition_1 = require("@appglue/common/dist/Common/Data/Definitions/BooleanDataDefinition");
const ExpressionValueType_1 = require("@appglue/common/dist/Expressions/ExpressionValueType");
function getLogicExpressionResultElseIfAtEnd() {
    let exp = new ExpressionConfiguration_1.ExpressionConfiguration();
    exp.executionResult = new NumberDataDefinition_1.NumberDataDefinition();
    let baseExpression = new IfThenExpression_1.IfThenExpression();
    baseExpression.ifThenStyle = IfThenExpression_1.IfThenStyle.DATA_RETURN;
    baseExpression.ifBranches[0].ifExpression.elements[0].variableName = "isEmployee";
    let greaterThan = new GreaterThan_1.GreaterThanExpression();
    let strLen = new StringLengthExpression_1.StringLengthExpression();
    strLen.value1.variableName = "person.name";
    greaterThan.value1.subExpression = strLen;
    greaterThan.value2.value = 5;
    let secondIf = baseExpression.addIfBranch();
    secondIf.ifExpression.elements[0].subExpression = greaterThan;
    secondIf.thenExpression.value = 20;
    // true result
    let subExpression = new MultiplyExpression_1.MultiplyExpression();
    subExpression.value2.value = 10;
    subExpression.value1.variableName = "income";
    baseExpression.trueOutput.subExpression = subExpression;
    // false result
    baseExpression.defaultOutput.value = 0;
    exp.expression = baseExpression;
    return exp;
}
exports.getLogicExpressionResultElseIfAtEnd = getLogicExpressionResultElseIfAtEnd;
function getLogicExpressionResultAtEnd() {
    let exp = new ExpressionConfiguration_1.ExpressionConfiguration();
    exp.executionResult = new NumberDataDefinition_1.NumberDataDefinition();
    let baseExpression = new IfThenExpression_1.IfThenExpression();
    baseExpression.ifThenStyle = IfThenExpression_1.IfThenStyle.DATA_RETURN;
    baseExpression.ifBranches[0].ifExpression.elements[0].variableName = "isEmployee";
    // true result
    let subExpression = new MultiplyExpression_1.MultiplyExpression();
    subExpression.value2.value = 10;
    subExpression.value1.variableName = "income";
    baseExpression.trueOutput.subExpression = subExpression;
    // false result
    baseExpression.defaultOutput.value = 0;
    exp.expression = baseExpression;
    return exp;
}
exports.getLogicExpressionResultAtEnd = getLogicExpressionResultAtEnd;
function getLogicExpressionElseIfElseWithSubWithBlanks() {
    let exp = new ExpressionConfiguration_1.ExpressionConfiguration();
    exp.executionResult = new NumberDataDefinition_1.NumberDataDefinition();
    let baseExpression = new IfThenExpression_1.IfThenExpression();
    let subExpression = new MultiplyExpression_1.MultiplyExpression();
    baseExpression.ifThenStyle = IfThenExpression_1.IfThenStyle.BRANCH_DATA_RETURN;
    baseExpression.ifBranches[0].ifExpression.elements[0].variableName = "isEmployee";
    // *** Left Null
    //    subExpression.value2.value = 10;
    subExpression.value1.variableName = "income";
    baseExpression.ifBranches[0].thenExpression.subExpression = subExpression;
    let greaterThan = new GreaterThan_1.GreaterThanExpression();
    let strLen = new StringLengthExpression_1.StringLengthExpression();
    strLen.value1.variableName = "person.name";
    greaterThan.value1.subExpression = strLen;
    greaterThan.value2.value = 5;
    let secondIf = baseExpression.addIfBranch();
    secondIf.ifExpression.elements[0].subExpression = greaterThan;
    secondIf.thenExpression.value = 1000;
    // *** Left Null
    //    baseExpression.defaultOutput.value = 0;
    exp.expression = baseExpression;
    return exp;
}
exports.getLogicExpressionElseIfElseWithSubWithBlanks = getLogicExpressionElseIfElseWithSubWithBlanks;
function getLogicExpressionElseIfElseWithSub() {
    let exp = new ExpressionConfiguration_1.ExpressionConfiguration();
    exp.executionResult = new NumberDataDefinition_1.NumberDataDefinition();
    let baseExpression = new IfThenExpression_1.IfThenExpression();
    baseExpression.ifThenStyle = IfThenExpression_1.IfThenStyle.BRANCH_DATA_RETURN;
    baseExpression.ifBranches[0].ifExpression.elements[0].variableName = "isEmployee";
    let subExpression = new MultiplyExpression_1.MultiplyExpression();
    subExpression.value2.value = 10;
    subExpression.value1.variableName = "income";
    baseExpression.ifBranches[0].thenExpression.subExpression = subExpression;
    let greaterThan = new GreaterThan_1.GreaterThanExpression();
    let strLen = new StringLengthExpression_1.StringLengthExpression();
    strLen.value1.variableName = "person.name";
    greaterThan.value1.subExpression = strLen;
    greaterThan.value2.value = 5;
    let secondIf = baseExpression.addIfBranch();
    secondIf.ifExpression.elements[0].subExpression = greaterThan;
    secondIf.thenExpression.value = 1000;
    baseExpression.defaultOutput.value = 0;
    exp.expression = baseExpression;
    return exp;
}
exports.getLogicExpressionElseIfElseWithSub = getLogicExpressionElseIfElseWithSub;
function getLogicExpressionElseIf() {
    let exp = new ExpressionConfiguration_1.ExpressionConfiguration();
    exp.executionResult = new NumberDataDefinition_1.NumberDataDefinition();
    let baseExpression = new IfThenExpression_1.IfThenExpression();
    baseExpression.ifThenStyle = IfThenExpression_1.IfThenStyle.BRANCH_DATA_RETURN;
    baseExpression.ifBranches[0].ifExpression.elements[0].variableName = "isEmployee";
    let subExpression = new MultiplyExpression_1.MultiplyExpression();
    subExpression.value2.value = 10;
    subExpression.value1.variableName = "income";
    baseExpression.ifBranches[0].thenExpression.subExpression = subExpression;
    let second = baseExpression.addIfBranch();
    second.ifExpression.elements[0].variableName = "isContractor";
    second.thenExpression.value = 1000;
    baseExpression.defaultOutput.value = 0;
    exp.expression = baseExpression;
    return exp;
}
exports.getLogicExpressionElseIf = getLogicExpressionElseIf;
function getLogicExpression() {
    let exp = new ExpressionConfiguration_1.ExpressionConfiguration();
    exp.executionResult = new NumberDataDefinition_1.NumberDataDefinition();
    let baseExpression = new IfThenExpression_1.IfThenExpression();
    baseExpression.ifThenStyle = IfThenExpression_1.IfThenStyle.BRANCH_DATA_RETURN;
    baseExpression.ifBranches[0].ifExpression.elements[0].variableName = "isEmployee";
    let subExpression = new MultiplyExpression_1.MultiplyExpression();
    subExpression.value2.value = 10;
    subExpression.value1.variableName = "income";
    baseExpression.ifBranches[0].thenExpression.subExpression = subExpression;
    baseExpression.defaultOutput.value = 0;
    exp.expression = baseExpression;
    return exp;
}
exports.getLogicExpression = getLogicExpression;
function getIfSimpleRule() {
    let exp = new ExpressionConfiguration_1.ExpressionConfiguration();
    exp.executionResult = new BooleanDataDefinition_1.BooleanDataDefinition();
    let baseExpression = new IfThenExpression_1.IfThenExpression();
    baseExpression.ifThenStyle = IfThenExpression_1.IfThenStyle.LOGICAL_RETURN;
    baseExpression.ifBranches[0].ifExpression.elements[0].variableName = "isEmployee";
    exp.expression = baseExpression;
    exp.valueType = ExpressionValueType_1.ExpressionValueType.SUBEXPRESSION;
    return exp;
}
exports.getIfSimpleRule = getIfSimpleRule;
function getIfElseSimpleRule() {
    let exp = new ExpressionConfiguration_1.ExpressionConfiguration();
    exp.executionResult = new NumberDataDefinition_1.NumberDataDefinition();
    let baseExpression = new IfThenExpression_1.IfThenExpression();
    baseExpression.ifThenStyle = IfThenExpression_1.IfThenStyle.LOGICAL_RETURN;
    baseExpression.ifBranches[0].ifExpression.elements[0].variableName = "isEmployee";
    baseExpression.addIfBranch().ifExpression.elements[0].variableName = "isContractor";
    exp.expression = baseExpression;
    return exp;
}
exports.getIfElseSimpleRule = getIfElseSimpleRule;
function getExistsSimpleRule() {
    let expression;
    expression = new Exists_1.ExistsExpression();
    expression.dataPath = "test";
    let exp = new ExpressionConfiguration_1.ExpressionConfiguration();
    exp.expression = expression;
    return exp;
}
exports.getExistsSimpleRule = getExistsSimpleRule;
function isFalseSimpleRule() {
    let expression = new IsFalse_1.IsFalseExpression();
    expression.value1.variableName = "test1";
    let exp = new ExpressionConfiguration_1.ExpressionConfiguration();
    exp.expression = expression;
    return exp;
}
exports.isFalseSimpleRule = isFalseSimpleRule;
function isTrueSimpleRule() {
    let expression = new IsTrue_1.IsTrueExpression();
    expression.value1.variableName = "test1";
    let exp = new ExpressionConfiguration_1.ExpressionConfiguration();
    exp.expression = expression;
    return exp;
}
exports.isTrueSimpleRule = isTrueSimpleRule;
function lessThanSimpleRule() {
    let expression = new LessThanExpression_1.LessThanExpression();
    expression.value1.variableName = "test1";
    expression.value2.variableName = "test2";
    let exp = new ExpressionConfiguration_1.ExpressionConfiguration();
    exp.expression = expression;
    return exp;
}
exports.lessThanSimpleRule = lessThanSimpleRule;
function lessThanEqualToSimpleRule() {
    let expression = new LessThanEqualToExpression_1.LessThanEqualToExpression();
    expression.value1.variableName = "test1";
    expression.value2.variableName = "test2";
    let exp = new ExpressionConfiguration_1.ExpressionConfiguration();
    exp.expression = expression;
    return exp;
}
exports.lessThanEqualToSimpleRule = lessThanEqualToSimpleRule;
function notSimpleRule() {
    let expression = new NotExpression_1.NotExpression();
    expression.value1.variableName = "test1";
    let exp = new ExpressionConfiguration_1.ExpressionConfiguration();
    exp.expression = expression;
    return exp;
}
exports.notSimpleRule = notSimpleRule;
//# sourceMappingURL=LogicData.js.map