IMetabaseUpdateUnresolved.IsRequired

Syntax

IsRequired: Boolean;

Description

The IsRequired property determines whether an error (forbidden link) is handled during update.

Comments

The property is set to False by default and an error is ignored. If the value is True, in the OnResolve event transition to handling of forbidden links is made (the OnError event).

Example

Executing the example requires an update file with the Update.pef name at the specified path.

Sub main;
Var
    mb: IMetabase;
    u: IMetabaseUpdate;
    progress: MyUpdateProgress;
Begin
    mb := MetabaseClass.Active;
    u := mb.CreateUpdate;
    u.LoadFromFile("c:\Temp\pef\Update.pef");
    progress := New MyUpdateProgress.Create;
    u.ApplyOptions := u.ApplyOptions Or MetabaseUpdateApplyOptions.EnableIgnoreErrors;
    u.Apply(progress);
End Sub main;

Class MyUpdateProgress: UpdateProgress

    Public Sub OnResolve(Node: IMetabaseUpdateNode; Resolver: IMetabaseUpdateResolver);
    Var i: integer;
    Begin
        Debug.WriteLine("OnResolve worked for Node '" + Node.Label + "' !");
        For i := 0 To Resolver.Count - 1 Do
            Debug.WriteLine(i.ToString + " Resolver.Item(" + i.ToString + ").Name " + Resolver.Item(i).Name + "' !");
            Resolver.Item(i).IsRequired := True//synchronization error will be handled in OnError
        End For;
    End Sub OnResolve;

    Sub OnError(Data: IMetabaseUpdateProgressData; Var Ignore: Boolean);
    Begin
        Debug.WriteLine("OnError worked for node '" + Data.Node.Label + "' !");
        Debug.WriteLine("Error text: " + Data.Error.Message);
        Debug.WriteLine("MessageID: " + Data.Error.MessageID.ToString);
        If Data.Object <> Null Then
            Debug.WriteLine("Error source: " + Data.Object.Id);
            Debug.WriteLine("Object key: " + Data.Object.Key.ToString);
        End If;
        //skip object
        Ignore := True;
    End Sub OnError;
End Class MyUpdateProgress;

The MyUpdateProgress custom class is used to handle events that occur on update. If during the update there will be an object that has forbidden links (dependency of update object on source repository objects that do not exist in destination repository), a synchronization error of repository object with an object in update (OnError) will be created and information about the forbidden link will be displayed in the development environment console. The objects with errors are skipped.

See also:

IMetabaseUpdateUnresolved