AssignSelection(Source: IDimSelection; DimElement: Integer);
AssignSelection(Source: Prognoz.Platform.Interop.Dimensions.IDimSelection; DimElement: Integer);
Source. Selection that must be set in fixed dimension.
DimElement. Index of the element that must be selected.
The AssignSelection method changes selection in the fixed dimension according to the parameters to be passed.
If the "-1" value is passed as the value of the DimElement parameter, the Source selection will be set for fixed dimension. If the index of specific element is passed then the Source selection is reset, and only one element with the DimElement index is selected.
Executing the example requires that the repository contains a virtual cube with the V_Cube identifier. A virtual cube and the first source cube have the Dim_P parametric dimension that must be fixed at specific values of dimension parameters. Parameters of this dimension are not connected with parameters of virtual cube.
Sub UserProc;
Var
MB: IMetabase;
VirtCub: IVirtualCube;
Source: IVirtualCubeSource;
ControlInfo: IMetabaseObjectControlInfo;
DimObj: IMetabaseObject;
Params: IMetabaseObjectParamValues;
Dim: IDimInstance;
Sel: IDimSelection;
Fix: ICubeDimensionFix;
FixEx: ICubeDimensionFixEx;
ParamValue: Integer = 100;
Begin
MB := MetabaseClass.Active;
//Open cube for edit
VirtCub := MB.ItemById("V_Cube").Edit As IVirtualCube;
//Get cube source
Source := VirtCub.Sources.Item(0);
//Change value of the parameter in the nested objects parameters
ControlInfo := (VirtCub As IMetabaseObject).Params.ControlInfo;
ControlInfo.Item(0).Item(0).Expression.AsString := ParamValue.ToString;
//Get parametric dimension of the source
DimObj := Source.Cube.Dimensions.FindById("Dim_P") As IMetabaseObject;
//Parameters for opening dimension instance
Params := DimObj.Params.CreateEmptyValues;
Params.Item(0).Value := ParamValue;
Dim := DimObj.Open(Params) As IDimInstance;
//Create a selection based on a new dimension instance
Sel := Dim.CreateSelection;
Sel.MultiSelect := True;
Sel.SelectElement(0, False);
Sel.SelectElement(1, False);
Sel.SelectElement(2, False);
//Get dimension fixing parameters
Fix := Source.FixInfo.FindByKey(DimObj.Key);
FixEx := Fix As ICubeDimensionFixEx;
//Update selection of fixed parametric dimension
FixEx.AssignSelection(Sel, -1);
Fix.Fixed := True;
//Save cube
(VirtCub As IMetabaseObject).Save;
End Sub UserProc;
On executing the example the selection of fixed parametric dimension in virtual cube are changed: first three elements in the dimension are selected. The dimension is opened with the specified parameter value. To keep functions of virtual cube, save parameter value in managing of nested object parameters.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Matrix;
Imports Prognoz.Platform.Interop.Metabase;
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
VirtCub: IVirtualCube;
Source: IVirtualCubeSource;
ControlInfo: IMetabaseObjectControlInfo;
DimObj: IMetabaseObject;
DimParams: IMetabaseObjectParamValues;
Dim: IDimInstance;
Sel: IDimSelection;
Fix: ICubeDimensionFix;
FixEx: ICubeDimensionFixEx;
ParamValue: Integer = 100;
Begin
MB := Params.Metabase;
//Open cube for edit
VirtCub := MB.ItemById["V_Cube"].Edit() As IVirtualCube;
//Get cube source
Source := VirtCub.Sources.Item[0];
//Change value of the parameter in the nested objects parameters
ControlInfo := (VirtCub As IMetabaseObject).Params.ControlInfo;
//Change value in the first parameter of the first source
ControlInfo.Item[0].Item[0].Expression.AsString := ParamValue.ToString();
//Get parametric dimension of the source
DimObj := Source.Cube.Dimensions.FindById("Dim_P") As IMetabaseObject;
//Parameters for opening dimension instance
DimParams := DimObj.Params.CreateEmptyValues();
DimParams.Item[0].Value := ParamValue;
Dim := DimObj.Open(DimParams) As IDimInstance;
//Create a selection based on a new dimension instance
Sel := Dim.CreateSelection();
Sel.MultiSelect := True;
Sel.SelectElement(0, False);
Sel.SelectElement(1, False);
Sel.SelectElement(2, False);
//Get dimension fixing parameters
Fix := Source.FixInfo.FindByKey(DimObj.Key);
FixEx := Fix As ICubeDimensionFixEx;
//Update selection of fixed parametric dimension
FixEx.AssignSelection(Sel, -1);
Fix.Fixed := True;
//Save cube
(VirtCub As IMetabaseObject).Save();
End Sub;
See also: