import { StringDataDefinition } from "../../../Common/Data/Definitions/StringDataDefinition";
import { DataUtilities } from "../../../Common/DataUtilities";
import { XExpressionDefinition } from "../../../Expressions/XExpressionDefinition";
import { ValidationIssue } from "../../../Common/IDesignValidationProvider";
import { ConfigStorageUtility } from "../../../Common/ConfigStorageUtility";
import { BooleanDataDefinition } from "../../../Common/Data/Definitions/BooleanDataDefinition";
import { ObjectDataDefinition } from "../../../Common/Data/Definitions/ObjectDataDefinition";
import { ExpressionValueType } from "../../../Expressions/ExpressionValueType";
export class ValueRuleColumn {
    constructor(columnName) {
        this._id = DataUtilities.generateUniqueId();
        this.cellData = new StringDataDefinition("cellValue");
        this.columnName = columnName;
        this.expression = new XExpressionDefinition();
        this.expression.valueType = ExpressionValueType.SUBEXPRESSION;
        let executionDef = new BooleanDataDefinition(this.columnName || "");
        this.expression.executionResult = () => executionDef;
    }
    getDesignValidationIssues() {
        let issues = [];
        if (this.cellData instanceof ObjectDataDefinition) {
            if (this.cellData.fields.length === 0) {
                issues.push(new ValidationIssue("Object data not setup. Object must contain fields."));
            }
        }
        return this.expression.getDesignValidationIssues();
    }
    getStorageData() {
        let data = {};
        Reflect.set(data, "_id", this._id);
        Reflect.set(data, "columnName", this.columnName);
        Reflect.set(data, "cellData", this.cellData.getStorageData());
        Reflect.set(data, "expression", this.expression.getStorageData());
        return data;
    }
    setStorageData(data) {
        this._id = Reflect.get(data, "_id");
        this.columnName = Reflect.get(data, "columnName");
        let ex = new XExpressionDefinition();
        ex.setStorageData(Reflect.get(data, "expression"));
        this.expression = ex;
        this.cellData = ConfigStorageUtility.getDataDefinitionFromData(Reflect.get(data, "cellData"));
    }
}
//# sourceMappingURL=ValueRuleColumn.js.map