RegisterKeyChangeO(OwnObject: Integer; ClassId: Integer; oldKey: Integer; newKey: Integer; oldId: String; newId: String; Object: IMetabaseObject);
OwnObject. Owner of the object, which key is redetermined.
ClassId. The identifier of the destination repository class, to which the update object refers.
oldKey. The key of the source repository object, to which the object refers before update.
newKey. The key of the destination repository object, to which the object refers after update.
oldId. The identifier of the source repository object, to which the object refers before updating.
newId. The identifier of the destination repository object, to which the object refers after update.
Object. The consumer destination repository object, to which the object refers after updating.
The RegisterKeyChangeO method redetermines the key of the repository object, to which the update object refers, taking into account owner.
One of the available values of the MetabaseObjectClass enumeration is specified as the value of the ClassId parameter.
Executing the example requires that the repository contains table MDM dictionaries with the MDM_HIE_INDICATOR_S, MDM_HIE_INDICATOR_D and MDM_INDICATOR_D identifiers. The MDM_INDICATOR_D dictionary must be a parent one for the MDM_HIE_INDICATOR_D dictionary.
The file system must contain the C:\CustomObj.pefx update file that is used to update the custom class object that depends on the MDM_HIE_INDICATOR_D dictionary and its parent.
Add a link to the Metabase system assembly.
Sub UserUpd;
Var
Mb: IMetabase;
Update: IMetabaseUpdate;
Context: IMetabaseUpdateContext;
NewObj, OldObj: IMetabaseObject;
Progress: MyUpdateProgress;
Begin
// Get the current repository
Mb := MetabaseClass.Active;
// Create an update
Update := Mb.CreateUpdate;
// Load update parameters from file
Update.LoadFromFileNF("C:\CustomObj.pefx");
// Get dictionaries
NewObj := Mb.ItemById("MDM_HIE_INDICATOR_S").Bind;
OldObj := Mb.ItemById("MDM_HIE_INDICATOR_D").Bind;
// Create additional update settings
Context := Update.CreateUpdateContext;
// Redetermine the dictionary, on which custom object depends in update
Context.RegisterKeyChangeO(Mb.ItemById("MDM_INDICATOR_D").key, MetabaseObjectClass.KE_CLASS_METADICTIONARYRDS,
OldObj.key, NewObj.key, OldObj.Id, NewObj.Id, NewObj);
// Create an object that implements events that occur during update
Progress := New MyUpdateProgress.Create;
// Execute update
Update.ApplyEx(Progress, Context);
End Sub UserUpd;
// Class that implements events that occur during update
Class MyUpdateProgress: UpdateProgress
// Event that occurs if there are additional update settings
Sub OnContext(Context: IMetabaseUpdateContext);
Var
i, j: Integer;
KeyMap: IMetabaseUpdateKeyMap;
UpdRemaps: IMetabaseUpdateRemappings;
UpdObjRemap: IMetabaseUpdateObjectRemapping;
UpdRemap: IMetabaseUpdateRemapping;
Begin
// Get map of keys used for repeated mapping of update objects
KeyMap := Context.KeyMap;
// Check if map is empty
If Not KeyMap.IsEmpty Then
// If map contains data, go through its elements
For j := 0 To KeyMap.Count - 1 Do
UpdObjRemap := KeyMap.Item(j);
// Get collection of parameters of repeated mapping for repository objects
UpdRemaps := UpdObjRemap.Map(MetabaseUpdateRemappingType.Object);
// Check if collection contains elements
If Not UpdRemaps.IsEmpty Then
// If collection contains data, go through its elements
For i := 0 To UpdRemaps.Count - 1 Do
UpdRemap := UpdRemaps.Item(i);
// Display information about parameters of repeated object mapping
Debug.WriteLine("New object identifier: " + UpdRemap.NewId);
Debug.WriteLine("Old object identifier: " + UpdRemap.OldId);
Debug.WriteLine("New object key: " + UpdRemap.NewKey.ToString);
Debug.WriteLine("Old object key: " + UpdRemap.OldKey.ToString);
Debug.WriteLine("");
End For;
End If;
End For;
End If;
End Sub OnContext;
End Class MyUpdateProgress;
After executing the example the custom object is updated: now it depends on the MDM_HIE_INDICATOR_S dictionary. During the update the event is handled that occurs if there are additional update settings. The console displays information about repeated object mapping executed on update.
See also: