SetAttrCombination(Attributes: String; Value: Array);
SetAttrCombination(Attributes: string; Value: System.Array);
Attributes. Attributes identifiers are separated with semicolon (;).
Value. Array of attribute values specified in the Attributes parameter.
The SetAttrCombination method sets a combination of attributes, by which time series data is extracted.
The SetAttrCombination method extracts only series with the specified combination of attributes. If time series are extracted by means of attribute selection constraint, the series are selected, which contain all available attribute combinations.
For example, there are the Country and Indicator attributes. If the selection Country = Afghanistan, Albania; Indicator = BCA, BEA selection is set, four series are extracted that contain all available combinations of these attributes. If the SetAttrCombination method is used, and the combination of attributes Afghanistan|BCA and Albania|BEA is set, only two series are extracted that contain only these attributes.
Executing the example requires that the repository contains a time series database with the TSDB_MLNG identifier containing time series attributes with the COUNTRY and INDICATOR identifiers. These attributes must be links to the dictionary.
Add links to the Cubes, Dimensions, Metabase, Rds system assemblies.
Sub uProc;
Var
MB: IMetabase;
RubDesc, DictDescr: IMetabaseObjectDescriptor;
RubrIn: IRubricatorInstance;
Cub: ICubeInstance;
Dest: ICubeInstanceDestination;
FactorExec: IRubricatorFactorExecutor;
Exec: ICubeInstanceDestinationExecutor;
Mat: IMatrix;
Ite: IMatrixIterator;
FactAttr: IMetaAttributes;
CountryElements, IndicatorElements: IDimElements;
SelArr: Array[2] Of Variant;
TmpArr: Array[2] Of Integer;
Begin
// Get repository
MB := MetabaseClass.Active;
// Get time series database
RubDesc := MB.ItemById("TSDB_MLNG");
RubrIn := RubDesc.Open(Null) As IRubricatorInstance;
// Get time series attributes
FactAttr := RubrIn.Facts.Dictionary.Attributes;
// Get values of the COUNTRY attribute
DictDescr := FactAttr.FindById("COUNTRY").ValuesObject;
CountryElements := (DictDescr.Open(Null) As IDimInstance).Elements;
// Get values of the INDICATOR attribute
DictDescr := FactAttr.FindById("INDICATOR").ValuesObject;
IndicatorElements := (DictDescr.Open(Null) As IDimInstance).Elements;
// Create an array with combination of attributes for sampling
TmpArr[0] := CountryElements.AttributeValue(1, 0) As Integer;
TmpArr[1] := IndicatorElements.AttributeValue(1, 0) As Integer;
SelArr[0] := TmpArr;
TmpArr[0] := CountryElements.AttributeValue(2, 0) As Integer;
TmpArr[1] := IndicatorElements.AttributeValue(2, 0) As Integer;
SelArr[1] := TmpArr;
// Create an object for extracting data from time series database
Cub := RubrIn As ICubeInstance;
Dest := Cub.Destinations.DefaultDestination;
Exec := Dest.CreateExecutor;
FactorExec := Exec As IRubricatorFactorExecutor;
// Specify that do not extract data of empty and deleted series
FactorExec.WhereIsDeleted := False;
FactorExec.WhereIsEmpty := False;
// Set combination of attributes for sampling
FactorExec.SetAttrCombination("COUNTRY;INDICATOR", SelArr);
FactorExec.FactDataId := "FACTOR;INDICATOR;COUNTRY";
// Extract data and output it to the console window
Exec := FactorExec.AsCubeExecutor;
Exec.PrepareExecute(Null);
Exec.PerformExecute;
Mat := Exec.Matrix;
Ite := Mat.CreateIterator;
Ite.Move(IteratorDirection.First);
While Ite.Valid Do
Debug.WriteLine(Ite.Value);
Ite.Move(IteratorDirection.Next);
End While;
End Sub uProc;
After executing the example the console window displays values of the time series formed by combination of the first two elements from dictionaries, to which the COUNTRY and INDICATOR attributes refer. Empty and deleted attributes are excluded from the sample.
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.ForeSystem;
Imports Prognoz.Platform.Interop.Matrix;
Imports Prognoz.Platform.Interop.Rds;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
RubDesc, DictDescr: IMetabaseObjectDescriptor;
RubrIn: IRubricatorInstance;
Cub: ICubeInstance;
Dest: ICubeInstanceDestination;
FactorExec: IRubricatorFactorExecutor;
Exec: ICubeInstanceDestinationExecutor;
Mat: IMatrix;
Ite: IMatrixIterator;
FactAttr: IMetaAttributes;
CountryElements, IndicatorElements: IDimElements;
SelArr: Array[2] Of object;
TmpArr: Array[2] Of Integer;
Begin
// Get repository
MB := Params.Metabase;
// Get time series database
RubDesc := MB.ItemById["TSDB_MLNG"];
RubrIn := RubDesc.Open(Null) As IRubricatorInstance;
// Get time series attributes
FactAttr := RubrIn.Facts.Dictionary.Attributes;
// Get values of the COUNTRY attribute
DictDescr := FactAttr.FindById("COUNTRY").ValuesObject;
CountryElements := (DictDescr.Open(Null) As IDimInstance).Elements;
// Get values of the INDICTOR attribute
DictDescr := FactAttr.FindById("INDICATOR").ValuesObject;
IndicatorElements := (DictDescr.Open(Null) As IDimInstance).Elements;
// Create an array with combination of attributes for sampling
TmpArr[0] := CountryElements.AttributeValue[1, 0] As Integer;
TmpArr[1] := IndicatorElements.AttributeValue[1, 0] As Integer;
SelArr[0] := TmpArr;
TmpArr[0] := CountryElements.AttributeValue[2, 0] As Integer;
TmpArr[1] := IndicatorElements.AttributeValue[2, 0] As Integer;
SelArr[1] := TmpArr;
// Create an object for extracting data from time series database
Cub := RubrIn As ICubeInstance;
Dest := Cub.Destinations.DefaultDestination;
Exec := Dest.CreateExecutor();
FactorExec := Exec As IRubricatorFactorExecutor;
// Specify that do not extract data of empty and deleted series
FactorExec.WhereIsDeleted := False;
FactorExec.WhereIsEmpty := False;
// Set combination of attributes for sampling
FactorExec.SetAttrCombination("COUNTRY;INDICATOR", SelArr);
FactorExec.FactDataId := "FACTOR;INDICATOR;COUNTRY";
// Extract data and output it to the console window
Exec := FactorExec.AsCubeExecutor();
Exec.PrepareExecute(Null);
Exec.PerformExecute(False);
Mat := Exec.Matrix;
Ite := Mat.CreateIterator();
Ite.Move(IteratorDirection.itdFirst);
While Ite.Valid Do
System.Diagnostics.Debug.WriteLine(Ite.Value);
Ite.Move(IteratorDirection.itdNext);
End While;
End Sub;
See also: