MauroDataMapper / mdm-core

The backend of MDM
Apache License 2.0
7 stars 3 forks source link

Merging versioned folders that are contained in sub-folders cannot find child items by path #479

Closed pjmonks closed 4 months ago

pjmonks commented 4 months ago

Description

I've discovered that to successfully merge a versioned folder branch into another, both must be at the top-level of the catalogue tree. If one or both are under a sub-folder, then locating the source/target items relative to the source/target versioned folders does not work because the PathService cannot find the items.

Steps to reproduce

First, create two versioned folders with branches main and anotherBranch. Make sure that main already contained some models/items, then add some new models/items to anotherBranch. To verify the merge works generally, first create them at the root level of the catalogue:

image

Perform a merge from anotherBranch into main. Once completed, this should successfully work and the two branches should be identical.

Now move these versioned folders to a sub-folder in the catalogue tree:

image

Now merge anotherBranch into main again, but this time the UI says it completed successfully but the new items were not copied from source to target.

Expected behavior

When under sub-folders, the versioned folders should still be identical after a merge.

Additional context

In terms of creation patches, I think the problem is because the path is absolute to the catalogue, not the source/target versioned folder. This is an example of a new item created in a source branch under a sub-folder:

fo:Test Folder|vf:Test Versioned Folder$anotherBranch|te:Versioned Terminology$anotherBranch

The PathService.findResourceByPathFromRootResource() method will look at this, see it is not relative to the provided source versioned folder, and attempt to use the whole path for item lookup. This will result in using the FolderService to locate the item, but this the wrong level to look at.

I think this path should be truncated during the merge - all sub-folders before vf:Test Versioned Folder$anotherBranch should be disregarded so that the child path can be used correctly.