IMetabaseUpdateContext.RegisterHierarchyChangeO

Syntax

RegisterHierarchyChangeO(OwnObject: Integer; oldObjKey: Integer; oldHieKey: Integer; oldHieId: String; newHieKey: Integer; newHieId: String; newObject: IMetabaseObject);

Parameters

OwnObject. Object owner, which alternative hierarchy is redetermined.

oldObjKey. Source dictionary key.

oldHieKey. Alternative hierarchy key in source dictionary.

oldHieId. Alternative hierarchy identifier in source dictionary.

newHieKey. Alternative hierarchy key in destination dictionary.

newHieId. Alternative hierarchy identifier in destination dictionary.

newObject. Destination dictionary.

Description

The RegisterHierarchyChange method redetermines the alternative hierarchy, to which updated object refers, taking into account object owner.

Comments

To redetermine alternative hierarchy without taking into account owner, use the IMetabaseUpdateContext.RegisterHierarchyChange method.

Example

Executing the example requires that the repository contains table MDM dictionaries with the DM_INDICATOR_S and MDM_INDICATOR_D identifiers. These dictionaries must contain identical alternative hierarchies. The MDM_INDICATOR_S dictionary must be a child one for time series database with the TSDB_PEF identifier.

The file system must contain the C:\RegHieOChng.pefx update file used to update custom class object that depends on the MDM_INDICATOR_S dictionary and its parent.

Add links to the Dimensions, Metabase system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    Update: IMetabaseUpdate;
    Context: IMetabaseUpdateContext;
    sourceDim, targetDim: IMetabaseObject;
    sourceHieSrc, targetHieSrc: IMetabaseObject;
    sourceHierarchies, targetHierarchies: IDimHierarchies;
    sourceHierarchy, targetHierarchy: IDimHierarchy;
    TSDBKey: Integer;
    i: Integer;
    KeyMap: IMetabaseUpdateKeyMap;
    UpdObjRemap: IMetabaseUpdateObjectRemapping;
Begin
    // Get the current repository
    MB := MetabaseClass.Active;
    // Create an update
    Update := Mb.CreateUpdate;
    // Load update parameters from file
    Update.LoadFromFileNF("C:\RegHieOChng.pefx", UpdateLoadMode.Replace);
    // Create additional update settings
    Context := Update.CreateUpdateContext;
    // Get dictionaries
    sourceDim := MB.ItemById("MDM_INDICATOR_S").Bind;
    targetDim := MB.ItemById("MDM_INDICATOR_D").Bind;
    // Get dictionary hierarchies
    sourceHierarchies := (sourceDim As IDimensionModel).Hierarchies;
    targetHierarchies := (targetDim As IDimensionModel).Hierarchies;
    // Get time series database key
    TSDBKey := MB.GetObjectKeyById("TSDB_PEF");
    context.RegisterKeyChangeO(TSDBKey, sourceDim.ClassId, sourceDim.Key, targetDim.Key,
                sourceDim.Id, targetDim.Id, targetDim);
    // Go through source dictionary hierarchies
    For i := 0 To sourceHierarchies.Count - 1 Do
        // Get the current source dictionary hierarchy
        sourceHierarchy := sourceHierarchies.Item(i);
        // Search identical destination dictionary hierarchy
        targetHierarchy := targetHierarchies.FindById(sourceHierarchy.Id);
        // If such hierarchy is found
        If (targetHierarchy <> NullThen
            // Redetermine alternative hierarchy, to which source dictionary refers.
            // It will refer to destination dictionary alternative hierarchy
            context.RegisterHierarchyChangeO(TSDBKey, sourceDim.Key, sourceHierarchy.Key, sourceHierarchy.Id,
                targetHierarchy.Key, targetHierarchy.Id, targetDim);
            // Get dictionary used for alternative hierarchy in source dictionary
            sourceHieSrc := sourceHierarchy.Source As IMetabaseObject;
            // Get a dictionary used for alternative hierarchy in destination dictionary
            targetHieSrc := targetHierarchy.Source As IMetabaseObject;
            // Redetermine a dictionary used for building alternative hierarchy in source dictionary.
            // The dictionary will be used to build alternative hierarchy in destination dictionary
            context.RegisterKeyChangeO(TSDBKey, sourceHieSrc.ClassId, sourceHieSrc.Key, targetHieSrc.Key,
                sourceHieSrc.Id, targetHieSrc.Id, targetHieSrc);
            End If;
    End For;
    // Apply update
    Update.ApplyEx(Null, Context);
    // Get map of keys used for repeated mapping of update objects
    KeyMap := Context.KeyMap;
    // Search mapping parameters for the dictionary used for building alternative hierarchy
    UpdObjRemap := KeyMap.FindByOldId(MetabaseObjectClass.KE_CLASS_METADICTIONARYRDS, targetHieSrc.Id);
    // Check if parameters are found
    If UpdObjRemap <> Null Then
        // Output information about parameters of repeated object mapping
        Debug.WriteLine("New object identifier: " + UpdObjRemap.NewId);
        Debug.WriteLine("Old object identifier: " + UpdObjRemap.OldId);
        Debug.WriteLine("New object key: " + UpdObjRemap.NewKey.ToString);
        Debug.WriteLine("Old object key: " + UpdObjRemap.OldKey.ToString);
    End If;
End Sub UserProc;

After executing the example the dictionary, on which the custom class object depends, and alternative hierarchy of this dictionary are redetermined for the custom class object.

See also:

IMetabaseUpdateContext