ICubeMetaLoaderBinding.CalendarDateFormatEx

Syntax

CalendarDateFormatEx(Level: DimCalendarLevel): String;

Parameters

Level. The calendar level, for which format is set.

Description

The CalendarDateFormatEx property determines a date format for several levels of calendar dimension.

Comments

To specify date format for several level, consequently specify them using this property. For example, the code for specifying annual and quarterly frequency format:

Sub UserProc;
Var

Binding: ICubeMetaLoaderBinding;
Begin

    Binding.CalendarDateFormatEx(DimCalendarLevel.Year) := "$Year$";
    Binding.CalendarDateFormatEx(DimCalendarLevel.Quarter) := "$Year$Q$Quarter$";

End Sub UserProc;

Example

Executing the example requires a time series database with the TSDB_IMPORT identifier containing mandatory attributes with the CITY and INDICATOR identifiers. These attributes must be links to the dictionary.

The file system must contain the D:\res_export.txt file containing data of several calendar frequencies.

Contents of the res_export.txt file

Add links to the Cubes, Db, Dimensions, Dt, Metabase, Rds system assemblies.

Sub UserProc;
Var
    TextProvider: IDtTextProvider;
    Mb: IMetabase;
    TSDBObj: IMetabaseObject;
    TSDB: IRubricator;
    Attr: IMetaAttributes;
    CrInfo: IMetabaseObjectCreateInfo;
    Obj: IMetabaseObject;
    ImportRequestDef: IImportRequestDefinition;
    Params: IImportRequestProviderParams;
    Bindings: ICubeMetaLoaderBindings;
    Binding: ICubeMetaLoaderBinding;
    DimM: IDimensionModel;
    Instance: IImportRequestInstance;
    ImportResult: IImportRequestResult;
    Count, i: Integer;
    Entry: ICubeMetaLoaderLogEntry;
Begin

    // Create a data source to 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_IMPORT").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;

    // Determine data source
    ImportRequestDef := Obj As IImportRequestDefinition;
    ImportRequestDef.SourceType := ImportRequestSourceType.irstProvider;

    // Determine data consumer

    ImportRequestDef.DestinationRubricator := TSDB;

    // Determine import parameters
    Params := ImportRequestDef.ProviderParams;
    Params.Provider := TextProvider As IDatasetDataProvider;
    Params.NewRevisionName := "Times series import";
    Params.ImportObjectKey := Obj.Key;
    Params.LoadType := CubeMetaLoaderLoadType.CreateAndUpdate;

    // Determine attribute binding
    Bindings := Params.Bindings;

    // Determine calendar binding
    Binding := Bindings.Add;
    Binding.BindingType := CubeMetaLoaderBindingType.Calendar;
    Binding.ByColumns := False;
    Binding.CalendarDateFormatEx(DimCalendarLevel.Year) := "$Year$";
    Binding.CalendarDateFormatEx(DimCalendarLevel.Quarter) := "$Year$Q$Quarter$";
    Binding.CalendarOptions.Levels := DimCalendarLevelSet.Year Or DimCalendarLevelSet.Quarter;
    Binding.FieldType := CubeMetaLoaderFieldType.Name;
    Binding.Field := "Year";

    // Determine binding of the Measurement Units (UNIT) attribute
    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";

    // Determine binding of the Cities (CITY) attribute
    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";

    // Determine binding of the Indicators (INDICATOR) attribute
    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";

    // Determine binding to import series observation values
    Binding := Bindings.Add;
    Binding.BindingType := CubeMetaLoaderBindingType.Value;
    Binding.FieldType := CubeMetaLoaderFieldType.Name;
    Binding.Field := "Value";

    // Save changes in the import object
    Obj.Save;

    // Import data
    Instance := (ImportRequestDef As IMetabaseObject).Open(NullAs IImportRequestInstance;
    Instance.LoadData();

    // Get error log of data import
    ImportResult := Instance.ImportResult;
    Count := importResult.Log.Count;

    // Display log to console dialog box
    For i := 0 To Count - 1 Do
        Entry := ImportResult.Log.Item(i);
        Debug.WriteLine(Entry.ErrorMessage);
        If Entry.IsError Then
            Debug.WriteLine(" (field = """ + Entry.Field + """, record = " +
                Entry.RecordNumber.ToString + ")");
        End If;
    End For;
End Sub UserProc;

As a result of executing the example the data from the "D:\res_export.txt" file will be imported to the time series database.

See also:

ICubeMetaLoaderBinding