LoadWithResult(Source: Object; CreateInfo: IMetabaseObjectCreateInfo): ICubeLoaderResult;
Source. The data source described by the IDtProvider interface.
CreateInfo. Information about the created object. If information is missing or loading to the current object is executed, the Null value must be passed as a parameter.
The LoadWithResult method loads data and returns loading result.
The type of created object determines value of the ICubeLoaderFromSource.Type property.
Executing the example requires the following in the repository:
Folder with the TSDB_FOLDER identifier.
MDM repository with the RDS_LOAD identifier.
Table MDM dictionary with the CITY_DICT identifier. This dictionary must be outside the MDM repository. The dictionary must also contain a unique index with the UINDEX identifier. This index must include only one attribute with the NAME identifier. The attribute contains names of dictionary elements. The dictionary must contain the following elements:
Anchorage.
Mexico.
Chicago.
The file system must contain the C:\result_exp.txt file with data.
Add links to the Collections, Cubes, Dimensions, Dt, Metabase, Rds system assemblies.
Contents of the C:\result_exp.txt file
Sub UserProc;
Var
mb: IMetabase;
parent: IMetabaseObject;
rdsDatabase: IRdsDatabase;
loader: ICubeLoaderFromSource;
DimBindings: ICubeLoaderDimensionBindings;
bind: ICubeLoaderDimensionBinding;
DimModel: IDimensionModel;
Calend: ICubeLoaderDimensionBinding;
DateConv: IDateConverter;
creator: IDtObjectCreator;
prov: IDtTextProvider;
Result: ICubeLoaderResult;
Object: IMetabaseObject;
List, Arr: IArrayList;
Item: Variant;
i: Integer;
Begin
// Get the current repository
mb := MetabaseClass.Active;
// Get the TSDB_FOLDER folder, in which a time
// series database will be created
parent := mb.ItemById("TSDB_FOLDER").Bind;
// Get MDM repository
rdsDatabase := mb.ItemById("RDS_LOAD").Bind As IRdsDatabase;
// Create an object for data loading
loader := New CubeLoaderFromSource.Create;
// Specify the MDM repository that will be used during loading
loader.RdsDatabase := rdsDatabase.Open(Null);
// Specify that a time series database will be
// created for loaded data
loader.Type := CubeLoaderType.Rubricator;
// Specify the folder, in which a time series database will be created
loader.Parent := parent;
// Get bindings of dimensions to data provider fields
DimBindings := loader.DimensionBindings;
// Add a binding for the CITY field
bind := DimBindings.Add("CITY");
// Specify that the field will have a corresponding dimension
// based on the CITY_DICT MDM dictionary
DimModel := mb.ItemById("CITY_DICT").Bind As IDimensionModel;
bind.Dictionary := DimModel;
// Specify the index, by which a binding will be created
bind.Index := DimModel.Indexes.FindById("UINDEX");
// Specify identifier of the attribute, on which index is based
bind.AttributeId := "NAME";
// Add a binding for the INDICATOR field.
// Dictionary for creating a dimension corresponding to this field
// will be created automatically in the RDS_LOAD MDM repository
DimBindings.Add("INDICATOR");
// Add a binding for calendar dimension
Calend := DimBindings.AddCalendar("Year", DimCalendarLevel.Year);
// Create an object for parsing dates in data provider
DateConv := New DateConverter.Create;
// Set date format
DateConv.CalendarDateFormat := "$YEAR$";
DateConv.ConvertShortYear := True;
// Set the created object to calendar dimension binding
Calend.Converter := DateConv;
// Add a binding for data provider values
loader.FactBindings.Add("Value");
// Create an object for working with data provider
creator := New DtObjectCreator.Create;
// Create a text data provider from file
prov := creator.CreateDtObjectFromFile("C:\result_exp.txt") As IDtTextProvider;
// Specify column delimiter used in data provider
prov.DelimitedColumnDelimiter := ";";
// Load data and process loading result
Result := loader.LoadWithResult(prov, Null);
// Get object, to which data was loaded
Object := Result.Object;
// Display information about object in the console window
Debug.WriteLine("Name and identifier of created time series database: " +
Object.Name + "(" + Object.Id + ")");
// Get empty records and display them in the console window
List := Result.NullStrings;
If List.Count <> 0 Then
Debug.WriteLine("Empty records:");
For Each Item In List Do
Arr := Item As IArrayList;
For i := 0 To Arr.Count - 1 Do
Debug.Write(Arr.Item(i));
Debug.Write("; ");
End For;
Debug.WriteLine("");
End For;
End If;
// Get duplicate records and display them in the console window
List := Result.DuplicatedStrings;
If List.Count <> 0 Then
Debug.WriteLine("Duplicate records:");
For Each Item In List Do
Arr := Item As IArrayList;
For i := 0 To Arr.Count - 1 Do
Debug.Write(Arr.Item(i));
Debug.Write("; ");
End For;
Debug.WriteLine("");
End For;
End If;
End Sub UserProc;
After executing the example data from the C:\result_exp.txt file is loaded to the time series database created for this purpose. Import results and identifier and name of the created time series database are output to the console window.
See also: