"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getValueTableWithDeferentType = exports.getValueTableBoolean = exports.getValueTableNumber = exports.getValueTableDate = exports.getValueTableStringList = exports.getValueTableString = exports.getEmptyValueTable = void 0;
const BooleanDataDefinition_1 = require("@appglue/common/dist/Common/Data/Definitions/BooleanDataDefinition");
const DateDataDefinition_1 = require("@appglue/common/dist/Common/Data/Definitions/DateDataDefinition");
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 DataTestData_1 = require("@appglue/common/dist/Common/Data/DataTestData");
const TestData_1 = require("../../../../CommonUI/DataEditing/Testing/TestData");
const DateGreaterThanExpression_1 = require("@appglue/common/dist/Expressions/Expressions/Date/DateGreaterThanExpression");
const GreaterThan_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/GreaterThan");
const StringEndWithExpression_1 = require("@appglue/common/dist/Expressions/Expressions/String/StringEndWithExpression");
const ValueTableConfiguration_1 = require("@appglue/common/dist/Rule/Table/Value/ValueTableConfiguration");
const getEmptyValueTable = () => {
    return new ValueTableConfiguration_1.ValueTableConfiguration();
};
exports.getEmptyValueTable = getEmptyValueTable;
const getValueTableString = (readonly) => {
    const ruleDefinition = new ValueTableConfiguration_1.ValueTableConfiguration();
    const dataDefinition = (0, TestData_1.getEmptyDataDefinition)();
    ruleDefinition.inputData = readonly
        ? () => {
            return dataDefinition;
        }
        : dataDefinition;
    ruleDefinition.columns[0].columnName = "firstName";
    ruleDefinition.columns[0].cellData = new StringDataDefinition_1.StringDataDefinition("cellValue");
    dataDefinition.fields.push(new StringDataDefinition_1.StringDataDefinition("firstName"));
    ruleDefinition.addRow();
    ruleDefinition.rows[0].cells[0].values = "Bruno";
    return ruleDefinition;
};
exports.getValueTableString = getValueTableString;
const getValueTableStringList = (readonly) => {
    const ruleDefinition = new ValueTableConfiguration_1.ValueTableConfiguration();
    const dataDefinition = (0, TestData_1.getEmptyDataDefinition)();
    ruleDefinition.inputData = readonly
        ? () => {
            return dataDefinition;
        }
        : dataDefinition;
    ruleDefinition.columns[0].columnName = "firstName";
    ruleDefinition.columns[0].cellData = new StringDataDefinition_1.StringDataDefinition("cellValue");
    dataDefinition.fields.push(new StringDataDefinition_1.StringDataDefinition("firstName"));
    ruleDefinition.addRow();
    ruleDefinition.rows[0].cells[0].values = ["Bruno", "James", "Martin", "Cristiano"];
    return ruleDefinition;
};
exports.getValueTableStringList = getValueTableStringList;
const getValueTableDate = (readonly) => {
    const ruleDefinition = new ValueTableConfiguration_1.ValueTableConfiguration();
    const dataDefinition = (0, TestData_1.getEmptyDataDefinition)();
    ruleDefinition.inputData = readonly
        ? () => {
            return dataDefinition;
        }
        : dataDefinition;
    ruleDefinition.columns[0].columnName = "birthday";
    ruleDefinition.columns[0].cellData = new DateDataDefinition_1.DateDataDefinition("cellValue");
    dataDefinition.fields.push(new DateDataDefinition_1.DateDataDefinition("birthday"));
    ruleDefinition.addRow();
    return ruleDefinition;
};
exports.getValueTableDate = getValueTableDate;
const getValueTableNumber = (readonly) => {
    const ruleDefinition = new ValueTableConfiguration_1.ValueTableConfiguration();
    const dataDefinition = (0, TestData_1.getEmptyDataDefinition)();
    ruleDefinition.inputData = readonly
        ? () => {
            return dataDefinition;
        }
        : dataDefinition;
    ruleDefinition.columns[0].columnName = "age";
    ruleDefinition.columns[0].cellData = new NumberDataDefinition_1.NumberDataDefinition("cellValue");
    dataDefinition.fields.push(new NumberDataDefinition_1.NumberDataDefinition("age"));
    ruleDefinition.addRow();
    return ruleDefinition;
};
exports.getValueTableNumber = getValueTableNumber;
const getValueTableBoolean = (readonly) => {
    const ruleDefinition = new ValueTableConfiguration_1.ValueTableConfiguration();
    const dataDefinition = (0, TestData_1.getEmptyDataDefinition)();
    ruleDefinition.inputData = readonly
        ? () => {
            return dataDefinition;
        }
        : dataDefinition;
    dataDefinition.fields.push(new BooleanDataDefinition_1.BooleanDataDefinition("married"));
    ruleDefinition.columns[0].columnName = "married";
    ruleDefinition.columns[0].cellData = new BooleanDataDefinition_1.BooleanDataDefinition("cellValue");
    ruleDefinition.addRow();
    return ruleDefinition;
};
exports.getValueTableBoolean = getValueTableBoolean;
const getValueTableWithDeferentType = (readonly) => {
    const ruleDefinition = new ValueTableConfiguration_1.ValueTableConfiguration();
    const dataDefinition = (0, DataTestData_1.getFilledDataDefinition)();
    ruleDefinition.inputData = readonly
        ? () => {
            return dataDefinition;
        }
        : dataDefinition;
    dataDefinition.fields.push(new NumberDataDefinition_1.NumberDataDefinition("age"));
    ruleDefinition.columns[0].columnName = "stringfield";
    ruleDefinition.columns[0].cellData = new StringDataDefinition_1.StringDataDefinition("cellValue");
    let strendwith = new StringEndWithExpression_1.StringEndWithExpression();
    strendwith.value1.variableName = "cellValue";
    strendwith.value2.value = "Chachin";
    ruleDefinition.columns[0].expression.expression = strendwith;
    ruleDefinition.addColumn();
    ruleDefinition.columns[1].columnName = "isMarried";
    ruleDefinition.columns[1].cellData = new BooleanDataDefinition_1.BooleanDataDefinition("cellValue");
    ruleDefinition.columns[1].expression.variableName = "cellValue";
    let birthday = new DateDataDefinition_1.DateDataDefinition("birthday");
    dataDefinition.fields.push(birthday);
    let dategreaterthan = new DateGreaterThanExpression_1.DateGreaterThanExpression();
    dategreaterthan.value1.variableName = "cellValue";
    dategreaterthan.value2.value = "1980-01-01";
    ruleDefinition.addColumn();
    ruleDefinition.columns[2].columnName = "birthday";
    ruleDefinition.columns[2].cellData = new DateDataDefinition_1.DateDataDefinition("cellValue");
    ruleDefinition.columns[2].expression.expression = dategreaterthan;
    let greaterthan = new GreaterThan_1.GreaterThanExpression();
    greaterthan.value1.variableName = "cellValue";
    greaterthan.value2.variableName = "age";
    ruleDefinition.addColumn();
    ruleDefinition.columns[3].columnName = "age";
    ruleDefinition.columns[3].cellData = new NumberDataDefinition_1.NumberDataDefinition("cellValue");
    ruleDefinition.columns[3].expression.expression = greaterthan;
    ruleDefinition.addRow();
    ruleDefinition.rows[0].cells[0].values = "Bruno Pereira";
    ruleDefinition.rows[0].cells[1].values = true;
    ruleDefinition.rows[0].cells[2].values = "1992-02-01";
    ruleDefinition.rows[0].cells[3].values = 42;
    ruleDefinition.rows[1].cells[0].values = "Jose Chachin";
    ruleDefinition.rows[1].cells[1].values = true;
    ruleDefinition.rows[1].cells[2].values = "1990-02-01";
    ruleDefinition.rows[1].cells[3].values = 31;
    ruleDefinition.syncAllRows();
    let outdef = new DataDefinition_1.DataDefinition();
    outdef.fields.push(new StringDataDefinition_1.StringDataDefinition("name"));
    outdef.fields.push(new NumberDataDefinition_1.NumberDataDefinition("income"));
    ruleDefinition.executionResult = outdef;
    ruleDefinition.rows[0].resultCells[0].value = "Bruno Pereira";
    ruleDefinition.rows[0].resultCells[1].value = 5000;
    ruleDefinition.rows[1].resultCells[0].value = "Jose Chachin";
    ruleDefinition.rows[1].resultCells[1].value = 10000;
    ruleDefinition.defaultResult[ruleDefinition.resultColumns[0]._id].value = "James";
    ruleDefinition.defaultResult[ruleDefinition.resultColumns[1]._id].value = 100;
    return ruleDefinition;
};
exports.getValueTableWithDeferentType = getValueTableWithDeferentType;
//# sourceMappingURL=TestDataSetup.js.map