IRubricatorSegments.CreateFactorsSegment

Syntax

CreateFactorsSegment: IRubricatorFactorsSegment;

CreateFactorsSegment: Prognoz.Platform.Interop.Cubes.IRubricatorFactorsSegment;

Description

The CreateFactorsSegment method adds a data range to the collection.

Example

Executing the example requires that the repository contains a time series database with the OBJ_RUBRICATOR identifier containing indicator attribute with the COUNTRY identifier that is a link to the dictionary.

To execute the example, add links to the Metabase, Cubes, Dimensions, Rds system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    RubInst: IRubricatorInstance;
    Rub: IRubricator;
    Segs: IRubricatorSegments;
    Seg: IRubricatorSegment;
    Sd: ISecurityDescriptor;
    Attr: IMetaAttribute;
    Dict: IMetabaseObject;
    DI: IDimInstance;
    Sel: IDimSelection;
    SegmFact: IRubricatorFactorsSegment;
    SegmObject: IMetabaseObjectDescriptor;
Begin
    MB := MetabaseClass.Active;
    Rub := MB.ItemById(
"OBJ_RUBRICATOR").Bind As IRubricator;
    RubInst := (Rub 
As IMetabaseObjectDescriptor).Open(NullAs IRubricatorInstance;
    Segs := RubInst.Segments;
    Seg := Segs.CreateFactorsSegment 
As IRubricatorSegment;
    SegmObject := Seg.AsObject;
    Sd := SegmObject.SecurityDescriptor;
    Sd.Edit;
    Seg.AttributeName := 
"COUNTRY";
    Attr := Rub.Facts.Attributes.FindById(
"COUNTRY");
    Seg.Attribute := Attr;
    Dict := Attr.ValuesObject.Bind;
    DI := Dict.Open(
NullAs IDimInstance;
    Sel := DI.CreateSelection;
    Sel.SelectElement(
0False);
    Sel.SelectElement(
1False);
    SegmFact := Seg 
As IRubricatorFactorsSegment;
    SegmFact.SetSelection(Sel);
    Seg.Save;
End Sub UserProc;

Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Rds;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    RubInst: IRubricatorInstance;
    Rub: IRubricator;
    Segs: IRubricatorSegments;
    Seg: IRubricatorSegment;
    Sd: ISecurityDescriptor;
    Attr: IMetaAttribute;
    Dict: IMetabaseObject;
    DI: IDimInstance;
    Sel: IDimSelection;
    SegmFact: IRubricatorFactorsSegment;
    SegmObject: IMetabaseObjectDescriptor;
Begin
    MB := Params.Metabase;
    Rub := MB.ItemById[
"OBJ_RUBRICATOR"].Bind() As IRubricator;
    RubInst := (Rub 
As IMetabaseObjectDescriptor).Open(NullAs IRubricatorInstance;
    Segs := RubInst.Segments;
    Seg := Segs.CreateFactorsSegment() 
As IRubricatorSegment;
    SegmObject := Seg.AsObject();
    Sd := SegmObject.SecurityDescriptor;
    Sd.Edit();
    Seg.AttributeName := 
"COUNTRY";
    Attr := Rub.Facts.Attributes.FindById(
"COUNTRY");
    Seg.Attribute := Attr;
    Dict := Attr.ValuesObject.Bind();
    DI := Dict.Open(
NullAs IDimInstance;
    Sel := DI.CreateSelection();
    Sel.SelectElement(
0False);
    Sel.SelectElement(
1False);
    SegmFact := Seg 
As IRubricatorFactorsSegment;
    SegmFact.SetSelection(Sel);
    Seg.Save();
End Sub;

After executing the example a segment that represents a data range is created in the time series database. The segment includes the first and the second dictionary elements, to which the COUNTRY attribute refers.

See also:

IRubricatorSegments