CreateRubricator: IRubricator;
The CreateRubricator method creates a time series database.
The IRubricatorCreator.CreateInfo property determines basic parameters of time series database as a repository object.
Executing the example requires that the repository contains the following:
Data table with the T_TSDB identifier that contains the following fields:
Identifier | Field type | Comment |
COUNTRY | Integer | Mandatory and included into the primary index. |
INDICATOR | Integer | Mandatory and included into the primary index. |
DL | Integer | Mandatory and included into the primary index. |
VALUE | Real | Optional. |
DT | Date | Optional. |
ACT | Logical | Optional. |
MDM repository with the MDM_REPO identifier that contains the following:
Measures dictionary with the MEASURES identifier.
Units dictionary with the UNITS identifier.
Countries dictionary with the DICT_CTR identifier.
Factors dictionary with the DICT_IND identifier.
Calendar dictionary with the D_CALEND identifier.
Add links to the Mb, Cubes, Rds, Db, Dal, Dimensions system assemblies.
Sub UserProc;
Var
mb: IMetabase;
cr: IRubricatorCreator;
CrInfo: IMetabaseObjectCreateInfo;
mbObj: IMetabaseObjectDescriptor;
RdsKey: Integer;
Bs: IRubricatorCreatorBindings;
bindCountry, bindIndicator: IRubricatorCreatorBinding;
bindDLfacts, bindValues, bindDate, bindC: IRubricatorCreatorBinding;
Begin
mb := MetabaseClass.Active;
cr := New RubricatorCreator.Create;
// Set repository
cr.Metabase := mb;
// Set parameters of created time series database
CrInfo := cr.CreateInfo;
CrInfo.Id := mb.generateId("RUBRICATOR");
CrInfo.Name := "Time series database";
CrInfo.Parent := mb.Root;
// Set MDM repository
mbObj := mb.ItemById("RDS_REPO");
RdsKey := mbObj.Key;
cr.RdsDatabase := mbObj.Bind As IRdsDatabase;
// Set data table
mbObj := mb.ItemById("T_TSDB");
cr.SourceTable := mbObj.Bind As ITable;
// Set attribute bindings
Bs := cr.Bindings;
// Binding of the Country factor attribute
bindCountry := Bs.Add;
bindCountry.Dictionary := RubricatorDictionary.Facts;
bindCountry.AttributeId := "COUNTRY";
bindCountry.AttributeName := "Country";
bindCountry.UseField := True;
bindCountry.SourceFieldId := "COUNTRY";
bindCountry.DataType := DbDataType.Integer;
bindCountry.Kind := (MetaAttributeKind.Dimension);
bindCountry.ValuesObject := mb.ItemByIdNamespace("DICT_CTR", RdsKey);
bindCountry.Nullable := False;
bindCountry.IsDimension := True;
bindCountry.IncludeInIndex := True;
// Binding of the Indicator factor attribute
bindIndicator := Bs.Add;
bindIndicator.Dictionary := RubricatorDictionary.Facts;
bindIndicator.AttributeId := "INDICATOR";
bindIndicator.AttributeName := "Factor";
bindIndicator.UseField := True;
bindIndicator.SourceFieldId := "INDICATOR";
bindIndicator.DataType := DbDataType.Integer;
bindIndicator.Kind := (MetaAttributeKind.Dimension);
bindIndicator.Tag := MetaAttributeTag.None;
bindIndicator.ValuesObject := mb.ItemByIdNamespace("DICT_IND", RdsKey);
bindIndicator.Nullable := False;
bindIndicator.IsDimension := True;
bindIndicator.IncludeInIndex := True;
// Binding of the Period factor attribute
bindDLfacts := Bs.Add;
bindDLfacts.Dictionary := RubricatorDictionary.Facts;
bindDLfacts.AttributeId := "DL";
bindDLfacts.UseField := True;
bindDLfacts.SourceFieldId := "DL";
bindDLfacts.IncludeInIndex := True;
// Binding of the Value observation attribute
bindValues := Bs.Add;
bindValues.Dictionary := RubricatorDictionary.Values;
bindValues.AttributeId := "VL";
bindValues.UseField := True;
bindValues.SourceFieldId := "VALUE";
// Binding of the Date observation attribute
bindDate := Bs.Add;
bindDate.Dictionary := RubricatorDictionary.Values;
bindDate.AttributeId := "DT";
bindDate.UseField := True;
bindDate.SourceFieldId := "DT";
// Binding of the Actuality observation attribute
bindC := Bs.Add;
bindC.Dictionary := RubricatorDictionary.Values;
bindC.AttributeId := "ACT";
bindC.AttributeName := "Actuality";
bindC.UseField := False;
bindC.DataType := DbDataType.Boolean;
bindC.SourceValue := 1;
bindIndicator.Hidden := True;
// Set calendar dimension
mbObj := mb.ItemById("D_CALEND");
cr.TemplateCalendar := mbObj.Bind As ICalendarDimension;
// Set measures dictionary
mbObj := mb.ItemByIdNamespace("MEASURES", RdsKey);
cr.Measures := mbObj.Bind As IRdsDictionary;
// Set measurement units dictionary
mbObj := mb.ItemByIdNamespace("UNITS", RdsKey);
cr.Units := mbObj.Bind As IRdsDictionary;
// Create time series database
cr.CreateRubricator;
End Sub UserProc;
Example execution result: a time series database that is based on the T_TSDB data table will be created. The database contains custom attributes of the COUNTRY and INDICATOR factors that refer to the DICT_CTR and DICT_IND MDM dictionaries.
See also: