"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTreeRuleExample = exports.getTreeRuleEmpty = void 0;
const BooleanDataDefinition_1 = require("@appglue/common/dist/Common/Data/Definitions/BooleanDataDefinition");
const DateGreaterThanExpression_1 = require("@appglue/common/dist/Expressions/Expressions/Date/DateGreaterThanExpression");
const Exists_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/Exists");
const IsTrue_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/IsTrue");
const NotExpression_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/NotExpression");
const StringContainsExpression_1 = require("@appglue/common/dist/Expressions/Expressions/String/StringContainsExpression");
const TreeRuleConfiguration_1 = require("@appglue/common/dist/Rule/Tree/TreeRuleConfiguration");
const DataDefinition_1 = require("../DataDefinition");
const getTreeRuleEmpty = () => {
    const treeRule = new TreeRuleConfiguration_1.TreeRuleConfiguration();
    treeRule.inputData = (0, DataDefinition_1.getTestInputDataDefinition)();
    return treeRule;
};
exports.getTreeRuleEmpty = getTreeRuleEmpty;
const getTreeRuleExample = () => {
    const treeRule = new TreeRuleConfiguration_1.TreeRuleConfiguration();
    treeRule.inputData = (0, DataDefinition_1.getTestInputDataDefinition)();
    treeRule.executionResult = new BooleanDataDefinition_1.BooleanDataDefinition();
    treeRule.root.setupEvaluation(treeRule.getInputDefinition());
    treeRule.root.expression.variableName = "isManager";
    let node = treeRule.root.trueNode;
    node.setupEvaluation(treeRule.getInputDefinition());
    let notExp = new NotExpression_1.NotExpression();
    let exists = new Exists_1.ExistsExpression();
    exists.dataPath = "disciplinaryActionsHistory";
    notExp.value1.subExpression = exists;
    node.expression.expression = notExp;
    node.falseNode.setupResult(treeRule.getInputDefinition(), treeRule.getRuleResult());
    node.falseNode.expression.value = false;
    node = node.trueNode;
    node.setupEvaluation(treeRule.getInputDefinition());
    let isTrue = new IsTrue_1.IsTrueExpression();
    isTrue.value1.variableName = "fullTime";
    node.expression.expression = isTrue;
    node.falseNode.setupResult(treeRule.getInputDefinition(), treeRule.getRuleResult());
    node.falseNode.expression.value = false;
    node.trueNode.setupResult(treeRule.getInputDefinition(), treeRule.getRuleResult());
    node.trueNode.expression.value = false;
    node = treeRule.root.falseNode;
    node.setupEvaluation(treeRule.getInputDefinition());
    let greaterThan = new DateGreaterThanExpression_1.DateGreaterThanExpression();
    greaterThan.value1.variableName = "dateOfHire";
    greaterThan.value2.value = "2019-01-01T00:00";
    node.expression.expression = greaterThan;
    node.trueNode.setupResult(treeRule.getInputDefinition(), treeRule.getRuleResult());
    node.trueNode.expression.value = true;
    node = node.falseNode;
    node.setupEvaluation(treeRule.getInputDefinition());
    notExp = new NotExpression_1.NotExpression();
    exists = new Exists_1.ExistsExpression();
    exists.dataPath = "disciplinaryActionsHistory";
    notExp.value1.subExpression = exists;
    node.expression.expression = notExp;
    node.trueNode.setupResult(treeRule.getInputDefinition(), treeRule.getRuleResult());
    node.trueNode.expression.value = true;
    node = node.falseNode;
    node.setupEvaluation(treeRule.getInputDefinition());
    let containExpression = new StringContainsExpression_1.StringContainsExpression();
    containExpression.value1.variableName = "salaryBand";
    containExpression.value2.value = "45C";
    node.expression.expression = containExpression;
    node.falseNode.setupResult(treeRule.getInputDefinition(), treeRule.getRuleResult());
    node.falseNode.expression.value = true;
    node = node.trueNode;
    node.setupEvaluation(treeRule.getInputDefinition());
    isTrue = new IsTrue_1.IsTrueExpression();
    isTrue.value1.variableName = "fullTime";
    node.expression.expression = isTrue;
    node.falseNode.setupResult(treeRule.getInputDefinition(), treeRule.getRuleResult());
    node.falseNode.expression.value = false;
    node.trueNode.setupResult(treeRule.getInputDefinition(), treeRule.getRuleResult());
    node.trueNode.expression.value = true;
    return treeRule;
};
exports.getTreeRuleExample = getTreeRuleExample;
//# sourceMappingURL=Tree.js.map