How to create a composition definition with a custom association type set?

Hello! :slightly_smiling_face:
I am looking for some advice. I am trying to write the following imperative migration:

  • It shall get an existing Composite Topic Type and add a Topic Type to the composition definition. This part is already working. The association is a ‚ÄúComposition Definition‚ÄĚ as per default.
  • That new association shall be retyped to an already existing custom association type (called ‚Äúsource‚ÄĚ).

How can I achieve that second part? I went through the API documentation but nothing seems to fit. This is what I have so far:

import systems.dmx.core.TopicType;
import systems.dmx.core.model.CompDefModel;
import systems.dmx.core.DMXObject;
import systems.dmx.core.service.Migration;

public class Migration8 extends Migration {
    public void run() {
	TopicType dish = dmx.getTopicType("");
	TopicType book = dmx.getTopicType("dmx.library.monograph");
	// Add "Book" from library plugin as a possible source to the "Dish" composite.
		"", "dmx.library.monograph", ""
		), "");
	// to fetch an association the documentation says: getAssoc(String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, long othersTopicId) 
	Assoc assoc = dmx.getAssoc("dmx.core.composition_def", "dmx.core.parent_type", "dmx.core.child_type", book.getId());

Any hints are welcome!

Instead of the 3-param newCompDefModel() method use its 6-param form:

As 1st param (customAssocTypeUri) you can specify your custom association type.

Just a wording hint: you don‚Äôt want ‚Äúretype an association type to a custom association type‚ÄĚ but ‚Äúcreate a composition definition with a custom association type set‚ÄĚ.

Great, many thanks! It’s working!

I renamed the thread to the correct wording.