"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getValueTableExample = exports.getValueTableEmpty = void 0;
const BooleanDataDefinition_1 = require("@appglue/common/dist/Common/Data/Definitions/BooleanDataDefinition");
const NumberDataDefinition_1 = require("@appglue/common/dist/Common/Data/Definitions/NumberDataDefinition");
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 GreaterThan_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/GreaterThan");
const SubstractExpression_1 = require("@appglue/common/dist/Expressions/Expressions/Math/SubstractExpression");
const DateGetYearExpression_1 = require("@appglue/common/dist/Expressions/Expressions/Date/DateGetYearExpression");
const DateGetTodayExpression_1 = require("@appglue/common/dist/Expressions/Expressions/Date/DateGetTodayExpression");
const IfThenExpression_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/IfThenExpression");
const NotExpression_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/NotExpression");
const Exists_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/Exists");
const StringContainsExpression_1 = require("@appglue/common/dist/Expressions/Expressions/String/StringContainsExpression");
const IsTrue_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/IsTrue");
const ValueRuleCell_1 = require("@appglue/common/dist/Rule/Table/Value/Structure/ValueRuleCell");
const ValueTableConfiguration_1 = require("@appglue/common/dist/Rule/Table/Value/ValueTableConfiguration");
const getValueTableEmpty = () => {
    const valueRuleDefinition = new ValueTableConfiguration_1.ValueTableConfiguration();
    valueRuleDefinition.inputData = (0, DataDefinition_2.getTestInputDataDefinition)();
    return valueRuleDefinition;
};
exports.getValueTableEmpty = getValueTableEmpty;
const getValueTableExample = () => {
    const valueRuleDefinition = new ValueTableConfiguration_1.ValueTableConfiguration();
    valueRuleDefinition.inputData = (0, DataDefinition_2.getTestInputDataDefinition)();
    valueRuleDefinition.executionResult = new DataDefinition_1.DataDefinition();
    let greaterThan = new GreaterThan_1.GreaterThanExpression();
    let subExp = new SubstractExpression_1.SubstractExpression();
    greaterThan.value1.subExpression = subExp;
    let getyearExp = new DateGetYearExpression_1.DateGetYearExpression();
    let getToday = new DateGetTodayExpression_1.DateGetTodayExpression();
    getyearExp.value1.subExpression = getToday;
    subExp.value1.subExpression = getyearExp;
    getyearExp = new DateGetYearExpression_1.DateGetYearExpression();
    getyearExp.value1.variableName = "dateOfHire";
    subExp.value2.subExpression = getyearExp;
    greaterThan.value2.variableName = "cellValue";
    valueRuleDefinition.columns[0].expression.expression = greaterThan;
    valueRuleDefinition.setRuleColumnType(valueRuleDefinition.columns[0], new NumberDataDefinition_1.NumberDataDefinition("cellValue"));
    valueRuleDefinition.addColumn();
    let ifThen = new IfThenExpression_1.IfThenExpression();
    let notExp = new NotExpression_1.NotExpression();
    let exists = new Exists_1.ExistsExpression();
    exists.dataPath = "promotionHistory";
    notExp.value1.subExpression = exists;
    ifThen.ifBranches[0].ifExpression.elements[0].subExpression = notExp;
    ifThen.ifBranches[0].ifExpression.add();
    exists = new Exists_1.ExistsExpression();
    exists.dataPath = "disciplinaryActionsHistory";
    ifThen.ifBranches[0].ifExpression.elements[1].subExpression = exists;
    ifThen.trueOutput.variableName = "cellValue";
    ifThen.defaultOutput.variableName = "cellValue";
    valueRuleDefinition.columns[1].expression.expression = ifThen;
    valueRuleDefinition.setRuleColumnType(valueRuleDefinition.columns[1], new BooleanDataDefinition_1.BooleanDataDefinition("cellValue"));
    valueRuleDefinition.addColumn();
    ifThen = new IfThenExpression_1.IfThenExpression();
    let isTrue = new IsTrue_1.IsTrueExpression();
    isTrue.value1.variableName = "isManager";
    ifThen.ifBranches[0].ifExpression.elements[0].subExpression = isTrue;
    ifThen.trueOutput.variableName = "cellValue";
    ifThen.defaultOutput.variableName = "cellValue";
    valueRuleDefinition.columns[2].expression.expression = ifThen;
    valueRuleDefinition.setRuleColumnType(valueRuleDefinition.columns[2], new BooleanDataDefinition_1.BooleanDataDefinition("cellValue"));
    valueRuleDefinition.addColumn();
    let containsExp = new StringContainsExpression_1.StringContainsExpression();
    containsExp.value1.variableName = "salaryBand";
    containsExp.value2.variableName = "cellValue";
    valueRuleDefinition.columns[3].expression.expression = containsExp;
    valueRuleDefinition.addRow();
    valueRuleDefinition.addRow();
    valueRuleDefinition.addRow();
    valueRuleDefinition.addRow();
    valueRuleDefinition.addRow();
    valueRuleDefinition.addRow();
    valueRuleDefinition.addRow();
    valueRuleDefinition.addRow();
    valueRuleDefinition.rows[0].cells[0].values = 2;
    valueRuleDefinition.rows[1].cells[0].values = 2;
    valueRuleDefinition.rows[2].cells[0].values = 2;
    valueRuleDefinition.rows[3].cells[0].values = 2;
    valueRuleDefinition.rows[4].cells[0].values = 2;
    valueRuleDefinition.rows[5].cells[0].values = 2;
    valueRuleDefinition.rows[6].cells[0].values = ValueRuleCell_1.ValueRuleCell.IGNORE_CELL_VALUE;
    valueRuleDefinition.rows[7].cells[0].values = ValueRuleCell_1.ValueRuleCell.IGNORE_CELL_VALUE;
    valueRuleDefinition.rows[8].cells[0].values = ValueRuleCell_1.ValueRuleCell.IGNORE_CELL_VALUE;
    valueRuleDefinition.rows[0].cells[1].values = true;
    valueRuleDefinition.rows[1].cells[1].values = true;
    valueRuleDefinition.rows[2].cells[1].values = true;
    valueRuleDefinition.rows[3].cells[1].values = false;
    valueRuleDefinition.rows[4].cells[1].values = true;
    valueRuleDefinition.rows[5].cells[1].values = false;
    valueRuleDefinition.rows[6].cells[1].values = true;
    valueRuleDefinition.rows[7].cells[1].values = true;
    valueRuleDefinition.rows[8].cells[1].values = false;
    valueRuleDefinition.rows[0].cells[2].values = true;
    valueRuleDefinition.rows[1].cells[2].values = false;
    valueRuleDefinition.rows[2].cells[2].values = ValueRuleCell_1.ValueRuleCell.IGNORE_CELL_VALUE;
    valueRuleDefinition.rows[3].cells[2].values = ValueRuleCell_1.ValueRuleCell.IGNORE_CELL_VALUE;
    valueRuleDefinition.rows[4].cells[2].values = ValueRuleCell_1.ValueRuleCell.IGNORE_CELL_VALUE;
    valueRuleDefinition.rows[5].cells[2].values = ValueRuleCell_1.ValueRuleCell.IGNORE_CELL_VALUE;
    valueRuleDefinition.rows[6].cells[2].values = true;
    valueRuleDefinition.rows[7].cells[2].values = true;
    valueRuleDefinition.rows[8].cells[2].values = false;
    valueRuleDefinition.rows[0].cells[3].values = "AC";
    valueRuleDefinition.rows[1].cells[3].values = "AC";
    valueRuleDefinition.rows[2].cells[3].values = "AE";
    valueRuleDefinition.rows[3].cells[3].values = ValueRuleCell_1.ValueRuleCell.IGNORE_CELL_VALUE;
    valueRuleDefinition.rows[4].cells[3].values = ValueRuleCell_1.ValueRuleCell.IGNORE_CELL_VALUE;
    valueRuleDefinition.rows[5].cells[3].values = ValueRuleCell_1.ValueRuleCell.IGNORE_CELL_VALUE;
    valueRuleDefinition.rows[6].cells[3].values = "AC";
    valueRuleDefinition.rows[7].cells[3].values = "AC";
    valueRuleDefinition.rows[8].cells[3].values = ValueRuleCell_1.ValueRuleCell.IGNORE_CELL_VALUE;
    valueRuleDefinition.addResultColumn();
    valueRuleDefinition.rows[0].resultCells[0].value = true;
    valueRuleDefinition.rows[1].resultCells[0].value = false;
    valueRuleDefinition.rows[2].resultCells[0].value = true;
    valueRuleDefinition.rows[3].resultCells[0].value = false;
    valueRuleDefinition.rows[4].resultCells[0].value = true;
    valueRuleDefinition.rows[5].resultCells[0].value = false;
    valueRuleDefinition.rows[6].resultCells[0].value = true;
    valueRuleDefinition.rows[7].resultCells[0].value = false;
    valueRuleDefinition.rows[8].resultCells[0].value = false;
    valueRuleDefinition.rows[0].resultCells[1].value = "Schendule Meeting";
    valueRuleDefinition.rows[1].resultCells[1].value = "Send Survey";
    valueRuleDefinition.rows[2].resultCells[1].value = "Schedule Meeting";
    valueRuleDefinition.rows[3].resultCells[1].value = "Do Nothing";
    valueRuleDefinition.rows[4].resultCells[1].value = "Schedule Meeting";
    valueRuleDefinition.rows[5].resultCells[1].value = "Send Survey";
    valueRuleDefinition.rows[6].resultCells[1].value = "Schedule Meeting";
    valueRuleDefinition.rows[7].resultCells[1].value = "Send Survey";
    valueRuleDefinition.rows[8].resultCells[1].value = "Do Nothing";
    valueRuleDefinition.defaultResult[valueRuleDefinition.resultColumns[0]._id].value = false;
    valueRuleDefinition.defaultResult[valueRuleDefinition.resultColumns[1]._id].value = "Do Nothing";
    valueRuleDefinition.setResultColumnType(valueRuleDefinition.resultColumns[0], new BooleanDataDefinition_1.BooleanDataDefinition("result_1"));
    valueRuleDefinition.setResultColumnType(valueRuleDefinition.resultColumns[1], new StringDataDefinition_1.StringDataDefinition("result_2"));
    valueRuleDefinition.syncAllRows();
    return valueRuleDefinition;
};
exports.getValueTableExample = getValueTableExample;
//# sourceMappingURL=ValueTable.js.map