IMsTransformObject.Selection

Syntax

Selection: IDimSelection;

Description

The Selection property determines selection of elements corresponding to this object.

Comments

To set description of repository object corresponding to the object, use the IMsTransformObject.Descriptorproperty.

Example

Executing the example requires that the repository contains a modeling container with the MS identifier containing a metamodel with the META_OBJLIST identifier and models with the DEFAULT_MODEL, MODEL_LINEAR identifiers. The repository must also contain the MDM dictionary with the MDM_DICT_OL identifier located out of the MDM repository.

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

Sub UserProc;
Var
    mb: IMetabase;
    msKey: Integer;
    pMetaModel: IMsMetaModel;
    pDimInstance: IDimInstance;
    pSelection: IDimSelection;
    paramMeta: IMsModelParam;
    params: IMsModelParams;
    calcChain: IMsCalculationChainEntries;
    branch: IMsCalculationChainBranch;
    cas: IMsBranchCase;
    model: IMsModel;
    CondEx: IMsBranchConditionExpression;
    desc: IMetabaseObjectDescriptor;
    trObj: IMsTransformObject;
Begin
    // Get current repository
    mb := MetabaseClass.Active;
    // Get modelling container key
    msKey := mb.GetObjectKeyById("MS");
    // Get metamodel  
    pMetaModel := mb.ItemByIdNamespace("META_OBJLIST", msKey).Edit As IMsMetaModel;
    // Get metamodel parameters collection
    params := pMetaModel.Params;
    // Clear collection
    params.Clear;
    // Add a new parameter
    paramMeta := params.Add;
    // Set parameter name
    paramMeta.Name := "COUNTRY";
    // Get MDM dictionary
    desc := mb.ItemById("MDM_DICT_OL");
    // Specify that dictionary values determine parameter values
    paramMeta.LinkedObject := desc.Bind;
    // Get metamodel calculation chain
    calcChain := pMetaModel.CalculationChain;
    // Clear calculation chain
    calcChain.Clear;
    // Create a condition in calculation chain    
    branch := calcChain.AddBranch("Condition");
    // Get the model
    model := mb.ItemByIdNamespace("DEFAULT_MODEL", msKey).Bind As IMsModel;
    // Specify that this model is calculated if any condition branch is not executed
    branch.DefaultContents.AddModel(model);
    // Determine cycle parameter
    branch.Parameter := paramMeta;
    // Add condition branch
    cas := branch.CaseList.Add;
    // Set model which will be calculated on executing this condition branch
    model := mb.ItemByIdNamespace("MODEL_LINEAR", msKey).Bind As IMsModel;
    cas.Contents.AddModel(model);
    // Add condition to calculate branch
    CondEx := cas.Conditions.Add(MsBranchConditionType.Expression) As IMsBranchConditionExpression;
    // Add MDM dictionary to the collection of objects used to calculate condition branch
    trObj := CondEx.Transform.ObjectList.Add(desc);
    // Get MDM dictionary instance
    pDimInstance := desc.Open(NullAs IDimInstance;
    // Create a selection in this dictionary
    pSelection := pDimInstance.CreateSelection;
    // Select element
    pSelection.SelectElement(1False);
    // Add MDM dictionary selection to the collection of objects used to calculate condition branch
    trObj.Selection := pSelection;
    // Specify branch calculation condition
    condex.Expression.AsString := "{COUNTRY}=@__" + trObj.Key.ToString;
    // Save metamodel
    (pMetaModel As IMetabaseObject).Save;
End Sub UserProc;

After executing the example the parameter which value is determined by the MDM_DICT_OL dictionary element is created in the metamodel. The cycle depending on this parameter is also added to the metamodel: if parameter value matches the second dictionary element, the MODEL_LINEAR is calculated, otherwise the DEFAULT_MODEL model is calculated.

See also:

IMsTransformObject