import { XExpressionDefinition } from "../XExpressionDefinition";
import { NumberDataDefinition } from "../../Common/Data/Definitions/NumberDataDefinition";
import { IsTrueExpression } from "../ExpressionElements/Logic/IsTrue";
import { StringLengthExpression } from "../ExpressionElements/String/StringLengthExpression";
import { ExistsExpression } from "../ExpressionElements/Logic/Exists";
import { MultiplyExpression } from "../ExpressionElements/Math/MultiplyExpression";
import { GreaterThanExpression } from "../ExpressionElements/Logic/GreaterThan";
import { IsFalseExpression } from "../ExpressionElements/Logic/IsFalse";
import { NotExpression } from "../ExpressionElements/Logic/Not";
import { IfThenExpression, IfThenStyle } from "../ExpressionElements/Logic/IfThenExpression";
import { LessThanEqualToExpression } from "../ExpressionElements/Logic/LessThanEqualTo";
import { LessThanExpression } from "../ExpressionElements/Logic/LessThan";
import { BooleanDataDefinition } from "../../Common/Data/Definitions/BooleanDataDefinition";
import { ExpressionValueType } from "../ExpressionValueType";
export function getLogicExpressionResultElseIfAtEnd() {
    let exp = new XExpressionDefinition();
    exp.executionResult = new NumberDataDefinition();
    let baseExpression = new IfThenExpression();
    baseExpression.ifThenStyle = IfThenStyle.DATA_RETURN;
    baseExpression.ifBranches[0].ifExpression.elements[0].variableName = "isEmployee";
    let greaterThan = new GreaterThanExpression();
    let strLen = new 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();
    subExpression.value2.value = 10;
    subExpression.value1.variableName = "income";
    baseExpression.trueOutput.subExpression = subExpression;
    // false result
    baseExpression.defaultOutput.value = 0;
    exp.expression = baseExpression;
    return exp;
}
export function getLogicExpressionResultAtEnd() {
    let exp = new XExpressionDefinition();
    exp.executionResult = new NumberDataDefinition();
    let baseExpression = new IfThenExpression();
    baseExpression.ifThenStyle = IfThenStyle.DATA_RETURN;
    baseExpression.ifBranches[0].ifExpression.elements[0].variableName = "isEmployee";
    // true result
    let subExpression = new MultiplyExpression();
    subExpression.value2.value = 10;
    subExpression.value1.variableName = "income";
    baseExpression.trueOutput.subExpression = subExpression;
    // false result
    baseExpression.defaultOutput.value = 0;
    exp.expression = baseExpression;
    return exp;
}
export function getLogicExpressionElseIfElseWithSubWithBlanks() {
    let exp = new XExpressionDefinition();
    exp.executionResult = new NumberDataDefinition();
    let baseExpression = new IfThenExpression();
    let subExpression = new MultiplyExpression();
    baseExpression.ifThenStyle = 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 GreaterThanExpression();
    let strLen = new 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;
}
export function getLogicExpressionElseIfElseWithSub() {
    let exp = new XExpressionDefinition();
    exp.executionResult = new NumberDataDefinition();
    let baseExpression = new IfThenExpression();
    baseExpression.ifThenStyle = IfThenStyle.BRANCH_DATA_RETURN;
    baseExpression.ifBranches[0].ifExpression.elements[0].variableName = "isEmployee";
    let subExpression = new MultiplyExpression();
    subExpression.value2.value = 10;
    subExpression.value1.variableName = "income";
    baseExpression.ifBranches[0].thenExpression.subExpression = subExpression;
    let greaterThan = new GreaterThanExpression();
    let strLen = new 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;
}
export function getLogicExpressionElseIf() {
    let exp = new XExpressionDefinition();
    exp.executionResult = new NumberDataDefinition();
    let baseExpression = new IfThenExpression();
    baseExpression.ifThenStyle = IfThenStyle.BRANCH_DATA_RETURN;
    baseExpression.ifBranches[0].ifExpression.elements[0].variableName = "isEmployee";
    let subExpression = new 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;
}
export function getLogicExpression() {
    let exp = new XExpressionDefinition();
    exp.executionResult = new NumberDataDefinition();
    let baseExpression = new IfThenExpression();
    baseExpression.ifThenStyle = IfThenStyle.BRANCH_DATA_RETURN;
    baseExpression.ifBranches[0].ifExpression.elements[0].variableName = "isEmployee";
    let subExpression = new MultiplyExpression();
    subExpression.value2.value = 10;
    subExpression.value1.variableName = "income";
    baseExpression.ifBranches[0].thenExpression.subExpression = subExpression;
    baseExpression.defaultOutput.value = 0;
    exp.expression = baseExpression;
    return exp;
}
export function getIfSimpleRule() {
    let exp = new XExpressionDefinition();
    exp.executionResult = new BooleanDataDefinition();
    let baseExpression = new IfThenExpression();
    baseExpression.ifThenStyle = IfThenStyle.LOGICAL_RETURN;
    baseExpression.ifBranches[0].ifExpression.elements[0].variableName = "isEmployee";
    exp.expression = baseExpression;
    exp.valueType = ExpressionValueType.SUBEXPRESSION;
    return exp;
}
export function getIfElseSimpleRule() {
    let exp = new XExpressionDefinition();
    exp.executionResult = new NumberDataDefinition();
    let baseExpression = new IfThenExpression();
    baseExpression.ifThenStyle = IfThenStyle.LOGICAL_RETURN;
    baseExpression.ifBranches[0].ifExpression.elements[0].variableName = "isEmployee";
    baseExpression.addIfBranch().ifExpression.elements[0].variableName = "isContractor";
    exp.expression = baseExpression;
    return exp;
}
export function getExistsSimpleRule() {
    let expression;
    expression = new ExistsExpression();
    expression.dataPath = 'test';
    let exp = new XExpressionDefinition();
    exp.expression = expression;
    return exp;
}
export function isFalseSimpleRule() {
    let expression = new IsFalseExpression();
    expression.value1.variableName = "test1";
    let exp = new XExpressionDefinition();
    exp.expression = expression;
    return exp;
}
export function isTrueSimpleRule() {
    let expression = new IsTrueExpression();
    expression.value1.variableName = "test1";
    let exp = new XExpressionDefinition();
    exp.expression = expression;
    return exp;
}
export function lessThanSimpleRule() {
    let expression = new LessThanExpression();
    expression.value1.variableName = "test1";
    expression.value2.variableName = "test2";
    let exp = new XExpressionDefinition();
    exp.expression = expression;
    return exp;
}
export function lessThanEqualToSimpleRule() {
    let expression = new LessThanEqualToExpression();
    expression.value1.variableName = "test1";
    expression.value2.variableName = "test2";
    let exp = new XExpressionDefinition();
    exp.expression = expression;
    return exp;
}
export function notSimpleRule() {
    let expression = new NotExpression();
    expression.value1.variableName = "test1";
    let exp = new XExpressionDefinition();
    exp.expression = expression;
    return exp;
}
//# sourceMappingURL=LogicData.js.map