IImportRequestProviderParams.DuplicateCheck

Syntax

DuplicateCheck: CubeLoadDuplicateCheckSet;

Description

The DuplicateCheck property determines a mode of excluding duplicate values.

Comments

To select time series loading mode, use the IImportRequestProviderParams.LoadType property.

Example

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.

Sub UserProc;
Var
    TextProvider: IDtTextProvider;
    Mb: IMetabase;
    TSDBObj: IMetabaseObject;
    TSDB: IRubricator;
    Attr: IMetaAttributes;
    CrInfo: IMetabaseObjectCreateInfo;
    ImportRequestDef: IImportRequestDefinition;
    Params: IImportRequestProviderParams;
    Obj: IMetabaseObject;
    Bindings: ICubeMetaLoaderBindings;
    Binding: ICubeMetaLoaderBinding;
    DimM: IDimensionModel;
    Instance: IImportRequestInstance;
Begin
    
// Create a data source for import from text file
    TextProvider := New DtTextProvider.Create;
    TextProvider.File := 
"D:\res_export.txt";
    TextProvider.FormatType := DtTextFormatType.Delimited;
    TextProvider.DelimitedColumnDelimiter := 
";";
    TextProvider.DelimitedTextQualifier := 
"""";
    TextProvider.Encoding := 
"WIN";
    TextProvider.RangeHasHeader := 
True;
    TextProvider.Open;
    
// Get time series database
    Mb := MetabaseClass.Active;
    TSDBObj := Mb.ItemById(
"TSDB_IMP").Bind;
    TSDB := TSDBObj 
As IRubricator;
    Attr := TSDB.Facts.Attributes;

    // Create an import object
    CrInfo := Mb.CreateCreateInfo;
    CrInfo.ClassId := MetabaseObjectClass.KE_CLASS_IMPORTREQUEST;
    CrInfo.Id := Mb.GenerateId(
"OBJ_IMPORTREQUEST_P", TSDBObj.Key);
    CrInfo.Name := 
"Import object";
    CrInfo.Parent := TSDBObj;
    Obj := Mb.CreateObject(CrInfo).Edit;
    
// Specify data provider
    ImportRequestDef := Obj As IImportRequestDefinition;
    ImportRequestDef.SourceType := ImportRequestSourceType.Provider;
    
// Specify data consumer
    ImportRequestDef.DestinationRubricator := TSDB;
    
// Set import options
    Params := ImportRequestDef.ProviderParams;
    Params.Provider := TextProvider 
As IDatasetDataProvider;
    Params.NewRevisionName := 
"Import of time series";
    Params.ImportObjectKey := Obj.Key;
    Params.LoadType := CubeMetaLoaderLoadType.CreateAndUpdate;
    Params.LoadMode := CubeLoadClearMode.DataAndMetadata;
    Params.DuplicateCheck := CubeLoadDuplicateCheckSet.ValueAttribute 
Or CubeLoadDuplicateCheckSet.Value;
    
// Specify scenario, to which data will be loaded
    Params.ScenarioKey := (TSDB.ModelSpace As IMsModelSpace).ScenarioTree.Item(0).Key;

    // Set attribute binding
    Bindings := Params.Bindings;
    
// Set calendar binding
    Binding := Bindings.Add;
    Binding.BindingType := CubeMetaLoaderBindingType.Calendar;
    Binding.ByColumns := 
False;
    Binding.CalendarDateFormat := 
"$Year$";
    Binding.CalendarOptions.Levels := DimCalendarLevelSet.Year;
    Binding.FieldType := CubeMetaLoaderFieldType.Name;
    Binding.Field := 
"Year";
    
// Set binding of the Measurement Units attribute (UNIT)
    Binding := Bindings.Add;
    Binding.BindingType := CubeMetaLoaderBindingType.Unit;
    Binding.FieldType := CubeMetaLoaderFieldType.ConstValue;
    Binding.FieldValue := 
1;
    Binding.Attribute := 
"UNIT";
    DimM := Attr.FindById(
"UNIT").ValuesObject.Bind As IDimensionModel;
    Binding.Dimension := DimM;
    Binding.Index := DimM.Indexes.Item(
0).Id;
    Binding.KeyAttribute := 
"KEY";
    
// Set binding of the Cities attribute (CITY)
    Binding := Bindings.Add;
    Binding.BindingType := CubeMetaLoaderBindingType.Attribute;
    Binding.Attribute := 
"CITY";
    Binding.FieldType := CubeMetaLoaderFieldType.Name;
    Binding.Field := 
"CITY_KEY";
    DimM := Attr.FindById(
"CITY").ValuesObject.Bind As IDimensionModel;
    Binding.Dimension := DimM;
    Binding.Index := DimM.Indexes.Item(
0).Id;
    Binding.KeyAttribute := 
"KEY";
    Binding.NameAttribute := 
"NAME";

    // Set binding of the Indicators attribute (INDICATOR)
    Binding := Bindings.Add;
    Binding.BindingType := CubeMetaLoaderBindingType.Attribute;
    Binding.Attribute := 
"INDICATOR";
    Binding.FieldType := CubeMetaLoaderFieldType.Name;
    Binding.Field := 
"INDICATOR_KEY";
    DimM := Attr.FindById(
"INDICATOR").ValuesObject.Bind As IDimensionModel;
    Binding.Dimension := DimM;
    Binding.Index := DimM.Indexes.Item(
0).Id;
    Binding.KeyAttribute := 
"KEY";
    Binding.NameAttribute := 
"NAME";
    
// Set binding for import of values of series observations
    Binding := Bindings.Add;
    Binding.BindingType := CubeMetaLoaderBindingType.Value;
    Binding.FieldType := CubeMetaLoaderFieldType.Name;
    Binding.Field := 
"Value";
    
// Save changes in import object
    Obj.Save;
    
// Import data
    Instance := (ImportRequestDef As IMetabaseObject).Open(NullAs IImportRequestInstance;
    Instance.LoadData;
End Sub UserProc;

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.

See also:

IImportRequestProviderParams