Descriptor: IMetabaseObjectDescriptor;
The Descriptor property describes a repository object corresponding to this object.
By default, value of the Descriptor property matches the value of the parameter, with which the IMsTransformObjectList.Add method was called (adding an object). If this method was called with the Null parameter, the object cannot be used properly, if value of the Descriptor property is not set before.
Executing the example requires that the repository contains a time series database with the FC identifier. Modeling container of this time series database must contain a model with the MODEL_ATTR identifier. 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;
ObjList.Clear;
ObjList.Add(DictDescr);
TransfObj := ObjList.Item(0);
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 first object is changed in the collection of objects of model calculation method. The output model variable is used for loading to it the UNIT attribute value (units). 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: