Problem
Overwriting attributes sometimes fails. The cause appears to be that the model is assembled in an unexpected order. In particular, attributes are added to a derivation even though the superclass does not yet have its attributes. However, as the overwritten attribute is required for an override because its configuration is adopted, this fails.
Migration
Overrides of backwards references should explicitly specify the child backwards in their configuration in order to determine directly what type of override is involved without, in the worst case, having to search the entire type hierarchy for a reference with the same name in order to determine the type of reference.
The configuration for the reference tl.doc:Page#parent, which is an override of a backward reference, looks like this, for example:
<reference name="parent" kind="backwards" override="true" type="Page" />
Ex. already overrides backward references, then they are currently stored "incorrectly" (as a forward reference) in the database. For the correction, you can refer to the files
- Ticket_21471_Adjust_model_overrides.migration.xml
- Ticket_21471_Adjust_model_overrides.model.transform.xslt
which do this for the override tl.doc:Page#parent of the backward reference tl.element:StructuredElement#parent.
Implementation
The model is created from a corresponding configuration in the following phases:
- START: The setup phase. In this phase, modules and empty type instances are created. These can be created independently of each other.
- CREATE_TYPE_HIERARCHY: Creation of the type hierarchy. For each type, its generalization is set.
- CREATE_PARTS: Creation of type parts. The inheritance hierarchy must be known in order to sort the actions for creating the type parts. This sorting is necessary because an overwriting of a tl:TLTypePart can only be created if the underlying type part already exists.
- CREATE_ASSOCIATION_END: Association ends must be created before references are created, as these use association ends.
- CREATE_REFERENCE: Creation of references.
- CREATE_REFERENCE_OVERRIDE: Creation of reference overrides. All reference overrides must be created before back references are created, as they can be backward references to overwritten references.
- CREATE_BACK_REFERENCE: Creation of backward references.
- CREATE_BACK_REFERENCE_OVERRIDE: All reference overrides must be created before back references are created, as there may be back references to overwritten references.
- REORDER_PROPERTIES: Definition of the final order.
- CREATE_ROLE: Role creation.
- CREATE_SINGLETON: Create module singletons.
This ensures that the overrides are not created until the super-type has already created the attribute to be overridden.
Test
No test.