CustomLinker: IMsDimCustomLinker;
The CustomLinker property determines a custom dimension linking mechanism.
A custom mechanism should be implemented as a class that implements methods of the IMsDimCustomLinker interface.
Executing the example requires that the repository includes a modeling container with the MS identifier including a modeling problem with the PROBLEM_MULTIDIMITERATOR identifier. This problem must calculate a metamodel containing only multidimensional iterator. The repository should also contains a time series database with the TSDB_STAT identifier that contains the INDICATOR attribute that is a dictionary link.
Add links to the Cubes, Dimensions, Metabase, Ms, Rds system assemblies.
Sub UserProc;
Var
mb: IMetabase;
MsKey: Integer;
Problem: IMsProblem;
MM: IMsMetaModel;
Iterator: IMsCalculationChainMultiDimIterator;
IterDim: IMsDimIteratorDimension;
Links: IMsDimIteratorLinks;
DSLinked: IRubricator;
Attributes: IMetaAttributes;
dimLinked: IDimInstance;
IDimLink: IMsDimIteratorLink;
ml: MLinker;
Calculation: IMsProblemCalculation;
CalcSettings: IMsProblemCalculationSettings;
Begin
// Get current repository
mb := MetabaseClass.Active;
// Get modelling container key
MsKey := mb.GetObjectKeyById("MS");
// Get modeling problem
Problem := mb.ItemByIdNamespace("PROBLEM_MULTIDIMITERATOR", MsKey).Bind As IMsProblem;
// Get metamodel calculated by problem
MM := Problem.EditMetaModel;
// Get multidimensional iterator
Iterator := MM.CalculationChain.Item(0) As IMsCalculationChainMultiDimIterator;
// Get links of iterator's first dimension
IterDim := Iterator.Dimensions.Item(0);
Links := IterDim.Links;
// Remove existing links
Links.Clear;
// Get the TSDB_STAT time series database
DSLinked := mb.ItemById("TSDB_STAT").Bind As IRubricator;
// Get dictionary, on which the INDICATOR attribute is based
Attributes := DSLinked.Facts.Attributes;
dimLinked := Attributes.FindById("INDICATOR").ValuesObject.Open(Null) As IDimInstance;
// Add a dictionary as a linked dimension
IDimLink := Links.Add(dimLinked);
// Specify data source of linked dimension
IDimLink.Dimension.Stubs.Add(DSLinked As IVariableStub);
// Specify consumer attribute
IDimLink.DestinationAttribute := dimLinked.Attributes.FindById("NAME").Attribute;
// Display name of controlling dimension in the console window
Debug.WriteLine("Controlling dimension: " + IDimLink.Owner.Name);
// Create a custom mechanism of dimension linking
ml := New MLinker.Create;
Links.CustomLinker := ml;
// Create problem calculation options
CalcSettings := Problem.CreateCalculationSettings;
Calculation := Problem.Calculate(CalcSettings);
// Execute calculation
Calculation.Run;
End Sub UserProc;
// Class that implements custom linking mechanism
Public Class MLinker: Object, IMsDimCustomLinker
Public Function ResolveLink(
Source: IMsDimIteratorDimension;
Destination: IMsDimIteratorDimension;
CurrentSelection: IDimSelectionSet;
Var SkipCustomLink: Boolean): Array;
Var
i: Integer;
Result: Array;
Begin
SkipCustomLink := False;
Debug.WriteLine("Source: " + Source.Name);
Debug.WriteLine("Consumer: " + Destination.Name);
Debug.WriteLine("Selection:");
Debug.Indent;
For i := 0 To CurrentSelection.Count - 1 Do
Debug.Write(CurrentSelection.Item(i).Dimension.Name + ": ");
Debug.WriteLine(CurrentSelection.Item(i).ToString);
End For;
Debug.Unindent;
Result := New Variant[1];
Result[0] := 1;
Return Result;
End Function ResolveLink;
End Class MLinker;
After executing the example a custom linking mechanism is applied to the multidimensional iterator. The console window displays information about linked dictionaries.
See also: