ICubeMetaExporterBinding.AttributeKey

Syntax

AttributeKey: Integer;

Description

The AttributeKey property determines a key of the factor attribute.

Comments

The following methods can be used to bind attributes of time series database to consumer fields:

If only attribute identifiers are used for binding, some errors may occur on export if attribute identifier in the time series database has been changed. Binding with attributes keys use is safer.

Example

Executing the example requires a time series database with the OBJ_RUBRICATOR identifier. This database must contain the COUNTRY custom attribute. Also add links to the Cubes, Metabase, Dt, Dal, Rds, Dimensions system assemblies.

    Sub UserProc;
    Var
        TextConsumer: IDtTextConsumer;
        MB: IMetabase;
        CrInfo: IMetabaseObjectCreateInfo;
        RubDescr: IMetabaseObjectDescriptor;
        ObjDesc: IMetabaseObjectDescriptor;
        Obj: IMetabaseObject;
        ExportRequestDef: IExportRequestDefinition;
        Params: IExportRequestParams;
        Rubr: IRubricator;
        Binding: ICubeMetaExporterBinding;
        FactsDict: IMetaDictionary;
        Attr: IMetaAttribute;
        Filter: ICubeMetaExporterFilter;
        FilterValues: Array;
        ExportRequestInst: IExportRequestInstance;
    Begin
    // Data consumer for export to the textual format
        TextConsumer := New DtTextConsumer.Create;
        TextConsumer.File := "C:\result.txt";
        TextConsumer.FormatType := DtTextFormatType.Delimited;
        TextConsumer.DelimitedColumnDelimiter := ";";
        TextConsumer.DelimitedTextQualifier := """";
        TextConsumer.Encoding := "WIN";
        TextConsumer.WriteHeader := True;
    // Export object
        MB := MetabaseClass.Active;
        CrInfo := MB.CreateCreateInfo;
        CrInfo.ClassId := MetabaseObjectClass.KE_CLASS_EXPORTREQUEST;
        CrInfo.Id := MB.GenerateId("OBJ_EXPORTREQUEST");
        CrInfo.Permanent := True;
        RubDescr := MB.ItemById("OBJ_RUBRICATOR");
        CrInfo.Parent := RubDescr;
        ObjDesc := MB.CreateObject(CrInfo);
        Obj := ObjDesc.Edit;
        ExportRequestDef := Obj As IExportRequestDefinition;
    // Export parameters
        Params := ExportRequestDef.Exporter;
        Rubr := RubDescr.Bind As IRubricator;
        Params.Rubricator := Rubr;
        Params.Consumer := TextConsumer As IDtConsumer;
        Binding := Params.Bindings.Add;
        Binding.FieldName := "CountryKey";
        Binding.DataType := DbDataType.String;
        Binding.BindingType := CubeMetaExporterBindingType.Attribute;
        FactsDict := Rubr.Facts;
        Attr := FactsDict.Attributes.FindById("COUNTRY");
        Binding.AttributeKey := Attr.Key;
        Binding.KeyField := "KEY";
        Binding := Params.Bindings.Add;
        Binding.FieldName := "Year";
        Binding.DataType := DbDataType.String;
        Binding.BindingType := CubeMetaExporterBindingType.Calendar;
        Binding.DateFormat := "$Year$";
        Binding.ValueFieldName := "Value";
        Binding.ValueDataType := DbDataType.Float;
        Params.ByColumns := True;
        Params.PeriodStart := DateTime.Parse("01.01.2000");
        Params.PeriodEnd := DateTime.Parse("01.01.2008");
        Params.CalendarLevel := DimCalendarLevel.Year;
        Filter := Params.Filters.Add;
        Filter.AttributeKey := Attr.Key;
        FilterValues := New Variant[2];
        FilterValues[0] := 512;
        FilterValues[1] := 914;
        Filter.ValuesList := FilterValues;
        Obj.Save;
    // Export
        ExportRequestInst := ObjDesc.OpenWithParam(NullAs IExportRequestInstance;
        ExportRequestInst.Export;
    End Sub UserProc;

After executing the example the factors are exported to the C:\result.txt file. Only data from 2000 to 2008 years can be exported for those factors, which value of the COUNTRY indicator is equal to 512 or 914. The attribute is bound by key.

See also:

ICubeMetaExporterBinding