001package systems.dmx.core.migrations;
002
003import systems.dmx.core.model.AssociationDefinitionModel;
004import systems.dmx.core.service.Migration;
005
006
007
008/**
009 * Adds child type "Association Type" to "Composition Definition" and "Aggregation Definition" association types.
010 * Runs ALWAYS.
011 * <p>
012 * Part of DM 4.6
013 */
014public class Migration5 extends Migration {
015
016    @Override
017    public void run() {
018        // Note: "Aggregation Definition" must be updated before "Composition Definition" as the child type
019        // is added via "Aggregation Definition" and this very definition is changed here.
020        dmx.getAssociationType("dmx.core.aggregation_def").addAssocDefBefore(
021            mf.newAssociationDefinitionModel("dmx.core.aggregation_def", "dmx.core.custom_assoc_type", false, false,
022                "dmx.core.aggregation_def", "dmx.core.assoc_type", "dmx.core.many", "dmx.core.one"
023            ),
024            "dmx.core.identity_attr"
025        );
026        dmx.getAssociationType("dmx.core.composition_def").addAssocDefBefore(
027            mf.newAssociationDefinitionModel("dmx.core.aggregation_def", "dmx.core.custom_assoc_type", false, false,
028                "dmx.core.composition_def", "dmx.core.assoc_type", "dmx.core.many", "dmx.core.one"
029            ),
030            "dmx.core.identity_attr"
031        );
032    }
033}