Exemple #1
0
        public EditFormulaStringCommand(string newFormulaString, FormulaWithFormulaString formula, IBuildingBlock buildingBlock)
            : base(buildingBlock)
        {
            _formulaId        = formula.Id;
            _formula          = formula;
            _newFormulaString = newFormulaString;
            _oldFormulaString = formula.FormulaString;

            ObjectType  = new ObjectTypeResolver().TypeFor(formula);
            CommandType = AppConstants.Commands.EditCommand;
            Description = AppConstants.Commands.ChangeFormulaString(formula.Name, _newFormulaString, _oldFormulaString, buildingBlock.Name);
        }
Exemple #2
0
        public (bool valid, string validationMessage) Validate(string formulaString, FormulaWithFormulaString formula, IBuildingBlock buildingBlock)
        {
            var(valid, validationMessage) = formula.IsValid(formulaString);

            if (valid)
            {
                _context.PublishEvent(new FormulaValidEvent(formula, buildingBlock));
            }
            else
            {
                _context.PublishEvent(new FormulaInvalidEvent(formula, buildingBlock, validationMessage));
            }

            return(valid, validationMessage);
        }
Exemple #3
0
        /// <summary>
        ///    Checks if formula equation is time dependent and add reference to
        ///    <para></para>
        ///    Time (if not already done)
        /// </summary>
        private void addTimeReferenceIfNeeded(FormulaWithFormulaString formula)
        {
            if (string.IsNullOrEmpty(formula.FormulaString))
            {
                return;
            }

            // check if formula string contains "Time" as a substring
            if (!formula.FormulaString.Contains(Constants.TIME))
            {
                return;
            }

            // check if time reference is already created
            if (formula.ContainsTimePath())
            {
                return;
            }

            // add time reference
            formula.AddObjectPath(_objectPathFactory.CreateTimePath(_dimensionRepository.Time));
        }
Exemple #4
0
 protected override void ClearReferences()
 {
     base.ClearReferences();
     _formula = null;
 }
Exemple #5
0
 public override void RestoreExecutionData(IMoBiContext context)
 {
     base.RestoreExecutionData(context);
     _formula = context.Get <FormulaWithFormulaString>(_formulaId);
 }
Exemple #6
0
        public IMoBiCommand SetFormulaString(FormulaWithFormulaString formula, string newFormulaString, IBuildingBlock buildingBlock)
        {
            var command = new EditFormulaStringCommand(newFormulaString, formula, buildingBlock).Run(_context);

            return(withUpdatedDefaultStateAndValueOrigin(command, formula, buildingBlock));
        }