IDtJsonProvider.File

Syntax

File: String;

File: String;

Description

The File property determines the path and the name of the JSON file, from which data is to be imported.

Example

Executing the example requires the D:\Work\Data.json JSON file. An ETL task with the ETL identifier is created in the repository.

Add links to the Andy, Drawing, Dt, Etl, Metabase system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    MObj: IMetabaseObject;
    EtlTask: IEtlTask;
    EtlProvider: IEtlPlainDataProvider;
    JSONProvider: IDtJsonProvider;
    WxProvider: IWxRectangle;
    WxETLProvider: IWxETLObject;
Begin
    MB := MetabaseClass.Active;
    
//Search the ETL task. Repository object with the ETL identifier
    MObj := MB.ItemById("ETL").Edit;
    EtlTask := MObj 
As IEtlTask;
    
//Start provider creation
    //Create the Import from JSON object
    EtlProvider := EtlTask.Create(EtlObjectType.PlainDataJsonProvider) As IEtlPlainDataProvider;
    EtlProvider := EtlProvider.Edit;
    EtlProvider.Id := 
"JSON_Provider";
    EtlProvider.Name := 
"Import from JSON";
    EtlProvider.Description := 
"Import from JSON";
    
//Set up data provider
    JSONProvider := EtlProvider.Provider As IDtJsonProvider;
    JSONProvider.File := 
"D:\Work\Data.json";
    JSONProvider.Query := 
"$..data";
    EtlProvider.FillDefault;
    
//Save provider
    EtlProvider.Save;
    
//End of provider creation
    //Start visual object creation
    WxProvider := EtlTask.Workspace.CreateRectangle;
    WxETLProvider := 
New WxETLObject.Create;
    WxETLProvider.ETLObject := EtlProvider;
    WxProvider.Style.TextPosition := WxTextPosition.Bottom;
    WxProvider.Style.PictureMarginTop := -
10;
    WxProvider.PinPosition := 
New GxPointF.Create(5050);
    WxProvider.Extension := WxETLProvider 
As IWxShapeExtension;
    
//End of visual object creation
    //Save ETL task
    MObj.Save;
End Sub UserProc;

Imports Prognoz.Platform.Interop.Andy;
Imports Prognoz.Platform.Interop.Drawing;
Imports Prognoz.Platform.Interop.Dt;
Imports Prognoz.Platform.Interop.Etl;
Imports Prognoz.Platform.Interop.Metabase;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    MObj: IMetabaseObject;
    EtlTask: IEtlTask;
    EtlProvider: IEtlPlainDataProvider;
    JSONProvider: IDtJsonProvider;
    WxProvider: IWxRectangle;
    WxETLProvider: IWxETLObject;
    Point: GxPointF = 
New GxPointFClass();
Begin
    MB := Params.Metabase;
    
//Search the ETL task. Repository object with the ETL identifier
    MObj := MB.ItemById["ETL"].Edit();
    EtlTask := MObj 
As IEtlTask;
    
//Start provider creation
    //Create the Import from JSON object
    EtlProvider := EtlTask.Create(EtlObjectType.eotPlainDataJsonProvider) As IEtlPlainDataProvider;
    EtlProvider := EtlProvider.Edit();
    EtlProvider.Id := 
"JSON_Provider";
    EtlProvider.Name := 
"Import from JSON";
    EtlProvider.Description := 
"Import from JSON";
    
//Set up data provider
    JSONProvider := EtlProvider.Provider As IDtJsonProvider;
    JSONProvider.File := 
"D:\Work\Data.json";
    JSONProvider.Query := 
"$..data";
    EtlProvider.FillDefault();
    
//Save provider
    EtlProvider.Save();
    
//End of provider creation
    //Start visual object creation
    WxProvider := EtlTask.Workspace.CreateRectangle();
    WxETLProvider := 
New WxETLObject();
    WxETLProvider.ETLObject := EtlProvider;
    WxProvider.Style.TextPosition := WxTextPosition.wtpBottom;
    WxProvider.Style.PictureMarginTop := -
10;
    Point.Create(
5050);
    WxProvider.PinPosition := Point;
    WxProvider.Extension := WxETLProvider 
As IWxShapeExtension;
    
//End of visual object creation
    //Save ETL task
    MObj.Save();
End Sub;

On executing the example a new data provider will be created in ETL task - Import from Json. The data provider is set up to work with the specified file.

See also:

IDtJsonProvider