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); }
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); }
/// <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)); }
protected override void ClearReferences() { base.ClearReferences(); _formula = null; }
public override void RestoreExecutionData(IMoBiContext context) { base.RestoreExecutionData(context); _formula = context.Get <FormulaWithFormulaString>(_formulaId); }
public IMoBiCommand SetFormulaString(FormulaWithFormulaString formula, string newFormulaString, IBuildingBlock buildingBlock) { var command = new EditFormulaStringCommand(newFormulaString, formula, buildingBlock).Run(_context); return(withUpdatedDefaultStateAndValueOrigin(command, formula, buildingBlock)); }