Averos Entity Metadata
Averos entities hold metadata that are mandatory and required in order to bootstrap the framework context.
Each Averos business entity should define the following metadata:
- a simple string name: describing the name of the entity class
- a View Layout holder: that hold the entity view layout with respect to different use cases
- a Service Controller: that will manage the entity (ex. CRUD operations). This service controller should be defined in the decorator @AverosEntity().
- a unique identifier: that is decorated by @ID()
- all relationships: members defining relationships and decorated with one of the relationship decorators @OneToOne, @OneToMany and @ManyToOne
Example:
@AverosEntity(MyAverosEntityService)
export class MyAverosEntity {
public static entityViewLayout$: Observable<EntityViewLayout<MyAverosEntity>>;
public static entityViewLayout : EntityViewLayout<MyAverosEntity>;
public static entityName = 'MyAverosEntity';
private static instance: MyAverosEntity = null;
@ID()
_id!: number;
name!: string;
description!: string;
createdAt!: Date;
updatedAt!: Date;
status!: MyEntityStatus;
@OneToOne('User', import('@wiforge/averos/core/_models/user')) createdBy!: User;
@OneToOne('User', import('@wiforge/averos/core/_models/user')) updatedBy!: User;
static getEntityViewLayout(): Observable<EntityViewLayout<MyAverosEntity>> {
return MyAverosEntity.entityViewLayout$;
}
static getUseCaseViewLayout(useCase: UseCase): Observable<UseCaseViewLayout<MyAverosEntity>>{
return getUseCaseViewLayout(MyAverosEntity, useCase);
}
static instanceMetadata(){
if (!MyAverosEntity.instance){
MyAverosEntity.instance = new MyAverosEntity();
}
return MyAverosEntity.instance;
}
}