FindChainVariableBySlice(Slice: IMsFormulaTransformSlice): IMsCalculationChainVariable;
FindChainVariableBySlice(Slice: Prognoz.Platform.Interop.Ms.IMsFormulaTransformSlice): Prognoz.Platform.Interop.Ms.IMsCalculationChainVariable;
Slice. Variable slice.
The FindChainVariableBySlice method searches for the variable by the slice.
The Slice parameter cannot take the Null value.
If the variable with the specified slice have not found, the method returns Null.
The example is the function, which returns whether the variable with the specified slice exists in the metamodel calculation chain. Input parameter of the function is the slice of the variable. If the variable is not found, the function returns True, otherwise it returns False.
Executing the example requires that the repository contains a modeling container with the MODEL_SPACE identifier containing a modeling problem with the WEB_PROBLEM identifier. The modeling problem must contain the internal metamodel.
Add links to the Metabase, Ms system assemblies.
Function FindChainVariableBySlice(Slice: IMsFormulaTransformSlice): Boolean;
Var
MB: IMetabase;
MsObj: IMetabaseObject;
Problem: IMsProblem;
Meta: IMsMetaModel;
MetaVisual: IMsMetaModelVisualController;
ChainVar: IMsCalculationChainVariable;
Begin
MB := MetabaseClass.Active;
// Get modeling container
MsObj := MB.ItemById("MODEL_SPACE").Bind;
// Get modeling problem
Problem := MB.ItemByIdNamespace("WEB_PROBLEM", MsObj.Key).Bind As IMsProblem;
// Get metamodel
Meta := Problem.MetaModel;
MetaVisual := Meta.VisualController;
// Search for the variable
ChainVar := MetaVisual.FindChainVariableBySlice(Slice);
// Return the attribute of existence of the variable in the metamodel
If Slice <> Null Then
Return True;
Else
Return False;
End If;
End Function FindChainVariableBySlice;
After executing the example the function returns whether the variable with the specified slice exists in the metamodel calculation chain.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Ms;
…
Public Shared Function FindChainVariableBySlice(Slice: IMsFormulaTransformSlice; Params: StartParams): Boolean;
Var
MB: IMetabase;
MsObj: IMetabaseObject;
Problem: IMsProblem;
Meta: IMsMetaModel;
MetaVisual: IMsMetaModelVisualController;
ChainVar: IMsCalculationChainVariable;
Begin
MB := Params.Metabase;
// Get modeling container
MsObj := MB.ItemById["MODEL_SPACE"].Bind();
// Get modeling problem
Problem := MB.ItemByIdNamespace["WEB_PROBLEM", MsObj.Key].Bind() As IMsProblem;
// Get metamodel
Meta := Problem.MetaModel;
MetaVisual := Meta.VisualController;
// Search for the variable
ChainVar := MetaVisual.FindChainVariableBySlice(Slice);
// Return the attribute of existence of the variable in the metamodel
If Slice <> Null Then
Return True;
Else
Return False;
End If;
End Function FindChainVariableBySlice;
See also: