IImportRequestInstance.LoadData

Syntax

LoadData;

Description

The LoadData method imports time series.

Example

Executing the example requires time series databases with the OBJ_RUBRICATOR and OBJ_RUBRICATOR_SOUR identifiers. The databases must contain the COUNTRY and INDICATOR attributes. Some rules are set for the attributes of the OBJ_RUBRICATOR_SOUR database.

Sub UserProc;
Var
    Mb: IMetabase;
    RubDesc: IMetabaseObjectDescriptor;
    RubDescSour: IMetabaseObjectDescriptor;
    CrInfo: IMetabaseObjectCreateInfo;
    Obj: IMetabaseObject;
    ObjDesc: IMetabaseObjectDescriptor;
    ImportRequestDef: IImportRequestDefinition;
    ImportRequestInst: IImportRequestInstance;
    ImportRequestRubricatorParams: IImportRequestRubricatorParams;
    ImportRequestResult: IImportRequestResult;
    Binding: ICubeMetaCopierBinding;
    Log: ICubeMetaLoaderLog;
    Count, i, key: Integer;
    Entry: ICubeMetaLoaderLogEntry;
    InvalidFactors: Array Of Integer;
Begin
    //Import object
    Mb := MetabaseClass.Active;
    CrInfo := Mb.CreateCreateInfo;
    CrInfo.ClassId := MetabaseObjectClass.KE_CLASS_IMPORTREQUEST;
    CrInfo.Id := "OBJ_IMPORTREQUEST";
    CrInfo.Name := "New import object";
    CrInfo.Permanent := True;
    CrInfo.Parent := RubDesc.Bind;
    ObjDesc := Mb.CreateObject(CrInfo);
    Obj := ObjDesc.Edit;
    //Set up source
    ImportRequestDef := Obj As IImportRequestDefinition;
    ImportRequestDef.SourceType := ImportRequestSourceType.Rubricator;
    RubDesc := Mb.ItemById("OBJ_RUBRICATOR");
    ImportRequestDef.DestinationRubricator := RubDesc.Bind As IRubricator;
    //Import parameters
    ImportRequestRubricatorParams := ImportRequestDef.RubricatorParams;
    RubDescSour := MB.ItemById("OBJ_RUBRICATOR_SOUR");
    ImportRequestRubricatorParams.SourceRubricator := RubDescSour.Bind As IRubricator;
    ImportRequestRubricatorParams.CalendarLevelSet := DimCalendarLevelSet.Year;
    ImportRequestRubricatorParams.NewRevisionName := "Import of factors";
    ImportRequestRubricatorParams.ImportObjectKey := Obj.Key;
    
    Binding := ImportRequestRubricatorParams.bindings.Add;
    Binding.BindingType := CubeMetaCopierBindingType.Attribute;
    Binding.DestinationAttribute := "COUNTRY";
    Binding.SourceAttribute := "COUNTRY";
    
    Binding := ImportRequestRubricatorParams.bindings.Add;
    Binding.BindingType := CubeMetaCopierBindingType.Attribute;
    Binding.DestinationAttribute := "INDICATOR";
    Binding.SourceAttribute := "INDICATOR";
    Obj.Save;

    //Import
    ImportRequestInst := (ImportRequestDef As IMetabaseObjectDescriptor).Open(NullAs IImportRequestInstance;
    ImportRequestInst.LoadData;
    
    //Import results
    ImportRequestResult := ImportRequestInst.ImportResult As IImportRequestResult;
    Log := ImportRequestResult.Log;
    Debug.WriteLine("Total records in the log: " + Count.ToString);
    For i := 0 To Count - 1 Do
        Entry := Log.Item(i);
        Debug.WriteLine(i.ToString + " : "  + Entry.DateBegin.ToString + ","
            + Entry.RecordNumber.ToString + ","
            + Entry.Field + ","
            + Entry.ErrorMessage);
    End For;

    InvalidFactors := (ImportRequestResult As IImportRequestResultEx).InvalidFactors;
    If InvalidFactors.Length <> 0 Then
        For Each Key In InvalidFactors Do
            Debug.WriteLine("Error when importing time series with key: " + Key.ToString);
        End For;
    Else
        Debug.WriteLine("Import completed without errors in factors");
    End If;
End Sub UserProc;

After executing the example time series are imported from the OBJ_RUBRICATOR_SOUR database to the OBJ_RUBRICATOR database. Import report records are displayed in the development environment console. If any rules are violated on import of some data series, the keys of respective time series are also displayed in the development environment console.

See also:

IImportRequestInstance