PrepareC(Context: IMetabaseUpdateContext);
Context. Additional settings of the update object.
The PrepareC method checks the correctness of update considering the advanced settings.
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 PrepareC method is called automatically after calling the IMetabaseUpdate.ApplyEx method and before objects update. To check if objects are ready for update one can use the IMetabaseUpdateUserEvents.OnBeforeApplyUpdate custom event.
If the Context parameter is set to Null, the verification is executed without advanced settings.
Executing the example requires the C:\Update.pefx update file and an object with the BD2 identifier in the repository.
Add a link to the Metabase system assembly.
Sub UserProc;
Var
MB: IMetabase;
MU: IMetabaseUpdate;
Root: IMetabaseUpdateFolderNode;
Node: IMetabaseUpdateNode;
ObjectNode: IMetabaseUpdateObjectNode;
i: Integer;
State: IMetabaseUpdateObjectApplyState;
UpdateCxt: IMetabaseUpdateContext;
NewObject: IMetabaseObject;
Begin
MB := MetabaseClass.Active;
MU := MB.CreateUpdate;
MU.LoadFromFileNF("C:\Update.pefx");
UpdateCxt := MU.CreateUpdateContext;
NewObject := MB.ItemById("BD2").Bind As IMetabaseObject;
UpdateCxt.RegisterIdChange(NewObject.ClassId, "BD1", "BD2", NewObject);
MU.PrepareC(UpdateCxt);
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 a 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 Update.pefx file is loaded and verified considering possible redetermining of the link of the updated object to the object with the BD2 identifier of the destination repository. 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: