...
Note! We have added a new row in a database sync_parent_object_hashcode table for each object pulled from its Parent instance. We keep only the most current hash code of each object.
...
Conflict Resolution
PULL:
...
- these two objects have to be merged**, then
- saved on Child and Parent instance;
- hash codes on both Child and Parent instance have to be updated.
* REMEMBER: This is a hash code of an object that was calculated and saved on the last pull of this object from Parent. This hash code is stored in a separate table than pulled object.
** See Merge
PUSH:
...
- these two objects have to be merged**, then
- saved on Child and Parent instance;
- hash codes on both Child and Parent instance have to be updated.
* REMEMBER: This is a hash code of an object that was calculated and saved on the last pull of this object from Parent. This hash code is stored in a separate table than pulled object.
** See Merge
Merge
Once a conflict was detected two objects will have to be merged. To do this, a new database table "Conflicts" will have to be created.
This table will have columns: openmrs_class, first_object, second_object and more if needed.
It will be possible to insert any type of object into child_object and parent_object due to its type: it will be either JSON, (TINY)BLOB, TEXT or else.
All conflicted objects will be put into this table and queued just like AuditLog does this.
However, there should be only the most recent merge conflict for any object. The old ones should be voided.
Then either chosen strategy or UI will be used to:
- determine if child_object, parent_object or mixed object will be preserved,
- determine what operation should be taken after merging (push / pull / ...)
When the conflict is resolved we should save parent's object as voided in child's database.
UI for merging will use openmrs_class field to determine what class are child_object and parent_object.
Fields of determined class will be displayed as text-boxes or buttons for each of two objects.
User will be able to choose which value he wants to keep.
Please read Merging extension points if you want to implement your own merge behaviourConflict resolution can be handled automatically or manually. After the conflict is detected it is passed to object/service which implements MergeBehaviour interface. The MergeBehaviour class defines a strategy of dealing with conflicts automatically. (In fact, you can add your own implementation. All hints can be found here.) All unresolved conflicts will be saved in order to be solved by the users.
If the same object causes another conflict, then an old one will be replaced with the new one. So there is only one, the most recent, conflict regarding any object.