import { Column , Entity , ManyToOne , PrimaryGeneratedColumn } from 'typeorm' ; import { Task } from '../Task/Task.entity' ; import { Project } from '../Project/Project.entity' ; import { User } from '../HumanResource/User/User.entity' ; export enum EventType { MISSION = 'mission' , SUPPORT = 'support' , DOJO = 'dojo' , FORMATION_CONFERENCE = 'formationConference' , OTHER = 'other' } @ Entity ( ) export class Event { public static readonly MAXIMUM_TIMESPENT_PER_DAY : number = 720 ; @ PrimaryGeneratedColumn ( 'uuid' ) private id : string ; @ Column ( 'enum' , { enum : EventType , nullable : false } ) private type : EventType ; @ Column ( { type : 'integer' , nullable : false , comment : 'Stored in minutes' } ) private time : number ; @ Column ( { type : 'date' , nullable : false } ) private date : string ; @ Column ( { type : 'boolean' , default : true } ) private billable : boolean ; @ Column ( { type : 'varchar' , nullable : true } ) private summary : string ; @ ManyToOne ( type => Project , { nullable : true , onDelete : 'SET NULL' } ) private project : Project ; @ ManyToOne ( type => Task , { nullable : true , onDelete : 'SET NULL' } ) private task : Task ; @ ManyToOne ( type => User , { nullable : false , onDelete : 'CASCADE' } ) private user : User ; constructor ( type , user , time , date , billable , project ? , task ? , summary ? ) { this . type = type ; this . user = user ; this . time = time ; this . date = date ; this . billable = billable ; this . project = project ; this . task = task ; this . summary = summary ; } public getId ( ) { return this . id ; } public getType ( ) { return this . type ; } public getTime ( ) { return this . time ; } public getDate ( ) { return this . date ; } public isBillable ( ) { return this . billable ; } public getSummary ( ) { return this . summary ; } public getProject ( ) { return this . project ; } public getTask ( ) { return this . task ; } public getUser ( ) { return this . user ; } public update ( type , time , billable , project ? , task ? , summary ? ) { this . type = type ; this . time = time ; this . billable = billable ; this . project = project ; this . task = task ; this . summary = summary ; } }