Major
Detail
Major
Detail
Detail
#26554
Calculated web folder references delete folder when deleting the base object
When a class A declares a mandatory reference of type "DocumentsFolder", a folder is automatically created and linked to each instance of A.
If an instance with references of the type "DocumentsFolder" is deleted, these are resolved and the referenced folders are deleted.
But this also happens for calculated folder references: If object B declares a calculated reference of the type "DocumentsFolder" and returns the folder of A in it, the folder of A is deleted when B is deleted, although B is not the creation context of the folder at all.
A is now left with an empty (although mandatory) folder reference.
Analysis
For historical reasons, the type tl.folder:WebFolder has the peculiarity that all references of type WebFolder are assigned a new WebFolder instance when the object is created. This aspect has not been stored in the model so far (e.g. via a default annotation). Accordingly, when (directly) deleting an object (via tDelete()), a WebFolder that is stored in any reference is also deleted. This does not take into account whether the reference is marked as a composition, nor whether the reference is possibly calculated. When deleting again, special code runs to ensure that the WebFolder is deleted recursively with its contents, without this being marked in the model.
Improvement
- The special code for the WebFolder type is removed.
- The WebFolder type gets a default provider annotation(<default-value/>) that causes a all single composition references of type WebFolder to default to a WebFolder instance during object creation.
- WebFolder attributes must subsequently always be created as a composition if the pre-population is desired. In turn, when the base object is deleted, deletion of the folder then happens automatically via the composition markup of the reference.
- When deleting a WebFolder, a recursive deletion must always take place, regardless of whether the folder is deleted as part of a base object or not. This cannot be done via the model because WebFolder content may also be "linked" historically. However, linked content must not be deleted during recursive deletion.
Code migration
- In exported model files, a reference of type tl.folder:WebFolder must be made into a composition to maintain the same semantics as before. The corresponding data migration in existing datasets happens automatically.
#!xml <reference name="folder" composite="true" type="tl.folder:WebFolder" />
Test
- /com.top_logic.demo/src/test/java/test/com/top_logic/demo/scripted/webfolder/TestComputedWebfolderRef.script.xml
- test.scripted.TestMigration740