DuplicateCheck: CubeLoadDuplicateCheckSet;
DuplicateCheck: Prognoz.Platform.Interop.Cubes.CubeLoadDuplicateCheckSet;
The DuplicateCheck property determines a mode of excluding duplicate values.
To select time series loading mode, use the IImportRequestProviderParams.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 /> ImportRequestDef: IImportRequestDefinition;<br /> Params: IImportRequestProviderParams;<br /> Obj: IMetabaseObject;<br /> Bindings: ICubeMetaLoaderBindings;<br /> Binding: ICubeMetaLoaderBinding;<br /> DimM: IDimensionModel;<br /> Instance: IImportRequestInstance;<br /> </font><font color="#008080">Begin</font><font color="#000000"><br /> </font><font color="#008000">// Create data source for 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 import object<br /> </font><font color="#000000"> CrInfo := Mb.CreateCreateInfo;<br /> CrInfo.ClassId := MetabaseObjectClass.KE_CLASS_IMPORTREQUEST;<br /> CrInfo.Id := Mb.GenerateId(</font><font color="#800000">"OBJ_IMPORTREQUEST_P"</font><font color="#000000">, TSDBObj.Key);<br /> CrInfo.Name := </font><font color="#800000">"Import object"</font><font color="#000000">;<br /> CrInfo.Parent := TSDBObj;<br /> Obj := Mb.CreateObject(CrInfo).Edit;<br /> </font><font color="#008000">// Specify data source<br /> </font><font color="#000000"> ImportRequestDef := Obj </font><font color="#008080">As</font><font color="#000000"> IImportRequestDefinition;<br /> ImportRequestDef.SourceType := ImportRequestSourceType.Provider;<br /> </font><font color="#008000">// Specify data consumer<br /> </font><font color="#000000"> ImportRequestDef.DestinationRubricator := TSDB;<br /> </font><font color="#008000">// Set import parameters<br /> </font><font color="#000000"> Params := ImportRequestDef.ProviderParams;<br /> Params.Provider := TextProvider </font><font color="#008080">As</font><font color="#000000"> IDatasetDataProvider;<br /> Params.NewRevisionName := </font><font color="#800000">"Time series import"</font><font color="#000000">;<br /> Params.ImportObjectKey := Obj.Key;<br /> Params.LoadType := CubeMetaLoaderLoadType.CreateAndUpdate;<br /> Params.LoadMode := CubeLoadClearMode.DataAndMetadata;<br /> Params.DuplicateCheck := CubeLoadDuplicateCheckSet.ValueAttribute </font><font color="#008080">Or</font><font color="#000000"> CubeLoadDuplicateCheckSet.Value;<br /> </font><font color="#008000">// Specify scenario, to which data is loaded<br /> </font><font color="#000000"> Params.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 := Params.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 Units attribute (UNIT)<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 attribute (CITY)<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 Indicatros attribute (INDICATOR)<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 for import of 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">// Save changes in import object<br /> </font><font color="#000000"> Obj.Save;<br /> </font><font color="#008000">// Import data<br /> </font><font color="#000000"> Instance := (ImportRequestDef </font><font color="#008080">As</font><font color="#000000"> IMetabaseObject).Open(</font><font color="#008080">Null</font><font color="#000000">) </font><font color="#008080">As</font><font color="#000000"> IImportRequestInstance;<br /> Instance.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 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 /> ImportRequestDef: IImportRequestDefinition;<br /> ParamsImp: IImportRequestProviderParams;<br /> Obj: IMetabaseObject;<br /> Bindings: ICubeMetaLoaderBindings;<br /> Binding: ICubeMetaLoaderBinding;<br /> DimM: IDimensionModel;<br /> Instance: IImportRequestInstance;<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.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 import object<br /> </font><font color="#000000"> CrInfo := Mb.CreateCreateInfo();<br /> CrInfo.ClassId := MetabaseObjectClass.KE_CLASS_IMPORTREQUEST </font><font color="#008080">As</font><font color="#000000"> integer;<br /> CrInfo.Id := Mb.GenerateId(</font><font color="#800000">"OBJ_IMPORTREQUEST_P"</font><font color="#000000">, TSDBObj.Key);<br /> CrInfo.Name := </font><font color="#800000">"Import object"</font><font color="#000000">;<br /> CrInfo.Parent := TSDBObj;<br /> Obj := Mb.CreateObject(CrInfo).Edit();<br /> </font><font color="#008000">// Determine data source<br /> </font><font color="#000000"> ImportRequestDef := Obj </font><font color="#008080">As</font><font color="#000000"> IImportRequestDefinition;<br /> ImportRequestDef.SourceType := ImportRequestSourceType.irstProvider;<br /> </font><font color="#008000">// Determine data consumer<br /> </font><font color="#000000"> ImportRequestDef.DestinationRubricator := TSDB;<br /> </font><font color="#008000">// Set import parameters<br /> </font><font color="#000000"> ParamsImp := ImportRequestDef.ProviderParams;<br /> ParamsImp.Provider := TextProvider </font><font color="#008080">As</font><font color="#000000"> IDatasetDataProvider;<br /> ParamsImp.NewRevisionName := </font><font color="#800000">"Import time series"</font><font color="#000000">;<br /> ParamsImp.ImportObjectKey := Obj.Key;<br /> ParamsImp.LoadType := CubeMetaLoaderLoadType.cmlltCreateAndUpdate;<br /> ParamsImp.LoadMode := CubeLoadClearMode.clcmDataAndMetadata;<br /> ParamsImp.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"> ParamsImp.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 := ParamsImp.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 attribute (UNIT)<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 attribute (CITY)<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 attribute (INDICATOR)<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 observations 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">// Save changes to import object<br /> </font><font color="#000000"> Obj.Save();<br /> </font><font color="#008000">// Import data<br /> </font><font color="#000000"> Instance := (ImportRequestDef </font><font color="#008080">As</font><font color="#000000"> IMetabaseObject).Open(</font><font color="#008080">Null</font><font color="#000000">) </font><font color="#008080">As</font><font color="#000000"> IImportRequestInstance;<br /> Instance.LoadData();<br /> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">Sub</font><font color="#000000">;</font>
See also: