AddWithOwner(Key: String; Obj: Object; Owner: IMetabaseObjectDescriptor);
AddWithOwner(Key: String; Obj: Object; Owner: Prognoz.Platform.Interop.Metabase.IMetabaseObjectDescriptor);
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.
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.
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.
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.
The requirements and result of the Fore.NET example execution match with those in the Fore example. Use Fore.NET analogs instead of Fore components.
Imports Prognoz.Platform.Forms.NET;
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Metabase;
Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Var
MB: IMetabase;
CustomObj: IMetabaseCustomObject;
Writer: IMetabaseCustomObjectWriter;
WriterSelSet: IMetabaseCustomObjectSelSets;
Begin
MB := Self.Metabase;
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",
MetaAttributesBreadcrumbNet1.CtrlBox.GetSelectionSet(),
(MetaAttributesBreadcrumbNet1.Rubricator.Rubricator As IMetabaseObjectDescriptor));
Writer.Save();
(CustomObj As IMetabaseObject).Save();
End Sub;
Private Sub button2_Click(sender: System.Object; e: System.EventArgs);
Var
MB: IMetabase;
CustomObj: IMetabaseCustomObject;
Reader: IMetabaseCustomObjectReader;
ReaderSelSet: IMetabaseCustomObjectSelSets;
DimSS: IDimSelectionSet;
Begin
MB := Self.Metabase;
CustomObj := MB.ItemById["SelectionStorage"].Edit() As IMetabaseCustomObject;
Reader := CustomObj.CreateReader();
ReaderSelSet := Reader.Selections;
DimSS := ReaderSelSet.FindByKey("MetaSelecetion") As IDimSelectionSet;
MetaAttributesBreadcrumbNet1.CtrlBox.SetSelectionSet(DimSS);
Text := ReaderSelSet.OwnerByKey("MetaSelecetion").Name;
End Sub;
See also: