IMsTransformObjectList.RemoveByKey

Syntax

RemoveByKey(Key: Integer): Boolean;

Parameters

Key. Object key.

Description

The RemoveByKey method removes object from the collection by its key.

Comments

If the object is successfully removed, the method returns True, value of the IMsTransformObjectList.Count property decreases by one; otherwise it is False.

Example

Executing the example requires that the repository contains a time series database with the FC identifier. A model with the MODEL_ATTR identifier must be available in the modeling container of this database. The model is calculated as determinate equation. Also, before executing the procedure it is necessary to add links to the Ms, Cubes, Rds, Metabase system assemblies.

Sub UserProc;

Var

Mb: IMetabase;

RubrDescr: IMetabaseObjectDescriptor;

Rubr: IRubricator;

MsDescr: IMetabaseObjectDescriptor;

Model: IMsModel;

Transform: IMsFormulaTransform;

TransformVarables: IMsFormulaTransformVariables;

TransVar: IMsFormulaTransformVariable;

FactsAttrs: IMetaAttributes;

Attr: IMetaAttribute;

DictDescr: IMetabaseObjectDescriptor;

ObjList: IMsTransformObjectList;

TransfObj: IMsTransformObject;

TermTrue, TermFalse: String;

Determ: IMsDeterministicTransform;

Expr: IExpression;

FormulaTerm: IMsFormulaTerm;

Begin

Mb := MetabaseClass.Active;

RubrDescr := Mb.ItemById("FC");

Rubr := RubrDescr.Bind As IRubricator;

MsDescr := Rubr.ModelSpace;

Model := Mb.ItemByIdNamespace("MODEL_ATTR", MsDescr.Key).Edit As IMsModel;

Transform := Model.Transform;

TransformVarables := Transform.Outputs;

TransVar := TransformVarables.Item(0);

TransVar.AttributeId := "UNIT";

FactsAttrs := Rubr.Facts.Attributes;

Attr := FactsAttrs.FindById("UNIT");

DictDescr := Attr.ValuesObject;

ObjList := Transform.ObjectList;

For Each TransfObj In ObjList Do

ObjList.RemoveByKey(TransfObj.Key);

End For;

TransfObj := ObjList.Add(DictDescr);

TermTrue := "@__" + TransfObj.Key.ToString + ":3433"; //3433 - Billions of National Currency

TermFalse := "@__" + TransfObj.Key.ToString + ":3549"; //3549 - National Currency

Determ := Transform.FormulaItem(0).Method As IMsDeterministicTransform;

Expr := Determ.Expression;

Expr.AsString := "";

FormulaTerm := Determ.Operands.Item(0);

Expr.AsString := "iif(" + FormulaTerm.TermToText + "=3433," + TermTrue + "," + TermFalse + ")";

If Not (Expr.Valid)

Then Debug.WriteLine(Expr.ErrorInfo.ErrorMessage);

Else (Model As IMetabaseObject).Save;

End If;

End Sub UserProc;

After executing the example the output variable of model is used for loading in it the values of the UNIT attribute (units). The collection of model objects is cleared before the object, that refers to the units dictionary, is added to it. The calculation formula of the determinate equation is set as follows: if the units of the first input variable are Billions of National Currency, the units of output variable are replaced with Billions of National Currency. In case the units of the first input variable are other than Billions of National Currency, the units of output variable are changed to National Currency.

See also:

IMsTransformObjectList