"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRuleTableExample = exports.getRuleTableEmpty = void 0;
const StringDataDefinition_1 = require("@appglue/common/dist/Common/Data/Definitions/StringDataDefinition");
const DataDefinition_1 = require("@appglue/common/dist/Common/Data/DataDefinition");
const DataDefinition_2 = require("../../DataDefinition");
const RuleTableConfiguration_1 = require("@appglue/common/dist/Rule/Table/Rule/RuleTableConfiguration");
const GreaterThan_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/GreaterThan");
const IsFalse_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/IsFalse");
const LessThanExpression_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/LessThanExpression");
const DivideExpression_1 = require("@appglue/common/dist/Expressions/Expressions/Math/DivideExpression");
const AddExpression_1 = require("@appglue/common/dist/Expressions/Expressions/Math/AddExpression");
const AndGroup_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/AndGroup");
const IsTrue_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/IsTrue");
const NotExpression_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/NotExpression");
const Exists_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/Exists");
const GreaterThanEqualTo_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/GreaterThanEqualTo");
const getRuleTableEmpty = () => {
    const ruleDefinition = new RuleTableConfiguration_1.RuleTableConfiguration();
    ruleDefinition.inputData = (0, DataDefinition_2.getTestInputDataDefinition)();
    return ruleDefinition;
};
exports.getRuleTableEmpty = getRuleTableEmpty;
const getRuleTableExample = () => {
    const ruleDefinition = new RuleTableConfiguration_1.RuleTableConfiguration();
    ruleDefinition.inputData = (0, DataDefinition_2.getTestInputDataDefinition)();
    ruleDefinition.executionResult = new DataDefinition_1.DataDefinition();
    ruleDefinition.setRuleColumn(ruleDefinition.ruleColumns[0], "vacationDaysRemaining");
    ruleDefinition.addRuleColumn();
    ruleDefinition.setRuleColumn(ruleDefinition.ruleColumns[1], "isManager");
    ruleDefinition.addRuleColumn();
    ruleDefinition.setRuleColumn(ruleDefinition.ruleColumns[2], "vacationDaysUsed");
    ruleDefinition.addRuleColumn();
    ruleDefinition.setRuleColumn(ruleDefinition.ruleColumns[3], "fullTime");
    ruleDefinition.setResultColumnType(ruleDefinition.resultColumns[0], new StringDataDefinition_1.StringDataDefinition("result_2"));
    ruleDefinition.addRow();
    ruleDefinition.addRow();
    ruleDefinition.addRow();
    ruleDefinition.addRow();
    ruleDefinition.addRow();
    ruleDefinition.addRow();
    // first row
    let greaterThan = new GreaterThan_1.GreaterThanExpression();
    greaterThan.value1.variableName = "vacationDaysRemaining";
    greaterThan.value2.value = 0;
    ruleDefinition.rows[0].cells[0].expression.expression = greaterThan;
    let isFalse = new IsFalse_1.IsFalseExpression();
    isFalse.value1.variableName = "isManager";
    ruleDefinition.rows[0].cells[1].expression.expression = isFalse;
    let lessThan = new LessThanExpression_1.LessThanExpression();
    let divide = new DivideExpression_1.DivideExpression();
    divide.divideValue.variableName = "vacationDaysUsed";
    let add = new AddExpression_1.AddExpression();
    add.value1.variableName = "vacationDaysUsed";
    add.value2.variableName = "vacationDaysRemaining";
    divide.divideBy.subExpression = add;
    lessThan.value1.subExpression = divide;
    lessThan.value2.value = 0.6;
    ruleDefinition.rows[0].cells[2].expression.expression = lessThan;
    let andExp = new AndGroup_1.AndGroup();
    let isTrue = new IsTrue_1.IsTrueExpression();
    isTrue.value1.variableName = "fullTime";
    andExp.elements[0].subExpression = isTrue;
    andExp.add();
    let notExp = new NotExpression_1.NotExpression();
    let exists = new Exists_1.ExistsExpression();
    exists.dataPath = "disciplinaryActionsHistory";
    notExp.value1.subExpression = exists;
    andExp.elements[1].subExpression = notExp;
    ruleDefinition.rows[0].cells[3].expression.expression = andExp;
    greaterThan = new GreaterThan_1.GreaterThanExpression();
    greaterThan.value1.variableName = "vacationDaysRemaining";
    greaterThan.value2.value = 0;
    // second row
    ruleDefinition.rows[1].cells[0].expression.expression = greaterThan;
    isFalse = new IsFalse_1.IsFalseExpression();
    isFalse.value1.variableName = "isManager";
    ruleDefinition.rows[1].cells[1].expression.expression = isFalse;
    lessThan = new LessThanExpression_1.LessThanExpression();
    divide = new DivideExpression_1.DivideExpression();
    divide.divideValue.variableName = "vacationDaysUsed";
    add = new AddExpression_1.AddExpression();
    add.value1.variableName = "vacationDaysUsed";
    add.value2.variableName = "vacationDaysRemaining";
    divide.divideBy.subExpression = add;
    lessThan.value1.subExpression = divide;
    lessThan.value2.value = 0.6;
    ruleDefinition.rows[1].cells[2].expression.expression = lessThan;
    andExp = new AndGroup_1.AndGroup();
    isFalse = new IsFalse_1.IsFalseExpression();
    isFalse.value1.variableName = "fullTime";
    andExp.elements[0].subExpression = isFalse;
    andExp.add();
    notExp = new NotExpression_1.NotExpression();
    exists = new Exists_1.ExistsExpression();
    exists.dataPath = "disciplinaryActionsHistory";
    notExp.value1.subExpression = exists;
    andExp.elements[1].subExpression = notExp;
    ruleDefinition.rows[1].cells[3].expression.expression = andExp;
    // thrid row
    ruleDefinition.rows[2].cells[0].expression.expression = greaterThan;
    isFalse = new IsFalse_1.IsFalseExpression();
    isFalse.value1.variableName = "isManager";
    ruleDefinition.rows[2].cells[1].expression.expression = isFalse;
    lessThan = new LessThanExpression_1.LessThanExpression();
    divide = new DivideExpression_1.DivideExpression();
    divide.divideValue.variableName = "vacationDaysUsed";
    add = new AddExpression_1.AddExpression();
    add.value1.variableName = "vacationDaysUsed";
    add.value2.variableName = "vacationDaysRemaining";
    divide.divideBy.subExpression = add;
    lessThan.value1.subExpression = divide;
    lessThan.value2.value = 0.8;
    ruleDefinition.rows[2].cells[2].expression.expression = lessThan;
    andExp = new AndGroup_1.AndGroup();
    isTrue = new IsTrue_1.IsTrueExpression();
    isTrue.value1.variableName = "fullTime";
    andExp.elements[0].subExpression = isTrue;
    andExp.add();
    notExp = new NotExpression_1.NotExpression();
    exists = new Exists_1.ExistsExpression();
    exists.dataPath = "disciplinaryActionsHistory";
    notExp.value1.subExpression = exists;
    andExp.elements[1].subExpression = notExp;
    ruleDefinition.rows[2].cells[3].expression.expression = andExp;
    // fourth
    ruleDefinition.rows[3].cells[0].expression.expression = greaterThan;
    isFalse = new IsFalse_1.IsFalseExpression();
    isFalse.value1.variableName = "isManager";
    ruleDefinition.rows[3].cells[1].expression.expression = isFalse;
    lessThan = new LessThanExpression_1.LessThanExpression();
    divide = new DivideExpression_1.DivideExpression();
    divide.divideValue.variableName = "vacationDaysUsed";
    add = new AddExpression_1.AddExpression();
    add.value1.variableName = "vacationDaysUsed";
    add.value2.variableName = "vacationDaysRemaining";
    divide.divideBy.subExpression = add;
    lessThan.value1.subExpression = divide;
    lessThan.value2.value = 0.8;
    ruleDefinition.rows[3].cells[2].expression.expression = lessThan;
    andExp = new AndGroup_1.AndGroup();
    isFalse = new IsFalse_1.IsFalseExpression();
    isFalse.value1.variableName = "fullTime";
    andExp.elements[0].subExpression = isFalse;
    andExp.add();
    notExp = new NotExpression_1.NotExpression();
    exists = new Exists_1.ExistsExpression();
    exists.dataPath = "disciplinaryActionsHistory";
    notExp.value1.subExpression = exists;
    andExp.elements[1].subExpression = notExp;
    ruleDefinition.rows[3].cells[3].expression.expression = andExp;
    // fifth row
    ruleDefinition.rows[4].cells[0].expression.expression = greaterThan;
    isFalse = new IsFalse_1.IsFalseExpression();
    isFalse.value1.variableName = "isManager";
    ruleDefinition.rows[4].cells[1].expression.expression = isFalse;
    divide = new DivideExpression_1.DivideExpression();
    divide.divideValue.variableName = "vacationDaysUsed";
    add = new AddExpression_1.AddExpression();
    add.value1.variableName = "vacationDaysUsed";
    add.value2.variableName = "vacationDaysRemaining";
    divide.divideBy.subExpression = add;
    let greaterThanEqual = new GreaterThanEqualTo_1.GreaterThanEqualToExpression();
    greaterThanEqual.value1.subExpression = divide;
    greaterThanEqual.value2.value = 0.8;
    ruleDefinition.rows[4].cells[2].expression.expression = greaterThanEqual;
    andExp = new AndGroup_1.AndGroup();
    isTrue = new IsTrue_1.IsTrueExpression();
    isTrue.value1.variableName = "fullTime";
    andExp.elements[0].subExpression = isTrue;
    andExp.add();
    notExp = new NotExpression_1.NotExpression();
    exists = new Exists_1.ExistsExpression();
    exists.dataPath = "disciplinaryActionsHistory";
    notExp.value1.subExpression = exists;
    andExp.elements[1].subExpression = notExp;
    ruleDefinition.rows[4].cells[3].expression.expression = andExp;
    // sixth
    greaterThan = new GreaterThan_1.GreaterThanExpression();
    greaterThan.value1.variableName = "vacationDaysRemaining";
    greaterThan.value2.value = 0;
    ruleDefinition.rows[5].cells[0].expression.expression = greaterThan;
    isTrue = new IsTrue_1.IsTrueExpression();
    isTrue.value1.variableName = "isManager";
    ruleDefinition.rows[5].cells[1].expression.expression = isTrue;
    lessThan = new LessThanExpression_1.LessThanExpression();
    divide = new DivideExpression_1.DivideExpression();
    divide.divideValue.variableName = "vacationDaysUsed";
    add = new AddExpression_1.AddExpression();
    add.value1.variableName = "vacationDaysUsed";
    add.value2.variableName = "vacationDaysRemaining";
    divide.divideBy.subExpression = add;
    lessThan.value1.subExpression = divide;
    lessThan.value2.value = 0.6;
    ruleDefinition.rows[5].cells[2].expression.expression = lessThan;
    andExp = new AndGroup_1.AndGroup();
    isTrue = new IsTrue_1.IsTrueExpression();
    isTrue.value1.variableName = "fullTime";
    andExp.elements[0].subExpression = isTrue;
    andExp.add();
    notExp = new NotExpression_1.NotExpression();
    exists = new Exists_1.ExistsExpression();
    exists.dataPath = "disciplinaryActionsHistory";
    notExp.value1.subExpression = exists;
    andExp.elements[1].subExpression = notExp;
    ruleDefinition.rows[5].cells[3].expression.expression = andExp;
    greaterThan = new GreaterThan_1.GreaterThanExpression();
    greaterThan.value1.variableName = "vacationDaysRemaining";
    greaterThan.value2.value = 0;
    // seventh
    greaterThan = new GreaterThan_1.GreaterThanExpression();
    greaterThan.value1.variableName = "vacationDaysRemaining";
    greaterThan.value2.value = 0;
    ruleDefinition.rows[6].cells[0].expression.expression = greaterThan;
    isTrue = new IsTrue_1.IsTrueExpression();
    isTrue.value1.variableName = "isManager";
    ruleDefinition.rows[6].cells[1].expression.expression = isTrue;
    divide = new DivideExpression_1.DivideExpression();
    divide.divideValue.variableName = "vacationDaysUsed";
    add = new AddExpression_1.AddExpression();
    add.value1.variableName = "vacationDaysUsed";
    add.value2.variableName = "vacationDaysRemaining";
    divide.divideBy.subExpression = add;
    greaterThanEqual = new GreaterThanEqualTo_1.GreaterThanEqualToExpression();
    greaterThanEqual.value1.subExpression = divide;
    greaterThanEqual.value2.value = 0.6;
    ruleDefinition.rows[6].cells[2].expression.expression = greaterThanEqual;
    andExp = new AndGroup_1.AndGroup();
    isFalse = new IsFalse_1.IsFalseExpression();
    isFalse.value1.variableName = "fullTime";
    andExp.elements[0].subExpression = isFalse;
    andExp.add();
    notExp = new NotExpression_1.NotExpression();
    exists = new Exists_1.ExistsExpression();
    exists.dataPath = "disciplinaryActionsHistory";
    notExp.value1.subExpression = exists;
    andExp.elements[1].subExpression = notExp;
    ruleDefinition.rows[6].cells[3].expression.expression = andExp;
    greaterThan = new GreaterThan_1.GreaterThanExpression();
    greaterThan.value1.variableName = "vacationDaysRemaining";
    greaterThan.value2.value = 0;
    ruleDefinition.rows[0].resultCells[0].value = "Auto-Approve";
    ruleDefinition.rows[1].resultCells[0].value = "Approve with ";
    ruleDefinition.rows[2].resultCells[0].value = "Manual Approve";
    ruleDefinition.rows[3].resultCells[0].value = "Reject";
    ruleDefinition.rows[4].resultCells[0].value = "Reject";
    ruleDefinition.rows[5].resultCells[0].value = "Auto-Approve";
    ruleDefinition.rows[6].resultCells[0].value = "Manual-Approve";
    ruleDefinition.getDefaultResultByOrder(0).value = "Manual Approve";
    return ruleDefinition;
};
exports.getRuleTableExample = getRuleTableExample;
//# sourceMappingURL=RuleTable.js.map