Class diagram - donvadicastro/generator-xmi GitHub Wiki
// 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 > ;
}
Important!!! Interface properties are not reflected in object that it implement. Only methods.
// 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 > ;
}
// 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();
}
}
// 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 > {
...
}
}
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 { |
After entity creation | export class Building extends BuildingBase { |
Before entity updating | export class Building extends BuildingBase { |
After entity updating | export class Building extends BuildingBase { |
Before entity deletion | export class Building extends BuildingBase { |
After entity deletion | export class Building extends BuildingBase { |