class Task {

    TaskGroup taskGroup
    TaskStatus taskStatus
    TaskPriority taskPriority
    TaskType taskType
    Task    parentTask
    Person leadPerson
    Asset primaryAsset
    TaskRecurringSchedule taskRecurringSchedule
    TaskProcedure taskProcedure

    String description
    String comment = ""
    Date targetStartDate = new Date()
    Date targetCompletionDate = new Date()
    boolean isScheduled = false
    boolean isApproved = false
    boolean isActive = true

    static hasMany = [entries: Entry, 
                        taskModifications: TaskModification, 
                        assignedPersons: AssignedPerson, 
                        subTasks: Task,
                        associatedAssets: Asset,
                        inventoryMovements: InventoryMovement]

    static mappedBy = [taskRecurringSchedule:"task"]

    static belongsTo = [TaskGroup, TaskStatus, Task, Person]

    static constraints = {
        description(blank:false,maxSize:75)
        comment()
        targetStartDate()
        targetCompletionDate()
        leadPerson()
        taskPriority()
        taskStatus()
        parentTask(blank: true, nullable:true)
        primaryAsset(blank: true, nullable:true)
        taskRecurringSchedule(blank: true, nullable:true)
        taskProcedure(blank: true, nullable:true)
        
    }

    String toString() {"${this.id} - ${this.description}"}
}
