How to create entities with generalization(System entities) through Model SDK ?

0
Hello Everyone,   Did anyone try creating generalized entities (System entities) through Model SDK ? I want to generalize my entities with system entities like Image or FileDocument. I couldn’t find a way, tried the below code from reverse engineering tool. Please let me know if anyone tried this. var generalization = domainmodels.Generalization.create(model); ***** The below line from reverse engineering tool is not supported as mentioned in the below comment ***** // Note: this is an unsupported internal property of the Model SDK which is subject to change. generalization.__generalization.updateWithRawValue("System.Image"); //generalization with entities other than System module (This works fine) generalization. Generalization=model.findEntityByQualifiedName("MyFirstModule.RandomEntity");   regards, Suresh Konapuram.
asked
1 answers
1

Hi Suresh,

This should work:

export async function createGeneralization(model: IModel, moduleName: string, entityName: string) {
    const domainModelInterface = model.allDomainModels().filter((dm) => dm.containerAsModule.name === moduleName)[0];
    const domainModel = await domainModelInterface.load();
    const newEntity = domainmodels.Entity.createIn(domainModel);
    const generalization = domainmodels.Generalization.create(model);
    const generalizedEntity = model.findEntityByQualifiedName("System.Image");
    if (generalizedEntity) {
        generalization.generalization = generalizedEntity;
    }
    newEntity.name = entityName;
    newEntity.generalization = generalization;
}

 

answered