Hello!
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:
package systems.dmx.cooking.migrations;
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 {
@Override
public void run() {
//
TopicType dish = dmx.getTopicType("dmx.cooking.dish");
TopicType book = dmx.getTopicType("dmx.library.monograph");
// Add "Book" from library plugin as a possible source to the "Dish" composite.
dish.addCompDefBefore(mf.newCompDefModel(
"dmx.cooking.dish", "dmx.library.monograph", "dmx.core.one"
), "dmx.cooking.annotation");
// 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!