IMsBranchConditionExpression.Transform

Fore Syntax

Transform: IMsFormulaTransform;

Fore.NET Syntax

Transform: Prognoz.Platform.Interop.Ms.IMsFormulaTransform;

Description

The Transform property returns the parameters of complex condition of calculation.

Comments

By default parameters contain one formula with annual frequency. To get it, use the IMsFormulaTransform.FormulaItem property. After forming the formula, it will be automatically decomposed and set into the IMsBranchConditionExpression.Expression property.

Fore Example

Executing the example requires that the repository contains a modeling container with the MODEL_SPACE identifier, which contains models with the USER_MODEL, DEFAULT_MODEL identifiers and a metamodel with the USER_META_MODEL identifier. The metamodel must contain the integer-valued parameter with indicator_param name.

Add links to the Dimensions, Metabase, Ms system assemblies.

Sub UserTransformation;
Var
    pMetabase: IMetabase;
    pMSKey: Integer;
    pMeta: IMsMetaModel;
    pBranch: IMsCalculationChainBranch;
    pModel_a, pModel_b: IMsModel;
    pCase: IMsBranchCase;
    pCond: IMsBranchConditionExpression;
    pTransf: IMsFormulaTransform;
    pMethod: IMsDeterministicTransform;
    
Begin
    pMetabase := MetabaseClass.Active;
    //Get the key of the modeling container
    pMSKey := pMetabase.GetObjectKeyById("MODEL_SPACE");
    // Get metamodel
    pMeta := pMetabase.ItemByIdNamespace("USER_META_MODEL", pMSKey).Edit As IMsMetaModel;
    // Clear the calculation chain of the metamodel
    pMeta.CalculationChain.Clear;
    // Create a condition of metamodel calculation
    pBranch := pMeta.CalculationChain.AddBranch("Calculation condition");
    // Set the calendar frequency of the condition
    pBranch.Level := DimCalendarLevel.Year;
    // Get the DEFAULT_MODEL model
    pModel_a := pMetabase.ItemByIdNamespace("DEFAULT_MODEL", pMSKey).Bind As IMsModel;
    // Add model to the condition
    pBranch.DefaultContents.AddModel(pModel_a);
    // Get the USER_MODEL model
    pModel_b := pMetabase.ItemByIdNamespace("USER_MODEL", pMSKey).Bind As IMsModel;
    // Create new branch of the condition
    pCase := pBranch.CaseList.Add;
    // Add USER_MODEL model to a new branch
    pCase.Contents.AddModel(pModel_b);
    // Create a condition of branch calculation
    pCond := pCase.Conditions.Add(MsBranchConditionType.Expression) As IMsBranchConditionExpression;
    pTransf := pCond.Transform;
    pMethod := pTransf.FormulaItem(0).Method As IMsDeterministicTransform;
    pMethod.Expression.AsString := "{indicator_param[t]} = 3";
    // Save metamodel 
    (pMeta As IMetabaseObject).Save;
End Sub UserTransformation;

After executing the example the calculation condition will be added to the metamodel: the value of the metamodel parameter must be equal to three. On calculating the transformation task the following condition will be checked: if it is satisfied, the USER_MODEL model is calculated, if it is not satisfied, the DEFAULT_MODEL is calculated.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.Ms;

Public Shared Sub Main(Params: StartParams);
Var
    pMetabase: IMetabase;
    pMSKey: uinteger;
    pMeta: IMsMetaModel;
    pBranch: IMsCalculationChainBranch;
    pModel_a, pModel_b: IMsModel;
    pCase: IMsBranchCase;
    pCond: IMsBranchConditionExpression;
    pTransf: IMsFormulaTransform;
    pMethod: IMsDeterministicTransform;
Begin
    pMetabase := Params.Metabase;
    //Get the key of the modeling container
    pMSKey := pMetabase.GetObjectKeyById("MODEL_SPACE");
    // Get metamodel
    pMeta := pMetabase.ItemByIdNamespace["USER_META_MODEL", pMSKey].Edit() As IMsMetaModel;
    // Clear the calculation chain of the metamodel
    pMeta.CalculationChain.Clear();
    // Create a condition of metamodel calculation
    pBranch := pMeta.CalculationChain.AddBranch("Calculation condition");
    // Set the calendar frequency of the condition
    pBranch.Level := DimCalendarLevel.dclYear;
    // Get the DEFAULT_MODEL model
    pModel_a := pMetabase.ItemByIdNamespace["DEFAULT_MODEL", pMSKey].Bind() As IMsModel;
    // Add model to the condition
    pBranch.DefaultContents.AddModel(pModel_a);
    // Get the USER_MODEL model
    pModel_b := pMetabase.ItemByIdNamespace["USER_MODEL", pMSKey].Bind() As IMsModel;
    // Create new branch of the condition
    pCase := pBranch.CaseList.Add();
    // Add USER_MODEL model to a new branch
    pCase.Contents.AddModel(pModel_b);
    // Create a condition of branch calculation
    pCond := pCase.Conditions.Add(MsBranchConditionType.mbctExpression) As IMsBranchConditionExpression;
    pTransf := pCond.Transform;
    pMethod := pTransf.FormulaItem[0].Method As IMsDeterministicTransform;
    pMethod.Expression.AsString := "{indicator_param[t]} = 3";
    // Save metamodel 
    (pMeta As IMetabaseObject).Save();
End Sub;

See also:

IMsBranchConditionExpression