ProviderParams: IImportRequestProviderParams;
The ProviderParams property returns the object that contains parameters of time series import from a data source (excluding time series database).
Executing the example requires a time series database with the OBJ_RUBRICATOR identifier and the time series export file C:\result.txt. Also, the repository must contain an MDM repository with the RDS identifier including the COUNTRY dictionary and other system dictionaries required for working of the time series database. The COUNTRY additional mandatory attribute referring to the countries dictionary has been created in the time series database. Add links to the following system assemblies: Cubes, Db, Dimensions, Dt, Metabase.
Sub CreateImportRequest;
Var
TextProvider: IDtTextProvider;
Mb: IMetabase;
RubDesc, NSIDesc: IMetabaseObjectDescriptor;
CrInfo: IMetabaseObjectCreateInfo;
Obj: IMetabaseObject;
ImportRequestDef: IImportRequestDefinition;
Params: IImportRequestProviderParams;
Bindings: ICubeMetaLoaderBindings;
Binding: ICubeMetaLoaderBinding;
Begin
// Data source for importing from text file
TextProvider := New DtTextProvider.Create;
TextProvider.File := "C:\result.txt";
TextProvider.FormatType := DtTextFormatType.Delimited;
TextProvider.DelimitedColumnDelimiter := ";";
TextProvider.DelimitedTextQualifier := """";
TextProvider.Encoding := "WIN";
TextProvider.RangeHasHeader := True;
TextProvider.Open;
// Create an import schema
Mb := MetabaseClass.Active;
RubDesc := Mb.ItemById("OBJ_RUBRICATOR");
NSIDesc := Mb.ItemById("RDS");
// Import object
CrInfo := Mb.CreateCreateInfo;
CrInfo.ClassId := MetabaseObjectClass.KE_CLASS_IMPORTREQUEST;
CrInfo.Id := "OBJ_IMPORTREQUEST_P";
CrInfo.Name := "Import object";
CrInfo.Parent := RubDesc.Bind;
Obj := Mb.CreateObject(CrInfo).Edit;
// Set up source
ImportRequestDef := Obj As IImportRequestDefinition;
ImportRequestDef.SourceType := ImportRequestSourceType.Provider;
ImportRequestDef.DestinationRubricator := RubDesc.Bind As IRubricator;
// Import parameters
Params := ImportRequestDef.ProviderParams;
Params.Provider := TextProvider As IDatasetDataProvider;
Params.NewRevisionName := "Factors import";
Params.ImportObjectKey := Obj.Key;
Params.LoadType := CubeMetaLoaderLoadType.CreateAndUpdate;
Bindings := Params.Bindings;
// Attributes binding
// Calendar
Binding := Bindings.Add;
Binding.BindingType := CubeMetaLoaderBindingType.Calendar;
Binding.CalendarOptions.Levels := DimCalendarLevelSet.Year;
Binding.ByColumns := True;
Binding.CalendarDateFormat := "$Year$A1";
Binding.FieldType := CubeMetaLoaderFieldType.Name;
Binding.Field := "1990A1";
Binding.EndField := "2000A1";
// Measurement units
Binding := Bindings.Add;
Binding.BindingType := CubeMetaLoaderBindingType.Unit;
Binding.FieldType := CubeMetaLoaderFieldType.Name;
Binding.Field := "Units";
Binding.Dimension := Mb.ItemByIdNamespace("UNITS", NSIDesc.Key).Bind As IDimensionModel;
Binding.Index := "PRIMARY_INDEX";
Binding.KeyAttribute := "KEY";
// Frequency
Binding := Bindings.Add;
Binding.BindingType := CubeMetaLoaderBindingType.Attribute;
Binding.Attribute := "DL";
Binding.FieldType := CubeMetaLoaderFieldType.ConstValue;
Binding.FieldValue := DimCalendarLevel.Year;
// Countries
Binding := Bindings.Add;
Binding.BindingType := CubeMetaLoaderBindingType.Attribute;
Binding.Attribute := "COUNTRY";
Binding.FieldType := CubeMetaLoaderFieldType.Name;
Binding.Field := "Code";
Binding.CheckField := "Country";
Binding.Dimension := Mb.ItemByIdNamespace("COUNTRY", NsiDesc.Key).Bind As IDimensionModel;
Binding.Index := "UNIQUEKEY";
Binding.KeyAttribute := "KEY";
Binding.NameAttribute := "NAME";
// Binding by index of all fields with values
//...
Binding := Bindings.Add;
Binding.BindingType := CubeMetaLoaderBindingType.Value;
Binding.FieldType := CubeMetaLoaderFieldType.Index;
Binding.Field := "3";
//...
// Same code blocks by binding other fields with values
// Only field number is changed in each block
//...
// Save import schema
Obj.Save;
End Sub CreateImportRequest;
On executing the example an time series import object is created from the C:\result.txt file. In this object the user can set up calendar parameters and parameters of binding attributes of the time series database to fields with data.
See also: