IMetabaseCustomObjectReferences.AddWithOwner

Fore Syntax

AddWithOwner(Object: IMetabaseObjectDescriptor;
             Owner: IMetabaseObjectDescriptor
             ): IMetabaseCustomObjectReference;

Fore.NET Syntax

AddWithOwner(Object: Prognoz.Platform.Interop.Metabase.IMetabaseObjectDescriptor;
             Owner: Prognoz.Platform.Interop.Metabase.IMetabaseObjectDescriptor
             ): Prognoz.Platform.Interop.Metabase.IMetabaseCustomObjectReference;

Parameters

Object. Repository object, on which custom class object depends.

Owner. Repository object that is a parent for the object specified in the Object parameter.

Description

The AddWithOwner method adds dependency from object and its parent.

Comments

To add dependency only from object, use the IMetabaseCustomObjectReferences.Add method.

Fore Example

Executing the example requires that the repository contains a custom class object with the CUSTOM_CLASS_OBJ identifier, an object with the MDM_HIE_INDICATOR_D identifier that is a child object for object with the MDM_INDICATOR_D identifier.

Add a link to the Metabase system assembly.

Sub UserProc;
Var
    pMb: IMetabase;
    pObject: IMetabaseObject;
    pCustomObject: IMetabaseCustomObject;
    pWriter: IMetabaseCustomObjectWriter;
    pReferences: IMetabaseCustomObjectReferences;
    pRef: IMetabaseCustomObjectReference;
Begin
    // Get current repository
    pMb := MetabaseClass.Active;
    // Get custom class object
    pObject := pMb.ItemById("CUSTOM_CLASS_OBJ").Edit;
    pCustomObject := pObject As IMetabaseCustomObject;
    // Create an object that enables writing data to custom class object
    pWriter := pCustomObject.CreateWriter;
    // Get collection of object dependencies
    pReferences := pWriter.References;
    // Clear collection of object dependencies
    pReferences.Clear;
    // Add the MDM_HIE_INDICATOR_D object  with its parent MDM_INDICATOR_D
    pRef := pReferences.AddWithOwner(pMb.ItemById("MDM_HIE_INDICATOR_D"), pMb.ItemById("MDM_INDICATOR_D"));
    // Output information about this to console window
    Debug.WriteLine("Object '" + pRef.Object.Id + "' with parent '" + pRef.Owner.Id + "' are added");
    // Save changes
    pWriter.Save;
    pObject.Save;
End Sub UserProc;

After executing the example the dependency from the MDM_HIE_INDICATOR_D object and its parent is added for custom class object.

Fore.NET Example

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

Public Shared Sub Main(Params: StartParams);
Var
    pMb: IMetabase;
    pObject: IMetabaseObject;
    pCustomObject: IMetabaseCustomObject;
    pWriter: IMetabaseCustomObjectWriter;
    pReferences: IMetabaseCustomObjectReferences;
    pRef: IMetabaseCustomObjectReference;
Begin
    // Get current repository
    pMb := Params.Metabase;
    // Get custom class object
    pObject := pMb.ItemById["CUSTOM_CLASS_OBJ"].Edit();
    pCustomObject := pObject As IMetabaseCustomObject;
    // Create an object that enables writing data to custom class object
    pWriter := pCustomObject.CreateWriter();
    // Get collection of object dependencies
    pReferences := pWriter.References;
    // Clear collection of object dependencies
    pReferences.Clear();
    // Add the MDM_HIE_INDICATOR_D object  with its parent MDM_INDICATOR_D
    pRef := pReferences.AddWithOwner(pMb.ItemById["MDM_HIE_INDICATOR_D"], pMb.ItemById["MDM_INDICATOR_D"]);
    // Output information about this to console window
    System.Diagnostics.Debug.WriteLine("Object '" + pRef.Object.Id + "' with parent '" + pRef.Owner.Id + "' are added");
    // Save changes
    pWriter.Save();
    pObject.Save();
End Sub;

See also:

IMetabaseCustomObjectReferences