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. Objects in the update are assigned the ApplyState property.

NOTE. The ApplyState property is set only for update objects which correspond to the repository objects. The Prepare method is automatically called after calling the Apply method, before updating objects. The OnBeforeApplyUpdate custom event can be used to check objects readiness for updating.

Example

Executing the example requires the update file Update.pef in the root of disc C.

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 + "; Status: Creating a new one");
                Case MetabaseUpdateObjectApplyState.EditExisting:
                    Debug.WriteLine("Update object: " + ObjectNode.ObjectId + "; Status: Updating an existing one.");
                Case MetabaseUpdateObjectApplyState.Conflict Or MetabaseUpdateObjectApplyState.ConflictKey:
                    Debug.WriteLine("Update object: " + ObjectNode.ObjectId + "; Status: Conflict. The object with the same key already exists.");
                Case MetabaseUpdateObjectApplyState.Conflict Or MetabaseUpdateObjectApplyState.ConflictId:
                    Debug.WriteLine("Update object: " + ObjectNode.ObjectId + "; Status: Conflict. The object with the same identifier already exists.");
                Case MetabaseUpdateObjectApplyState.Conflict Or MetabaseUpdateObjectApplyState.ConflictClassId:
                    Debug.WriteLine("Update object: " + ObjectNode.ObjectId + "; Status: Conflict. The existing object has another class.");
                Case MetabaseUpdateObjectApplyState.Conflict Or MetabaseUpdateObjectApplyState.ConflictObjectNotFound:
                    Debug.WriteLine("Update object: " + ObjectNode.ObjectId + "; Status: Conflict. The repository object which has the Update Only type.");
                Case MetabaseUpdateObjectApplyState.Conflict Or MetabaseUpdateObjectApplyState.ConflictMissingMetadata:
                    Debug.WriteLine("Update object: " + ObjectNode.ObjectId + "; Status: Conflict. The update does not contain the metadata for creating the object.");
            End Select;
        End If;
    End For;
End Sub UserProc;

After executing this example the update file Update.pef is downloaded and checked. The state of readiness for updating is displayed in a development environment console for the objects, that are in the root folder of the update, and for corresponding repository objects.

See also:

IMetabaseUpdate | IMetabaseUpdate.PrepareC