EditExistingObject: Boolean;
EditExistingObject: Boolean;
The EditExistingObject property determines whether the structure of the object, to which data is loaded, is edited.
If the property is set to True, the structure of the specified cube or time series database is edited before data loading. Editing is executed according to the set parameters of dimension and fact bindings. To be able to edit, the following conditions must be satisfied: a cube must be standard, cube dimensions must be based on table MDM dictionaries or a calendar.
If the property is set to False, the structure is not edited. For correct data loading, set correct bindings in the DimensionBindings and FactBindings properties.
Executing the example requires the C:\Data.xls file that contains data by countries. The data is located in columns named Country Name, Date and Value, an in some other fields. The repository contains a standard cube with the STD_CUBE identifier based on table MDM dictionaries and a calendar.
Sub UserProc;
Var
MB: IMetabase;
Loader: ICubeLoaderFromSource;
Provider: IDtExcelProvider;
StdCube: IStandardCube;
DimBindings: ICubeLoaderDimensionBindings;
DimBinding: ICubeLoaderDimensionBinding;
FactBindings: ICubeLoaderFactBindings;
FactBinding: ICubeLoaderFactBinding;
Begin
MB := MetabaseClass.Active;
//Data source for cube
Provider := New DtExcelProvider.Create;
Provider.DriverVersion := "Excel 8.0";
Provider.File := "C:\Data.xls";
Provider.HasHeader := True;
Provider.Query := "Select * From [Sheet1$]";
//Cube, which structure will be changed and data will be loaded
StdCube := MB.ItemById("STD_CUBE").Bind As IStandardCube;
//Cube data loader
Loader := New CubeLoaderFromSource.Create;
Loader.Cube := StdCube;
Loader.EditExistingObject := True;
//Binding dimensions
//Countries
DimBindings := Loader.DimensionBindings;
DimBinding := DimBindings.Add("Country Name");
DimBinding.Dimension := StdCube.Dimensions.FindById("COUNTRY");
DimBinding.Dictionary := DimBinding.Dimension.Dimension;
//Calendar
DimBinding := DimBindings.AddCalendar("Date", DimCalendarLevel.Month);
DimBinding.Dimension := StdCube.Dimensions.Calendar;
//Facts binding
FactBindings := Loader.FactBindings;
FactBinding := FactBindings.Add("Value");
FactBinding.FactKey := 2;
//Change cube structure and load data
Loader.Load(Provider, Null);
End Sub UserProc;
On executing the example the specified cube structure is changed, and data is loaded to it again. After the cube structure is changed, two dimensions are left in the cube, the field with data is bound to a fact with the 2 key.
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.Dal;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Dt;
Imports Prognoz.Platform.Interop.Metabase;
Public Sub Main(Params: StartParams);
Var
MB: IMetabase;
Loader: ICubeLoaderFromSource = New CubeLoaderFromSourceClass();
Provider: IDtExcelProvider = New DtExcelProviderClass();
StdCube: IStandardCube;
DimBindings: ICubeLoaderDimensionBindings;
DimBinding: ICubeLoaderDimensionBinding;
FactBindings: ICubeLoaderFactBindings;
FactBinding: ICubeLoaderFactBinding;
Begin
MB := Params.Metabase;
//Data source for cube
Provider.DriverVersion := "Excel 8.0";
Provider.File := "C:\Data.xls";
Provider.HasHeader := True;
Provider.Query := "Select * From [Sheet1$]";
//Cube, which structure will be changed and data will be loaded
StdCube := MB.ItemById["STD_CUBE"].Bind() As IStandardCube;
//Cube data loader
Loader.Cube := StdCube;
Loader.EditExistingObject := True;
//Binding dimensions
//Countries
DimBindings := Loader.DimensionBindings;
DimBinding := DimBindings.Add("Country Name");
DimBinding.Dimension := StdCube.Dimensions.FindById("COUNTRY");
DimBinding.Dictionary := DimBinding.Dimension.Dimension;
//Calendar
DimBinding := DimBindings.AddCalendar("Date", DimCalendarLevel.dclMonth);
DimBinding.Dimension := StdCube.Dimensions.Calendar;
//Facts binding
FactBindings := Loader.FactBindings;
FactBinding := FactBindings.Add("Value");
FactBinding.FactKey := 2;
//Change cube structure and load data
Loader.Load(Provider, Null);
End Sub;
See also: