IMetabaseUpdate.Prepare

Syntax

Prepare;

Description

The Prepare method checks the correctness of the update.

Comments

The correspondence of object parameters in the update and respective objects in the repository is checked when executing the method. The IMetabaseUpdateObjectNode.ApplyState property will be set for objects in the update.

NOTE. The IMetabaseUpdateObjectNode.ApplyState property is set only for the objects in the update that correspond to repository objects. The Prepare method is called automatically after calling the IMetabaseUpdate.Apply method and before updating objects. To check if objects are ready for update one can use the IMetabaseUpdateUserEvents.OnBeforeApplyUpdate custom event.

Example

Executing the example requires the C:\Update.pef update file.

Add a link to the Metabase system assembly.

Sub UserProc;
Var
    MB: IMetabase;
    MU: IMetabaseUpdate;
    Root: IMetabaseUpdateFolderNode;
    Node: IMetabaseUpdateNode;
    i: Integer;
    ObjectNode: IMetabaseUpdateObjectNode;
    State: IMetabaseUpdateObjectApplyState;
Begin
    MB := MetabaseClass.Active;
    MU := MB.CreateUpdate;
    MU.LoadFromFile("C:\Update.pef");
    MU.Prepare;
    Root := MU.RootFolder;
    For i := 0 To Root.Count - 1 Do
        Node := Root.Item(i);
        If Node.NodeType = MetabaseUpdateNodeType.Object Then
            ObjectNode := Node As IMetabaseUpdateObjectNode;
            State := ObjectNode.ApplyState;
            Select Case State.State
                Case MetabaseUpdateObjectApplyState.CreateNew:
                    Debug.WriteLine("Update object: " + ObjectNode.ObjectId
                          + "; State: Create new");
                Case MetabaseUpdateObjectApplyState.EditExisting:
                    Debug.WriteLine("Update object: " + ObjectNode.ObjectId
                          + "; State: Update existing.");
                Case MetabaseUpdateObjectApplyState.Conflict Or MetabaseUpdateObjectApplyState.ConflictKey:
                    Debug.WriteLine("Update object: " + ObjectNode.ObjectId
                          + "; State: Conflict. Object with this key already exists.");
                Case MetabaseUpdateObjectApplyState.Conflict Or MetabaseUpdateObjectApplyState.ConflictId:
                    Debug.WriteLine("Update object: " + ObjectNode.ObjectId
                          + "; State: Conflict. Object with this identifier already exists.");
                Case MetabaseUpdateObjectApplyState.Conflict Or MetabaseUpdateObjectApplyState.ConflictClassId:
                    Debug.WriteLine("Update object: " + ObjectNode.ObjectId
                          + "; State: Conflict. Existing object has different class.");
                Case MetabaseUpdateObjectApplyState.Conflict Or MetabaseUpdateObjectApplyState.ConflictObjectNotFound:
                    Debug.WriteLine("Update object: " + ObjectNode.ObjectId
                          + "; State: Conflict. Repository object is not found, for which the Update Only update type is set.");
                Case MetabaseUpdateObjectApplyState.Conflict Or MetabaseUpdateObjectApplyState.ConflictMissingMetadata:
                    Debug.WriteLine("Update object: " + ObjectNode.ObjectId
                          + "; State: Conflict. Update does not contain metadata for creating an object.");
            End Select;
        End If;
    End For;
End Sub UserProc;

After executing the example, the C:\Update.pef update file will be loaded and checked. The state of readiness for updating is displayed in the development environment console for the objects contained in the root folder of the update, and for corresponding repository objects.

See also:

IMetabaseUpdate | IMetabaseUpdate.PrepareC