DimOpenStubParamValues: IMsDimOpenStubParamValues;
DimOpenStubParamValues: Prognoz.Platform.Interop.Ms.IMsDimOpenStubParamValues;
The DimOpenStubParamValues property returns the collection of parameters used on opening objects with parametric dimensions.
Parameters for opening parametric dimensions are supported only for internal models included in the metamodel.
Executing the example requires that repository contains:
Modeling container with the MS identifier containing a metamodel with the METAMODEL identifier.
Parametric dictionary with the DIM identifier containing a string parameter with the PARAM1 identifier.
Parametric cubes with the CUBE_IN, CUBE_OUT identifiers containing a string parameter with the PARAM1 identifier. Cubes must contain calendar dimension and controlling dimension based on the DIM dictionary.
Add links to the Cubes, Dimensions, Metabase, Ms system assemblies.
Sub UserProc;
Var
mb: IMetabase;
ms: IMetabaseObjectDescriptor;
MetaModel: IMsMetaModel;
Dimension: IDimensionModel;
CubeIn, CubeOut: IMetabaseObject;
StParams: IMsDimOpenStubParamValues;
StubParam: IMsDimOpenStubParamValue;
Param: IMsDimOpenParamValue;
ChainEntries: IMsCalculationChainEntries;
ChainModel: IMsCalculationChainModel;
Model: IMsModel;
Trans: IMsFormulaTransform;
Vars: IMsFormulaTransformVariables;
Stub: IVariableStub;
SelectionFact: IDimSelectionSetFactory;
Selection: IDimSelectionSet;
DimSel: IDimSelection;
Slice: IMsFormulaTransformSlice;
Selector: IMsFormulaTransformSelector;
ParamValues: IMetabaseObjectParamValues;
Formula: IMsFormula;
Determ: IMsDeterministicTransform;
TermX1: IMsFormulaTerm;
Begin
mb := MetabaseClass.Active;
// Get metamodel
ms := mb.ItemById("MS");
MetaModel := mb.ItemByIdNamespace("METAMODEL", ms.Key).Edit As IMsMetaModel;
// Get parametric dictionary
Dimension := mb.ItemById("DIM").Bind As IDimensionModel;
// Get input cube
CubeIn := mb.ItemById("CUBE_IN").Bind;
// Get output cube
CubeOut := mb.ItemById("CUBE_OUT").Bind;
// Add parameters to the metamodel and set their values
StParams := MetaModel.DimOpenStubParamValues;
StParams.Clear;
// Parameters for the input cube
StubParam := StParams.Add(CubeOut.Key);
StubParam.StubValues := CubeOut.Params.CreateEmptyValues;
StubParam.StubValues.FindById("PARAM1").Value := "1";
Param := StubParam.Values.Add(Dimension);
Param.Values := (Dimension As IMetabaseObject).Params.CreateEmptyValues;
Param.Values.FindById("PARAM1").Value := "1";
// Parameter of the input cube
StubParam := StParams.Add(CubeIn.Key);
StubParam.StubValues := CubeIn.Params.CreateEmptyValues;
StubParam.StubValues.FindById("PARAM1").Value := "1";
Param := StubParam.Values.Add(Dimension);
Param.Values := (Dimension As IMetabaseObject).Params.CreateEmptyValues;
Param.Values.FindById("PARAM1").Value := "1";
// Create an internal model in the metamodel
ChainEntries := MetaModel.CalculationChain;
ChainModel := ChainEntries.AddExclusiveModel;
Model := ChainModel.EditModel;
Trans := Model.Transform;
// Add output variable
Vars := Trans.Outputs;
Stub := CubeOut As IVariableStub;
ParamValues := (Dimension As IMetabaseObject).Params.CreateEmptyValues;
ParamValues.FindById("PARAM1").Value := "1";
SelectionFact := New DimSelectionSetFactory.Create;
Selection := SelectionFact.CreateDimSelectionSet;
// Set selection
DimSel := Selection.Add((Dimension As IMetabaseObject).Open(ParamValues) As IDimInstance);
DimSel.SelectElement(0, False);
// Set up model calculation
Slice := Vars.Add(Stub).Slices.Add(Selection);
Selector := Model.Transform.CreateSelector;
Selector.Slice := Slice;
Formula := Model.Transform.Transform(Selector);
Formula.Level := DimCalendarLevel.Year;
// Set up determinate equation
(Model As IMetabaseObject).Name := "Determinate equation";
Formula.Kind := MsFormulaKind.Deterministic;
Determ := Formula.Method As IMsDeterministicTransform;
// Add an input variable
Vars := Trans.Inputs;
Stub := CubeIn As IVariableStub;
ParamValues := (Dimension As IMetabaseObject).Params.CreateEmptyValues;
ParamValues.FindById("PARAM1").Value := "1";
SelectionFact := New DimSelectionSetFactory.Create;
Selection := SelectionFact.CreateDimSelectionSet;
// Set selection
DimSel := Selection.Add((Dimension As IMetabaseObject).Open(ParamValues) As IDimInstance);
DimSel.SelectElement(0, False);
// Set the formula
Slice := Vars.Add(Stub).Slices.Add(Selection);
TermX1 := Determ.Operands.Add(Slice);
Determ.Expression.AsString := "10 -" + TermX1.TermToInnerText + " * 3.14";
// Save changes of the metamodel
(MetaModel As IMetabaseObject).Save;
End Sub UserProc;
After executing the example the internal model is added to the metamodel, which is calculated by the Determinate Equation method. Input variable of the model is the CUBE_IN cube, output variable of the model is the CUBE_OUT cube. The parameters to manage the parameters of data of cubes are added to the metamodel.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Ms;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
ms: IMetabaseObjectDescriptor;
MetaModel: IMsMetaModel;
Dimension: IDimensionModel;
CubeIn, CubeOut: IMetabaseObject;
StParams: IMsDimOpenStubParamValues;
StubParam: IMsDimOpenStubParamValue;
Param: IMsDimOpenParamValue;
ChainEntries: IMsCalculationChainEntries;
ChainModel: IMsCalculationChainModel;
Model: IMsModel;
Trans: IMsFormulaTransform;
Vars: IMsFormulaTransformVariables;
Stub: IVariableStub;
SelectionFact: IDimSelectionSetFactory;
Selection: IDimSelectionSet;
DimSel: IDimSelection;
Slice: IMsFormulaTransformSlice;
Selector: IMsFormulaTransformSelector;
ParamValues: IMetabaseObjectParamValues;
Formula: IMsFormula;
Determ: IMsDeterministicTransform;
TermX1: IMsFormulaTerm;
Begin
mb := Params.Metabase;
// Get metamodel
ms := mb.ItemById["MS"];
MetaModel := mb.ItemByIdNamespace["METAMODEL", ms.Key].Edit() As IMsMetaModel;
// Get parametric dictionary
Dimension := mb.ItemById["DIM"].Bind() As IDimensionModel;
// Get input cube
CubeIn := mb.ItemById["CUBE_IN"].Bind();
// Get output cube
CubeOut := mb.ItemById["CUBE_OUT"].Bind();
// Add parameters to the metamodel and set their values
StParams := MetaModel.DimOpenStubParamValues;
StParams.Clear();
// Parameter for the output cube
StubParam := StParams.Add(CubeOut.Key);
StubParam.StubValues := CubeOut.Params.CreateEmptyValues();
StubParam.StubValues.FindById("PARAM1").Value := "1";
Param := StubParam.Values.Add(Dimension);
Param.Values := (Dimension As IMetabaseObject).Params.CreateEmptyValues();
Param.Values.FindById("PARAM1").Value := "1";
// Parameter of the input cube
StubParam := StParams.Add(CubeIn.Key);
StubParam.StubValues := CubeIn.Params.CreateEmptyValues();
StubParam.StubValues.FindById("PARAM1").Value := "1";
Param := StubParam.Values.Add(Dimension);
Param.Values := (Dimension As IMetabaseObject).Params.CreateEmptyValues();
Param.Values.FindById("PARAM1").Value := "1";
// Create an internal model in the metamodel
ChainEntries := MetaModel.CalculationChain;
ChainModel := ChainEntries.AddExclusiveModel();
Model := ChainModel.EditModel;
Trans := Model.Transform;
// Add output variable
Vars := Trans.Outputs;
Stub := CubeOut As IVariableStub;
ParamValues := (Dimension As IMetabaseObject).Params.CreateEmptyValues();
ParamValues.FindById("PARAM1").Value := "1";
SelectionFact := New DimSelectionSetFactory.Create();
Selection := SelectionFact.CreateDimSelectionSet();
// Set selection
DimSel := Selection.Add((Dimension As IMetabaseObject).Open(ParamValues) As IDimInstance);
DimSel.SelectElement(0, False);
// Set up model calculation
Slice := Vars.Add(Stub).Slices.Add(Selection);
Selector := Model.Transform.CreateSelector();
Selector.Slice := Slice;
Formula := Model.Transform.Transform[Selector];
Formula.Level := DimCalendarLevel.dclYear;
// Set up determinate equation
(Model As IMetabaseObject).Name := "Determinate equation";
Formula.Kind := MsFormulaKind.mfkDeterministic;
Determ := Formula.Method As IMsDeterministicTransform;
// Add an input variable
Vars := Trans.Inputs;
Stub := CubeIn As IVariableStub;
ParamValues := (Dimension As IMetabaseObject).Params.CreateEmptyValues();
ParamValues.FindById("PARAM1").Value := "1";
SelectionFact := New DimSelectionSetFactory.Create();
Selection := SelectionFact.CreateDimSelectionSet();
// Set selection
DimSel := Selection.Add((Dimension As IMetabaseObject).Open(ParamValues) As IDimInstance);
DimSel.SelectElement(0, False);
// Set the formula
Slice := Vars.Add(Stub).Slices.Add(Selection);
TermX1 := Determ.Operands.Add(Slice);
Determ.Expression.AsString := "10 -" + TermX1.TermToInnerText() + " * 3.14";
// Save changes of the metamodel
(MetaModel As IMetabaseObject).Save();
End Sub;
See also: