IsMetabaseProvider: Boolean;
IsMetabaseProvider: boolean;
The IsMetabaseProvider property determines whether source data is loaded to the repository.
Available values:
True. Data is loaded from source to repository.
False. Data is loaded from external data source.
Executing the example requires that the repository contains a folder with the CUBE_FOLDER identifier and a data table with the TABLE_DATA identifier. This table must contain the following fields:
Indicator. String field containing indicator names.
City. String field containing city names.
Year. Field of data type containing years.
Value. Field of real type containing value of the indicator for corresponding city for some year.
The repository must also contain MDM repository with the RDS_LOAD identifier.
The example uses the Converter custom class. Class implementation is given in the example for IValueConverter.Convert.
Add links to the Cubes, Db, Dimensions, Dt, Metabase, Rds system assemblies.
Sub UserProc;
Var
mb: IMetabase;
cube, parent: IMetabaseObject;
rdsDatabase: IRdsDatabase;
loader: ICubeLoaderFromSource;
DimBindings: ICubeLoaderDimensionBindings;
FactBindings: ICubeLoaderFactBindings;
Fact: ICubeLoaderFactBinding;
Conv: Converter;
provider: IDtProvider;
Begin
// Get current repository
mb := MetabaseClass.Active;
// Get the folder, in which a cube is created
parent := mb.ItemById("CUBE_FOLDER").Bind;
// Get the MDM repository, in which dictionaries are created
rdsDatabase := mb.ItemById("RDS_LOAD").Bind As IRdsDatabase;
// Create an object for cube creation
loader := New CubeLoaderFromSource.Create;
loader.Type := CubeLoaderType.Cube;
// Specify MDM repository that will be used
loader.RdsDatabase := rdsDatabase.Open(Null);
// Specify the folder, in which a cube is created
loader.Parent := parent;
// Specify that cube is created based on table
loader.IsMetabaseProvider := True;
// Get parameters of binding cube dimensions
DimBindings := loader.DimensionBindings;
// Add cube dimensions
DimBindings.Add("CITY");
DimBindings.Add("INDICATOR");
// Add a calendar dimension
DimBindings.AddCalendar("YEAR", DimCalendarLevel.Year);
// Get collection of bindings for fact dimension
FactBindings := loader.FactBindings;
// Specify that facts in cube are local
FactBindings.CreateExternalDimension := False;
// Add a fact dimension
Fact := FactBindings.Add("VALUE");
// Create a value transformer
Conv := New Converter.Create;
// Specify that values of the VALUE field must be transformed
Fact.Converter := Conv;
// Create a data source
provider := New DtMetabaseProvider.Create As IDtProvider;
// Specify the table, from which data is loaded
(provider As IDtMetabaseProvider).Dataset := mb.ItemById("TABLE_DATA").Bind As IDatasetModel;
// Create a cube and load data
cube := loader.Load(provider, Null);
// Save cube
cube.Save;
End Sub UserProc;
After executing the example a cube based on data of the TABLE_DATA table is created in the repository in the CUBE_FOLDER folder.
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.Db;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Dt;
Imports Prognoz.Platform.Interop.Rds;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
cube, parent: IMetabaseObject;
rdsDatabase: IRdsDatabase;
loader: ICubeLoaderFromSource;
DimBindings: ICubeLoaderDimensionBindings;
FactBindings: ICubeLoaderFactBindings;
Fact: ICubeLoaderFactBinding;
Conv: Converter;
provider: IDtProvider;
Begin
// Get current repository
mb := Params.Metabase;
// Get the folder, in which a cube is created
parent := mb.ItemById["CUBE_FOLDER"].Bind();
// Get the MDM repository, in which dictionaries are created
rdsDatabase := mb.ItemById["RDS_LOAD"].Bind() As IRdsDatabase;
// Create an object for cube creation
loader := New CubeLoaderFromSource.Create();
loader.Type := CubeLoaderType.cltCube;
// Specify MDM repository that will be used
loader.RdsDatabase := rdsDatabase.Open(Null);
// Specify the folder, in which a cube is created
loader.Parent := parent;
// Specify that cube is created based on table
loader.IsMetabaseProvider := True;
// Get parameters of binding cube dimensions
DimBindings := loader.DimensionBindings;
// Add cube dimensions
DimBindings.Add("CITY");
DimBindings.Add("INDICATOR");
// Add a calendar dimension
DimBindings.AddCalendar("YEAR", DimCalendarLevel.dclYear);
// Get collection of bindings for fact dimension
FactBindings := loader.FactBindings;
// Specify that facts in cube are local
FactBindings.CreateExternalDimension := False;
// Add a fact dimension
Fact := FactBindings.Add("VALUE");
// Create a value transformer
Conv := New Converter.Create();
// Specify that values of the VALUE field must be transformed
Fact.Converter := Conv;
// Create a data source
provider := New DtMetabaseProvider.Create() As IDtProvider;
// Specify the table, from which data is loaded
(provider As IDtMetabaseProvider).Dataset := mb.ItemById["TABLE_DATA"].Bind() As IDatasetModel;
// Create a cube and load data
cube := loader.Load(provider, Null);
// Save cube
cube.Save();
End Sub;
See also: