Class diagram - donvadicastro/generator-xmi GitHub Wiki

class diagrams

// bulding
export class Building extends BuildingBase {
    //override base actions to implement own business behaviors
    build(state: any): Promise < any > {
        return super.build(state);
    }
}

// building.generated
export abstract class BuildingBase implements BuildingContract {
    code: number = 0;

    constructor() {
        super();
    }

    build(state: any): Promise < any > {
        ...
    }
}

// building.contract
export interface BuildingContract {
    code: number;

    build(state: any): Promise < any > ;
}

Interface generation

Important!!! Interface properties are not reflected in object that it implement. Only methods.

interface generation

// A
export class A extends ABase {
}

// A.generated
export abstract class ABase implements AContract {
    ...
    
    fn1(state: any): Promise < any > {
        ...
    }
    
    fn2(state: any): Promise < any > {
        ...
    }
}

// A.contract
export interface AContract {
    fn1(state: any): Promise < any > ;
    fn2(state: any): Promise < any > ;
}

// B.contract
/**
 * This file is auto-generated. Do not update it's content!
 */
export interface BContract {
    attr1: number;
    attr2: boolean;
    
    fn1(state: any): Promise < any > ;
    fn2(state: any): Promise < any > ;
}

Class association generation

class association diagrams

// city
export abstract class CityBase implements CityContract {
    name: string = '';

    airlineRef: airlineContract | null = null;
    
    constructor() {
        super();
    }
}

// airline
export abstract class AirlineBase implements AirlineContract {
    name: string = '';

    aircraftRefList: aircraftContract[] = [];
    
    cityRef: cityContract | null = null;
    
    constructor() {
        super();
    }
}

// aircraft
export abstract class AircraftBase implements AircraftContract {
    number: string = '';

    airlineRef: airlineContract | null = null;
    
    constructor() {
        super();
    }
}

Class generalization generation

class generalization diagrams

// person
export abstract class PersonBase implements PersonContract {
    firstName: string = '';
    lastName: string = '';

    constructor() { super(); }

    getFirstName(state: any): Promise < any > {
        ...
    }
}

// student
export abstract class StudentBase extends PersonBase implements StudentContract {
    specialization: string = '';

    constructor() { super(); }

    checkExam(state: any): Promise < any > {
        ...
    }

    getFirstName(state: any): Promise < any > {
        ...
    }
}

Listen and react to class events

After project generation each class in class diagram will be presented as set of UI forms to support full set of CRUD operations over defined entity (Create/Read/Update/Delete).

At the same time there is a possibility to listen entity events and react to it by introducing custom business behaviors over generated code by adding specific class annotation to custom methods.

Event Listener example
Before entity creation
export class Building extends BuildingBase {
    @BeforeInsert
    beforeInsertFn() {   ...  }
}
After entity creation
export class Building extends BuildingBase {
    @AfterInsert
    afterInsertFn() {   ...  }
}
Before entity updating
export class Building extends BuildingBase {
    @BeforeUpdate
    beforeUpdateFn() {   ...  }
}
After entity updating
export class Building extends BuildingBase {
    @AfterUpdate
    afterUpdateFn() {   ...  }
}
Before entity deletion
export class Building extends BuildingBase {
    @BeforeRemove
    beforeRemoveFn() {   ...  }
}
After entity deletion
export class Building extends BuildingBase {
    @AfterRemove
    afterRemoveFn() {   ...  }
}
⚠️ **GitHub.com Fallback** ⚠️