DuplicateCheck: CubeLoadDuplicateCheckSet;
DuplicateCheck: Prognoz.Platform.Interop.Cubes.CubeLoadDuplicateCheckSet;
The DuplicateCheck property determines a mode of excluding duplicate values.
To select the time series loading mode, use the ICubeMetaLoader.LoadType property.
Executing the example requires a time series database with the TSDB_IMP identifier containing mandatory custom attributes with the CITY and INDICATOR identifiers. These attributes must be links to the dictionary. The child container of time series database must have several scenarios.
The file system must have the D:\res_export.txt file with data.
Contents of the res_export.txt file
Add links to the Cubes, Db, Dimensions, Dt, Metabase, Ms, Rds system assemblies.
<font color="#008080">Sub</font><font color="#000000"> UserProc;<br /> </font><font color="#008080">Var</font><font color="#000000"><br /> TextProvider: IDtTextProvider;<br /> Mb: IMetabase;<br /> TSDBObj: IMetabaseObject;<br /> TSDB: IRubricator;<br /> Attr: IMetaAttributes;<br /> CrInfo: IMetabaseObjectCreateInfo;<br /> Obj: IMetabaseObject;<br /> Loader: ICubeMetaLoader;<br /> Bindings: ICubeMetaLoaderBindings;<br /> Binding: ICubeMetaLoaderBinding;<br /> DimM: IDimensionModel;<br /> </font><font color="#008080">Begin</font><font color="#000000"><br /> </font><font color="#008000">// Create data source to import from text file<br /> </font><font color="#000000"> TextProvider := </font><font color="#008080">New</font><font color="#000000"> DtTextProvider.Create;<br /> TextProvider.File := </font><font color="#800000">"D:\res_export.txt"</font><font color="#000000">;<br /> TextProvider.FormatType := DtTextFormatType.Delimited;<br /> TextProvider.DelimitedColumnDelimiter := </font><font color="#800000">";"</font><font color="#000000">;<br /> TextProvider.DelimitedTextQualifier := </font><font color="#800000">""""</font><font color="#000000">;<br /> TextProvider.Encoding := </font><font color="#800000">"WIN"</font><font color="#000000">;<br /> TextProvider.RangeHasHeader := </font><font color="#008080">True</font><font color="#000000">;<br /> TextProvider.Open;<br /> </font><font color="#008000">// Get time series database<br /> </font><font color="#000000"> Mb := MetabaseClass.Active;<br /> TSDBObj := Mb.ItemById(</font><font color="#800000">"TSDB_IMP"</font><font color="#000000">).Bind;<br /> TSDB := TSDBObj </font><font color="#008080">As</font><font color="#000000"> IRubricator;<br /> Attr := TSDB.Facts.Attributes;<br /> </font><font color="#008000">// Create object to load time series<br /> </font><font color="#000000"> CrInfo := Mb.CreateCreateInfo;<br /> CrInfo.ClassId := MetabaseObjectClass.KE_CLASS_CUBEMETALOADER;<br /> CrInfo.Parent := TSDBObj;<br /> CrInfo.Id := Mb.GenerateId(</font><font color="#800000">"CUBEMETALOADER"</font><font color="#000000">, TSDBObj.Key);<br /> CrInfo.Permanent := </font><font color="#008080">False</font><font color="#000000">;<br /> Obj := Mb.CreateObject(CrInfo).Edit;<br /> Loader := Obj </font><font color="#008080">As</font><font color="#000000"> ICubeMetaLoader;<br /> </font><font color="#008000">// Set data source<br /> </font><font color="#000000"> Loader.Data := TextProvider </font><font color="#008080">As</font><font color="#000000"> IDatasetDataProvider;<br /> </font><font color="#008000">// Set data consumer<br /> </font><font color="#000000"> Loader.Rubricator := TSDB;<br /> </font><font color="#008000">// Set data loading parameters<br /> </font><font color="#000000"> Loader.ImportObjectKey := Obj.Key;<br /> Loader.NewRevisionName := </font><font color="#800000">"Update data"</font><font color="#000000">;<br /> Loader.LoadType := CubeMetaLoaderLoadType.CreateAndUpdate;<br /> Loader.LoadMode := CubeLoadClearMode.DataAndMetadata;<br /> Loader.DuplicateCheck := CubeLoadDuplicateCheckSet.ValueAttribute </font><font color="#008080">Or</font><font color="#000000"> CubeLoadDuplicateCheckSet.Value;<br /> </font><font color="#008000">// Determine scenario to which data will be loaded<br /> </font><font color="#000000"> Loader.ScenarioKey := (TSDB.ModelSpace </font><font color="#008080">As</font><font color="#000000"> IMsModelSpace).ScenarioTree.Item(</font><font color="#008000">0</font><font color="#000000">).Key;<br /> </font><font color="#008000">// Set attribute binding<br /> </font><font color="#000000"> Bindings := Loader.Bindings;<br /> </font><font color="#008000">// Set calendar binding<br /> </font><font color="#000000"> Binding := Bindings.Add;<br /> Binding.BindingType := CubeMetaLoaderBindingType.Calendar;<br /> Binding.ByColumns := </font><font color="#008080">False</font><font color="#000000">;<br /> Binding.CalendarDateFormat := </font><font color="#800000">"$Year$"</font><font color="#000000">;<br /> Binding.CalendarOptions.Levels := DimCalendarLevelSet.Year;<br /> Binding.FieldType := CubeMetaLoaderFieldType.Name;<br /> Binding.Field := </font><font color="#800000">"Year"</font><font color="#000000">;<br /> </font><font color="#008000">// Set binding of the Measurement Units (UNIT) attribute<br /> </font><font color="#000000"> Binding := Bindings.Add;<br /> Binding.BindingType := CubeMetaLoaderBindingType.Unit;<br /> Binding.FieldType := CubeMetaLoaderFieldType.ConstValue;<br /> Binding.FieldValue := </font><font color="#008000">1</font><font color="#000000">;<br /> Binding.Attribute := </font><font color="#800000">"UNIT"</font><font color="#000000">;<br /> DimM := Attr.FindById(</font><font color="#800000">"UNIT"</font><font color="#000000">).ValuesObject.Bind </font><font color="#008080">As</font><font color="#000000"> IDimensionModel;<br /> Binding.Dimension := DimM;<br /> Binding.Index := DimM.Indexes.Item(</font><font color="#008000">0</font><font color="#000000">).Id;<br /> Binding.KeyAttribute := </font><font color="#800000">"KEY"</font><font color="#000000">;<br /> </font><font color="#008000">// Set binding of the Cities (CITY) attribute<br /> </font><font color="#000000"> Binding := Bindings.Add;<br /> Binding.BindingType := CubeMetaLoaderBindingType.Attribute;<br /> Binding.Attribute := </font><font color="#800000">"CITY"</font><font color="#000000">;<br /> Binding.FieldType := CubeMetaLoaderFieldType.Name;<br /> Binding.Field := </font><font color="#800000">"CITY_KEY"</font><font color="#000000">;<br /> DimM := Attr.FindById(</font><font color="#800000">"CITY"</font><font color="#000000">).ValuesObject.Bind </font><font color="#008080">As</font><font color="#000000"> IDimensionModel;<br /> Binding.Dimension := DimM;<br /> Binding.Index := DimM.Indexes.Item(</font><font color="#008000">0</font><font color="#000000">).Id;<br /> Binding.KeyAttribute := </font><font color="#800000">"KEY"</font><font color="#000000">;<br /> Binding.NameAttribute := </font><font color="#800000">"NAME"</font><font color="#000000">;<br /> </font><font color="#008000">// Set binding of the Indicators (INDICATOR) attribute<br /> </font><font color="#000000"> Binding := Bindings.Add;<br /> Binding.BindingType := CubeMetaLoaderBindingType.Attribute;<br /> Binding.Attribute := </font><font color="#800000">"INDICATOR"</font><font color="#000000">;<br /> Binding.FieldType := CubeMetaLoaderFieldType.Name;<br /> Binding.Field := </font><font color="#800000">"INDICATOR_KEY"</font><font color="#000000">;<br /> DimM := Attr.FindById(</font><font color="#800000">"INDICATOR"</font><font color="#000000">).ValuesObject.Bind </font><font color="#008080">As</font><font color="#000000"> IDimensionModel;<br /> Binding.Dimension := DimM;<br /> Binding.Index := DimM.Indexes.Item(</font><font color="#008000">0</font><font color="#000000">).Id;<br /> Binding.KeyAttribute := </font><font color="#800000">"KEY"</font><font color="#000000">;<br /> Binding.NameAttribute := </font><font color="#800000">"NAME"</font><font color="#000000">;<br /> </font><font color="#008000">// Set binding to import series observation values<br /> </font><font color="#000000"> Binding := Bindings.Add;<br /> Binding.BindingType := CubeMetaLoaderBindingType.Value;<br /> Binding.FieldType := CubeMetaLoaderFieldType.Name;<br /> Binding.Field := </font><font color="#800000">"Value"</font><font color="#000000">;<br /> </font><font color="#008000">// Load data<br /> </font><font color="#000000"> Loader.LoadData;<br /> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">Sub</font><font color="#000000"> UserProc;</font>
After executing the example the data from the "D:\res_export.txt" file will be imported to the time series database for the first scenario, and duplicate data will be excluded.
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.Ms;
Imports Prognoz.Platform.Interop.Rds;
<font color="#008080">Public</font><font color="#000000"> </font><font color="#008080">Shared</font><font color="#000000"> </font><font color="#008080">Sub</font><font color="#000000"> Main(Params: StartParams);<br /> </font><font color="#008080">Var</font><font color="#000000"><br /> TextProvider: IDtTextProvider;<br /> Mb: IMetabase;<br /> TSDBObj: IMetabaseObject;<br /> TSDB: IRubricator;<br /> Attr: IMetaAttributes;<br /> CrInfo: IMetabaseObjectCreateInfo;<br /> Obj: IMetabaseObject;<br /> Loader: ICubeMetaLoader;<br /> Bindings: ICubeMetaLoaderBindings;<br /> Binding: ICubeMetaLoaderBinding;<br /> DimM: IDimensionModel;<br /> </font><font color="#008080">Begin</font><font color="#000000"><br /> </font><font color="#008000">// Create a data source to import from text file<br /> </font><font color="#000000"> TextProvider := </font><font color="#008080">New</font><font color="#000000"> DtTextProvider.Create();<br /> TextProvider.File := </font><font color="#800000">"D:\res_export.txt"</font><font color="#000000">;<br /> TextProvider.FormatType := DtTextFormatType.tftDelimited;<br /> TextProvider.DelimitedColumnDelimiter := </font><font color="#800000">";"</font><font color="#000000">;<br /> TextProvider.DelimitedTextQualifier := </font><font color="#800000">""""</font><font color="#000000">;<br /> TextProvider.Encoding := </font><font color="#800000">"WIN"</font><font color="#000000">;<br /> TextProvider.RangeHasHeader := </font><font color="#008080">True</font><font color="#000000">;<br /> TextProvider.Open();<br /> </font><font color="#008000">// Get time series database<br /> </font><font color="#000000"> Mb := Params.Metabase;<br /> TSDBObj := Mb.ItemById[</font><font color="#800000">"TSDB_IMP"</font><font color="#000000">].Bind();<br /> TSDB := TSDBObj </font><font color="#008080">As</font><font color="#000000"> IRubricator;<br /> Attr := TSDB.Facts.Attributes;<br /> </font><font color="#008000">// Create an object to load time series<br /> </font><font color="#000000"> CrInfo := Mb.CreateCreateInfo();<br /> CrInfo.ClassId := MetabaseObjectClass.KE_CLASS_CUBEMETALOADER </font><font color="#008080">As</font><font color="#000000"> integer;<br /> CrInfo.Parent := TSDBObj;<br /> CrInfo.Id := Mb.GenerateId(</font><font color="#800000">"CUBEMETALOADER"</font><font color="#000000">, TSDBObj.Key);<br /> CrInfo.Permanent := </font><font color="#008080">False</font><font color="#000000">;<br /> Obj := Mb.CreateObject(CrInfo).Edit();<br /> Loader := Obj </font><font color="#008080">As</font><font color="#000000"> ICubeMetaLoader;<br /> </font><font color="#008000">// Determine data source<br /> </font><font color="#000000"> Loader.Data := TextProvider </font><font color="#008080">As</font><font color="#000000"> IDatasetDataProvider;<br /> </font><font color="#008000">// Determine data consumer<br /> </font><font color="#000000"> Loader.Rubricator := TSDB;<br /> </font><font color="#008000">// Set data loading parameters<br /> </font><font color="#000000"> Loader.ImportObjectKey := Obj.Key;<br /> Loader.NewRevisionName := </font><font color="#800000">"Update data"</font><font color="#000000">;<br /> Loader.LoadType := CubeMetaLoaderLoadType.cmlltCreateAndUpdate;<br /> Loader.LoadMode := CubeLoadClearMode.clcmDataAndMetadata;<br /> Loader.DuplicateCheck := CubeLoadDuplicateCheckSet.cldcValueAttribute </font><font color="#008080">Or</font><font color="#000000"> CubeLoadDuplicateCheckSet.cldcValue;<br /> </font><font color="#008000">// Set scenario to which data will be loaded<br /> </font><font color="#000000"> Loader.ScenarioKey := (TSDB.ModelSpace </font><font color="#008080">As</font><font color="#000000"> IMsModelSpace).ScenarioTree.Item[</font><font color="#008000">0</font><font color="#000000">].Key </font><font color="#008080">As</font><font color="#000000"> integer;<br /> </font><font color="#008000">// Set attribute binding<br /> </font><font color="#000000"> Bindings := Loader.Bindings;<br /> </font><font color="#008000">// Set calendar binding<br /> </font><font color="#000000"> Binding := Bindings.Add();<br /> Binding.BindingType := CubeMetaLoaderBindingType.cmlbtCalendar;<br /> Binding.ByColumns := </font><font color="#008080">False</font><font color="#000000">;<br /> Binding.CalendarDateFormat := </font><font color="#800000">"$Year$"</font><font color="#000000">;<br /> Binding.CalendarOptions.Levels := DimCalendarLevelSet.dclsYear;<br /> Binding.FieldType := CubeMetaLoaderFieldType.cmlftName;<br /> Binding.Field := </font><font color="#800000">"Year"</font><font color="#000000">;<br /> </font><font color="#008000">// Set binding of the Measurement Units (UNIT) attribute<br /> </font><font color="#000000"> Binding := Bindings.Add();<br /> Binding.BindingType := CubeMetaLoaderBindingType.cmlbtUnit;<br /> Binding.FieldType := CubeMetaLoaderFieldType.cmlftConstValue;<br /> Binding.FieldValue := </font><font color="#008000">1</font><font color="#000000">;<br /> Binding.Attribute := </font><font color="#800000">"UNIT"</font><font color="#000000">;<br /> DimM := Attr.FindById(</font><font color="#800000">"UNIT"</font><font color="#000000">).ValuesObject.Bind() </font><font color="#008080">As</font><font color="#000000"> IDimensionModel;<br /> Binding.Dimension := DimM;<br /> Binding.Index := DimM.Indexes.Item[</font><font color="#008000">0</font><font color="#000000">].Id;<br /> Binding.KeyAttribute := </font><font color="#800000">"KEY"</font><font color="#000000">;<br /> </font><font color="#008000">// Set binding of the Cities (CITY) attribute<br /> </font><font color="#000000"> Binding := Bindings.Add();<br /> Binding.BindingType := CubeMetaLoaderBindingType.cmlbtAttribute;<br /> Binding.Attribute := </font><font color="#800000">"CITY"</font><font color="#000000">;<br /> Binding.FieldType := CubeMetaLoaderFieldType.cmlftName;<br /> Binding.Field := </font><font color="#800000">"CITY_KEY"</font><font color="#000000">;<br /> DimM := Attr.FindById(</font><font color="#800000">"CITY"</font><font color="#000000">).ValuesObject.Bind() </font><font color="#008080">As</font><font color="#000000"> IDimensionModel;<br /> Binding.Dimension := DimM;<br /> Binding.Index := DimM.Indexes.Item[</font><font color="#008000">0</font><font color="#000000">].Id;<br /> Binding.KeyAttribute := </font><font color="#800000">"KEY"</font><font color="#000000">;<br /> Binding.NameAttribute := </font><font color="#800000">"NAME"</font><font color="#000000">;<br /> </font><font color="#008000">// Set binding of the Factors (INDICATOR) attribute<br /> </font><font color="#000000"> Binding := Bindings.Add();<br /> Binding.BindingType := CubeMetaLoaderBindingType.cmlbtAttribute;<br /> Binding.Attribute := </font><font color="#800000">"INDICATOR"</font><font color="#000000">;<br /> Binding.FieldType := CubeMetaLoaderFieldType.cmlftName;<br /> Binding.Field := </font><font color="#800000">"INDICATOR_KEY"</font><font color="#000000">;<br /> DimM := Attr.FindById(</font><font color="#800000">"INDICATOR"</font><font color="#000000">).ValuesObject.Bind() </font><font color="#008080">As</font><font color="#000000"> IDimensionModel;<br /> Binding.Dimension := DimM;<br /> Binding.Index := DimM.Indexes.Item[</font><font color="#008000">0</font><font color="#000000">].Id;<br /> Binding.KeyAttribute := </font><font color="#800000">"KEY"</font><font color="#000000">;<br /> Binding.NameAttribute := </font><font color="#800000">"NAME"</font><font color="#000000">;<br /> </font><font color="#008000">// Set binding to import series observation values<br /> </font><font color="#000000"> Binding := Bindings.Add();<br /> Binding.BindingType := CubeMetaLoaderBindingType.cmlbtValue;<br /> Binding.FieldType := CubeMetaLoaderFieldType.cmlftName;<br /> Binding.Field := </font><font color="#800000">"Value"</font><font color="#000000">;<br /> </font><font color="#008000">// Load data<br /> </font><font color="#000000"> Loader.LoadData();<br /> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">Sub</font><font color="#000000">;</font>
See also: