IMetabaseCustomObjectSelSets.AddWithOwner

Syntax

AddWithOwner(Key: String; Obj: Object; Owner: IMetabaseObjectDescriptor);

Parameters

Key. Key of the created element.

Obj. Dimensions selection, which will be saved in the created element.

Owner. Description of the repository object, to which the selection is linked.

Description

The AddWithOwner method adds a new element to the collection and saves the passed dimension selection in its metadata, with linking to the specified selection owner.

Comments

It is necessary to specify a unique key of the created element as value of the Key parameter. If the collection has already contain the element with the specified key, exception is generated. As a value of the Obj parameter, it is necessary to pass the dimension selection described by the IDimSelectionSet interface. Specify description of the object, with which the selection is linked, in the Owner parameter, for example, description of a cube or time series database. The method can be used if the collection stores one-type selections created for different repository objects.

Example

Executing the example requires a form with two buttons Button1 and Button2, the MetaAttributesBreadcrumb component named MetaAttributesBreadcrumb1 linked to a time series database. The repository should also contains a custom class object with the SelectionStorage identifier. Add links to the Cubes, Dimension, Metabase system assemblies.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    MB: IMetabase;
    CustomObj: IMetabaseCustomObject;
    Writer: IMetabaseCustomObjectWriter;
    WriterSelSet: IMetabaseCustomObjectSelSets;
Begin
    MB := MetabaseClass.Active;
    CustomObj := MB.ItemById("SelectionStorage").Edit As IMetabaseCustomObject;
    Writer := CustomObj.CreateWriter;
    WriterSelSet := Writer.Selections;
    If WriterSelSet.FindByKey("MetaSelecetion") <> Null Then
        WriterSelSet.RemoveByKey("MetaSelecetion");
    End If;
    WriterSelSet.AddWithOwner("MetaSelecetion",
        MetaAttributesBreadcrumb1.GetSelectionSet,
        (MetaAttributesBreadcrumb1.Rubricator.Rubricator As IMetabaseObjectDescriptor));
    Writer.Save;
    (CustomObj As IMetabaseObject).Save;
End Sub Button1OnClick;

Sub Button2OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    MB: IMetabase;
    CustomObj: IMetabaseCustomObject;
    Reader: IMetabaseCustomObjectReader;
    ReaderSelSet: IMetabaseCustomObjectSelSets;
    DimSS: IDimSelectionSet;
Begin
    MB := MetabaseClass.Active;
    CustomObj := MB.ItemById("SelectionStorage").Edit As IMetabaseCustomObject;
    Reader := CustomObj.CreateReader;
    ReaderSelSet := Reader.Selections;
    DimSS := ReaderSelSet.FindByKey("MetaSelecetion"As IDimSelectionSet;
    MetaAttributesBreadcrumb1.SetSelectionSet(DimSS);
    Text := ReaderSelSet.OwnerByKey("MetaSelecetion").Name;
End Sub Button2OnClick;

On clicking the button the factors selection, installed in the MetaAttributesBreadcrumb1 component, is saved to the custom class object. On clicking them second button the selection is restored from the specified custom class object and is installed in the MetaAttributesBreadcrumb1 component.

See also:

IMetabaseCustomObjectSelSets