IMsMetaModelVisualController.RemoveFactor

Fore Syntax

RemoveFactor(Model: IMsModel;
             Index: Integer;
             RemoveSimilar: Boolean;
             RemoveModel: Boolean): Boolean;

Fore.NET Syntax

RemoveFactor(Model: Prognoz.Platform.Interop.Ms.IMsModel;
             Index: integer;
             RemoveSimilar: boolean;
             RemoveModel: boolean): boolean;

Parameters

Model. Internal model, from which the factor must be removed.

Index. Index of the factor to be removed.

RemoveSimilar. The indicator whether to remove similar factors, that is, factors, the content, and the dimensions selection in which coincides with the factor to be removed.

RemoveModel. The attribute of the fact whether to remove the model if it does not contain factors.

Description

The RemoveFactor method removes the specified factor from the internal model.

Comments

Available values of the RemoveSimilar parameter:

Available values of the RemoveModel parameter:

If the factor is successfully deleted, the method returns the True value.

Fore Example

Executing the example requires a modeling container with the MS identifier containing a metamodel with the META identifier. This metamodel must contain an internal time series database and a model.

Add links to the Metabase, Ms system assemblies.

Sub RemoveFactor;
Var
    mb: IMetabase;
    MsObj: IMetabaseObjectDescriptor;
    Meta: IMsMetaModel;
    MetaVisual: IMsMetaModelVisualController;
    SimpleModel: IMsModel;
    i: Integer;
    ChainEn: IMsCalculationChainEntries;
Begin
    mb := MetabaseClass.Active;
    // Get modeling container
    MsObj := mb.ItemById("MS");
    // Get metamodel
    Meta := mb.ItemByIdNamespace("META", MsObj.Key).Bind As IMsMetaModel;
    MetaVisual := Meta.VisualController;
    // Get the model
    ChainEn := Meta.CalculationChain;
    For i := 0 To ChainEn.Count - 1 Do
        If ChainEn.Item(i).Type = MsCalculationChainEntryType.Model Then
            SimpleModel := (ChainEn.Item(i) As IMsCalculationChainModel).Model;
        End If;
    End For;
    SimpleModel := (SimpleModel As IMetabaseObject).Edit As IMsModel;
    // Remove the first factor
    If MetaVisual.RemoveFactor(SimpleModel, 0FalseFalseThen
        Debug.WriteLine("Removal is performed successfuly");
    Else
        Debug.WriteLine("Factor was not removed");
    End If;
    (SimpleModel As IMetabaseObject).Save;
End Sub RemoveFactor;

After execution of the procedure from the first internal model the first factor will be removed, the result of removal will be output in the console window.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Ms;

Public Shared Sub Main(Params: StartParams);
Var
    mb: IMetabase;
    MsObj: IMetabaseObjectDescriptor;
    Meta: IMsMetaModel;
    MetaVisual: IMsMetaModelVisualController;
    SimpleModel: IMsModel;
    i: Integer;
    ChainEn: IMsCalculationChainEntries;
Begin
    mb := Params.Metabase;
    // Get modeling container
    MsObj := mb.ItemById["MS"];
    // Get metamodel
    Meta := mb.ItemByIdNamespace["META", MsObj.Key].Bind() As IMsMetaModel;
    MetaVisual := Meta.VisualController;
    // Get the model
    ChainEn := Meta.CalculationChain;
    For i := 0 To ChainEn.Count - 1 Do
        If ChainEn.Item[i].Type = MsCalculationChainEntryType.mccetModel Then
            SimpleModel := (ChainEn.Item[i] As IMsCalculationChainModel).Model;
        End If;
    End For;
    SimpleModel := (SimpleModel As IMetabaseObject).Edit() As IMsModel;
    // Remove the first factor
    If MetaVisual.RemoveFactor(SimpleModel, 0FalseFalseThen
        System.Diagnostics.Debug.WriteLine("Removal is performed successfuly");
    Else
        System.Diagnostics.Debug.WriteLine("Factor was not removed");
    End If;
    (SimpleModel As IMetabaseObject).Save();
End Sub;

See also:

IMsMetaModelVisualController