IMsMetaModel.GenerateChain

Syntax

GenerateChain(Serie: ILanerCalculateSerie);

Parameters

Serie. Calculated series of the workbook.

Description

The GenerateChain method generates a calculation chain for the metamodel.

Example

Executing the example requires a form, the Button1 button on it, the TabSheetBox component, the Memo component named Memo1 and the UiErAnalyzer component named UiErAnalyzer1 that is a data source for TabSheetBox. A workbook of the time series database must be loaded to UiErAnalyzer1. This workbook should contain more than one data series with annual frequency. This database must include mandatory the attributes COUNTRY and INDICATOR that refer to a dictionary.

Click the button to start executing of this example.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);

Var

Laner: Ilaner;

UsingSerie, UsingSerie2: ILanerSerie;

NewSerie: ILanerCalculateSerie;

Str: String;

Trasss: IFormulaTransformModel;

ms: IMsFormulaTransform;

TransformVar: IMsFormulaTransformVariable;

Coord: IMsFormulaTransformCoord;

Slice: IMsFormulaTransformSlice;

selector: IMsFormulaTransformSelector;

Formula: IMsFormula;

Det: IMsDeterministicTransform;

Term1, Term2: IMsFormulaTerm;

ActiveMetabase: IMetabase;

ci: IMetabaseObjectCreateInfo;

DescTrans, Obj: IMetabaseObjectDescriptor;

Ruby: IRubricator;

MetaModel: IMsMetaModel;

ModelMBObj: IMetabaseObject;

MetaAt: ILanerMetaAttributeValueList;

Begin

Laner := UiErAnalyzer1.ErAnalyzer.Laner;

Laner.BeginUpdate;

UsingSerie := Laner.Series.Item(0) As ILanerSerie;

UsingSerie2 := Laner.Series.Item(1) As ILanerSerie;

Str := "Summ_(" + UsingSerie.Name + " , " + UsingSerie2.Name + ")";

NewSerie := Laner.Series.AddCalculateSerie(Str);

Trasss := NewSerie.Transform;

Trasss.AddInputVariable(UsingSerie.Stub);

Trasss.AddInputVariable(UsingSerie2.Stub);

ms := Trasss.Transform As IMsFormulaTransform;

TransformVar := ms.Outputs.Item(0);

Coord := ms.CreateCoord(TransformVar);

Slice := TransformVar.Slices.Add(Null);

Selector := ms.CreateSelector;

Selector.Slice := Slice;

Formula := ms.Transform(Selector);

Formula.Kind := MsFormulaKind.Deterministic;

Formula.Level := DimCalendarLevel.Year;

Det := Formula.Method As IMsDeterministicTransform;

TransformVar := ms.Inputs.Add(UsingSerie.Stub);

Slice := TransformVar.Slices.Add(Null);

TransformVar := ms.Inputs.Add(UsingSerie.Stub);

Slice := TransformVar.Slices.Add(Null);

Term1 := Det.Operands.Add(Slice);

TransformVar := ms.Inputs.Add(UsingSerie2.Stub);

Slice := TransformVar.Slices.Add(Null);

Term2 := Det.Operands.Add(Slice);

Det.Expression.AsString := Term1.TermToInnerText + " + " + Term2.TermToInnerText;

NewSerie.Calculate;

MetaAt := NewSerie.MetaAttributeValueList;

MetaAt.FindById("COUNTRY").Value := 512;

MetaAt.FindById("INDICATOR").Value := 1009;

Laner.EndUpdate;

ActiveMetabase := MetabaseClass.Active;

Ruby := Laner.RubricatorInstance.Rubricator;

DescTrans := Ruby.ModelSpace;

ci := ActiveMetabase.CreateCreateInfo;

ci.ClassId := MetabaseObjectClass.KE_CLASS_MSMETAMODEL;

ci.Parent := DescTrans;

ci.Name := NewSerie.Name;

Obj := ActiveMetabase.CreateObject(ci);

ModelMBObj := Obj.Edit;

MetaModel := ModelMBObj As IMsMetaModel;

MetaModel.GenerateChain(NewSerie);

ModelMBObj.Save;

Memo1.Lines.Add(metamodel identifier: +ModelMBObj.Id);

End Sub Button1OnClick;

After executing the example a new calculated series, which is a sum of the first two series data, is added. The metamodel, the calculation chain of which is generated based on this calculated series, is created. The metamodel identifier is displayed in the Memo1 component.

See also:

IMsMetaModel