ChildRubricator: IRubricator;
ChildRubricator: Prognoz.Platform.Interop.Cubes.IRubricator;
The ChildRubricator property returns the child time series database.
The temporary database is created if the child time series database is missing. Bindings are saved into the source cube but not into the time series database when saving.
Executing the example requires that the repository contains a standard cube with the STD_CUBE identifier.
Add links to the Metabase, Cube, Rds system assemblies.
// Data output function
Function ToString(Value: Variant): String;
Var
sRes: String;
i, l, idx: integer;
s: String;
arr: Array Of Variant;
Begin
Select Case Value.VarType
Case ForeVariantType.Integer:
i := Value;
sRes := i.ToString;
Case ForeVariantType.Matrix:
arr := Value As Array Of Variant;
l := arr.Length - 1;
For idx := 0 To l Do
s := s + ToString(arr[idx]) + "; ";
End For;
sRes := s;
End Select;
Return sRes;
End Function ToString;
// Main procedure
Sub UserProc;
Var
mb: IMetabase;
Cube: IStandardCube;
Rub: IMetabaseObject;
RubI: IRubricatorInstance;
Key: Array[2];
FactD: IRubricatorFactData;
FactVal: IFactorObservationValues;
i: Integer;
Mem: IMetaDataMember;
Begin
mb := MetabaseClass.Active;
// Get cube
Cube := mb.ItemById("STD_CUBE").Bind As IStandardCube;
// Get child time series database
Rub := Cube.ChildRubricator As IMetabaseObject;
If Rub <> Null Then
RubI := Rub.Open(Null) As IRubricatorInstance;
Key[0] := 512;
Key[1] := 1009;
// Get time series by composite key value
FactD := RubI.GetCompoundFactData(Key);
// Display data about time series
If FactD <> Null Then
Debug.WriteLine("____________");
Debug.WriteLine("Mnemo:" + FactD.Mnemo);
Debug.WriteLine("Key: " + FactD.FactorKey.ToString);
Debug.WriteLine("IsDeleted: " + FactD.IsDeleted.ToString);
Debug.WriteLine("IsEmpty: " + FactD.IsEmpty.ToString);
Debug.WriteLine("UseCompoundKey: " + FactD.UseCompoundKey.ToString);
Debug.WriteLine("CompoundKey: " + ToString(FactD.CompoundKey));
Debug.WriteLine("CompoundFactorKey: " + ToString(FactD.CompoundFactorKey));
Debug.WriteLine("____________");
// Display data about time series observations
For i := 1980 To 2012 Do
FactVal := RubI.GetObservationValues(FactD, DateTime.ComposeDay(i, 1, 1));
If FactVal <> Null Then
Debug.WriteLine("Date: " + DateTime.ComposeDay(i, 1, 1).ToString);
Debug.WriteLine("FactDataCompoundKey: " + ToString(FactVal.FactDataCompoundKey));
Mem := FactVal.Record.Members.FindByKind(MetaAttributeKind.Value);
Debug.WriteLine("Value: " + ToString(Mem.Value));
Debug.WriteLine("----");
End If;
End For;
End If;
End If;
End Sub UserProc;
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Rds;
// Main procedure
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
Cube: IStandardCube;
Rub: IMetabaseObject;
RubI: IRubricatorInstance;
Key: Array[2] Of object;
KeyO: object;
FactD: RubricatorFactData;
FactVal: IFactorObservationValues;
i: Integer;
Mem: IMetaDataMember;
Begin
mb := Params.Metabase;
// Get cube
Cube := mb.ItemById["STD_CUBE"].Bind() As IStandardCube;
// Get child time series database
Rub := Cube.ChildRubricator As IMetabaseObject;
If Rub <> Null Then
RubI := Rub.Open(Null) As IRubricatorInstance;
//Key := New string[2];
Key[0] := "512"; Key[1] := "1009";
// Get time series by composite key value
FactD := RubI.GetCompoundFactData(Key, DictionaryGetDataOptions.dgdoNone);
// Display data about time series
If FactD <> Null Then
System.Diagnostics.Debug.WriteLine("____________");
System.Diagnostics.Debug.WriteLine("Mnemo:" + FactD.Mnemo);
System.Diagnostics.Debug.WriteLine("Key: " + FactD.FactorKey.ToString());
System.Diagnostics.Debug.WriteLine("IsDeleted: " + FactD.IsDeleted.ToString());
System.Diagnostics.Debug.WriteLine("IsEmpty: " + FactD.IsEmpty.ToString());
System.Diagnostics.Debug.WriteLine("UseCompoundKey: " + FactD.UseCompoundKey.ToString());
System.Diagnostics.Debug.WriteLine("CompoundKey: " + ToString(FactD.CompoundKey));
System.Diagnostics.Debug.WriteLine("CompoundFactorKey: " + ToString(FactD.CompoundFactorKey));
System.Diagnostics.Debug.WriteLine("____________");
// Display data about time series observations
For i := 1980 To 2012 Do
FactVal := RubI.GetObservationValues(FactD, DateTime.Parse(i + ".1.1"), 0 As DictionaryGetDataOptions);
If FactVal <> Null Then
System.Diagnostics.Debug.WriteLine("Date: " + DateTime.Parse(i + ".1.1").ToString());
System.Diagnostics.Debug.WriteLine("FactDataCompoundKey: " + ToString(FactVal.FactDataCompoundKey));
Mem := FactVal.Record.Members.FindByKind(MetaAttributeKind.meakValue, 0);
System.Diagnostics.Debug.WriteLine("Value: " + Mem.Value.ToString());
System.Diagnostics.Debug.WriteLine("----");
End If;
End For;
End If;
End If;
End Sub;
// Data output function
Public Shared Function ToString(Value: object): String;
Var
sRes: String;
l, idx: integer;
s: String;
arr: Array Of object;
Begin
If Value.GetType().IsArray Then
arr := Value As Array Of object;
l := arr.Length - 1;
For idx := 0 To l Do
s := s + ToString(arr[idx]) + "; ";
End For;
sRes := s;
Else
sRes := Value.ToString();
End If;
Return sRes;
End Function ToString;
After the basic procedure is executed, the console window displays the data of time series and its observations that is obtained by the composite key value.
See also: