source: trunk/grails-app/domain/Task.groovy @ 450

Last change on this file since 450 was 446, checked in by gav, 15 years ago

Add constraints to Task domain class for targetCompletionDate and comment.

File size: 1.6 KB
Line 
1class Task {
2
3    TaskGroup taskGroup
4    TaskStatus taskStatus
5    TaskPriority taskPriority
6    TaskBudgetStatus taskBudgetStatus
7    TaskType taskType
8    Task parentTask
9    Person leadPerson
10    Asset primaryAsset
11    TaskRecurringSchedule taskRecurringSchedule
12    TaskProcedure taskProcedure
13
14    String description
15    String comment = ""
16    Date targetStartDate = new Date()
17    Date targetCompletionDate = new Date()
18    boolean scheduled = false
19    boolean approved = false
20    boolean trash = false
21    boolean attentionFlag = false
22
23    static hasMany = [entries: Entry,
24                        taskModifications: TaskModification,
25                        assignedGroups: AssignedGroup,
26                        assignedPersons: AssignedPerson,
27                        subTasks: Task,
28                        associatedAssets: Asset,
29                        inventoryMovements: InventoryMovement]
30
31    static mappedBy = [taskRecurringSchedule:"task"]
32
33    static belongsTo = [TaskGroup, TaskStatus, Task, Person]
34
35    static constraints = {
36        description(blank:false,maxSize:75)
37        comment(maxSize:1000)
38        targetStartDate()
39        targetCompletionDate(validator: {val, obj ->
40            if(val.before(obj.targetStartDate))
41                return 'before.targetStartDate'
42        })
43        leadPerson()
44        taskPriority()
45        taskBudgetStatus()
46        taskStatus()
47        parentTask(nullable:true)
48        primaryAsset(nullable:true)
49        taskRecurringSchedule(nullable:true)
50        taskProcedure(nullable:true)
51
52    }
53
54    String toString() {"${this.id} - ${this.description}"}
55}
Note: See TracBrowser for help on using the repository browser.