CreateCube(CreateInfo: IMetabaseObjectCreateInfo): IStandardCube;
CreateCube(CreateInfo: Prognoz.Platform.Interop.Metabase.IMetabaseObjectCreateInfo): Prognoz.Platform.Interop.Cubes.IStandardCube;
CreateInfo. The description, according to which a cube is created.
The CreateCube method creates and sets up a standard cube.
The following operations are executed on executing the method:
According to the information specified in the CreateInfo parameter, a standard cube is created.
The cube structure contains facts and dimensions.
If the Table property is not specified, a table for storing cube data will be created.
Binding to the Table fields is set up for facts and dimensions.
The method results in a standard cube opened for edit.
Executing the example requires the following objects in the repository:
MDM repository with the MDM identifier.
Calendar dictionary with the CALENDAR identifier.
Folder with the F_CUBES identifier that stores the cubes.
Sub UserProc;
Var
MB: IMetabase;
Rds: IRdsDatabaseInstance;
CCreator: ICubeCreator;
Facts: ICubeCreatorFacts;
Dims: ICubeCreatorDimensions;
Dim: IDimensionModel;
CreatorDim1, CreatorDim2: ICubeCreatorDimension;
CrInfo: IMetabaseObjectCreateInfo;
TmpCube: IStandardCube;
Begin
MB := MetabaseClass.Active;
Rds := MB.ItemById("RDS").Open(Null) As IRdsDatabaseInstance;
//Cube creator
CCreator := New CubeCreator.Create;
CCreator.RdsDatabase := Rds;
CCreator.Database := Rds.DatabaseInstance;
//Cube dimensions collection
Dims := CCreator.Dimensions;
//New dimension, for which a personal dictionary is created
CreatorDim1 := Dims.AddNew("Dim1");
//Dimension that is based on the current dictionary
Dim := MB.ItemById("CALENDAR").Bind As IDimensionModel;
CreatorDim2 := Dims.Add(Dim);
//Block index, by which the cube binding to the table fields is executed
CreatorDim2.Index := Dim.Blocks.Item("MONTHS").Indexes.PrimaryIndex;
//Cube facts
Facts := CCreator.Facts;
Facts.Add("Fact1");
Facts.Add("Fact2");
//Information about creating a repository object
CrInfo := MB.CreateCreateInfo;
CrInfo.Parent := MB.ItemById("F_CUBES");
//Cube creation
TmpCube := CCreator.CreateCube(CrInfo);
(TmpCube As IMetabaseObject).Save;
End Sub UserProc;
The cube creator is initialized on executing the example. The dimensions collection is formed for cube creation: the first dimension is new (a new table MDM dictionary is created for dimension in MDM repository); the second dimension is created on the base of calendar dictionary. Two facts are to be created in the facts collection. A cube is created in the selected folder. On executing the CreateCube method the table is formed, in which the facts values are stored. Bindings of dimensions and facts are set up for this table.
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.Metabase;
Imports Prognoz.Platform.Interop.Rds;
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
Rds: IRdsDatabaseInstance;
CCreator: ICubeCreator;
Facts: ICubeCreatorFacts;
Dims: ICubeCreatorDimensions;
Dim: IDimensionModel;
CreatorDim1, CreatorDim2: ICubeCreatorDimension;
CrInfo: IMetabaseObjectCreateInfo;
TmpCube: IStandardCube;
Begin
MB := Params.Metabase;
Rds := MB.ItemById["RDS"].Open(Null) As IRdsDatabaseInstance;
//Cube creator
CCreator := New CubeCreatorClass();
CCreator.RdsDatabase := Rds;
CCreator.Database := Rds.DatabaseInstance;
//Cube dimensions collection
Dims := CCreator.Dimensions;
//New dimension, for which a personal dictionary is created
CreatorDim1 := Dims.AddNew("Dim1");
//Dimension that is based on the current dictionary
Dim := MB.ItemById["CALENDAR"].Bind() As IDimensionModel;
CreatorDim2 := Dims.Add(Dim);
//Block index, by which the cube binding to the table fields is executed
CreatorDim2.Index := Dim.Blocks.Item["MONTHS"].Indexes.PrimaryIndex;
//Cube facts
Facts := CCreator.Facts;
Facts.Add("Fact1");
Facts.Add("Fact2");
//Information about creating a repository object
CrInfo := MB.CreateCreateInfo();
CrInfo.Parent := MB.ItemById["F_CUBES"];
//Cube creation
TmpCube := CCreator.CreateCube(CrInfo);
(TmpCube As IMetabaseObject).Save();
End Sub;
See also: