source: trunk/grails-app/domain/TaskProcedureRevision.groovy @ 816

Last change on this file since 816 was 809, checked in by gav, 14 years ago

Domain change, first draft of TaskProcedureRevisions.

File size: 1.7 KB
RevLine 
[809]1import org.apache.commons.collections.list.LazyList
2import org.apache.commons.collections.FactoryUtils
3
4class TaskProcedureRevision {
5
6    Task linkedTask
7
8    TaskProcedure taskProcedure
9    Integer revision
10    Person createdBy
11    Date dateCreated = new Date() // autoTimestamp
12
13    def getDescription() { linkedTask.description }
14    def getAsset() { linkedTask.primaryAsset }
15
16    List maintenanceActions = new ArrayList()
17    List documentReferences = new ArrayList()
18
19    static hasMany = [tasks: Task,
20                                    maintenanceActions: MaintenanceAction,
21                                    documentReferences: DocumentReference]
22
23    def getMaintenanceActionLazyList() {
24        return LazyList.decorate(maintenanceActions, FactoryUtils.instantiateFactory(MaintenanceAction.class))
25    }
26
27    def getDocumentReferenceLazyList() {
28        return LazyList.decorate(documentReferences, FactoryUtils.instantiateFactory(DocumentReference.class))
29    }
30
31    // The taskProcedure holds the procedure id number.
32    def getTaskProcedureId() {
33        taskProcedure.id
34    }
35
36    static mappedBy = [tasks:"taskProcedureRevision"]
37
38    static mapping = {
39        taskProcedure lazy:false
40        linkedTask lazy:false
41        tasks batchSize: 10
42        maintenanceActions cascade:"all-delete-orphan"
43        documentReferences cascade:"all-delete-orphan"
44    }
45
46    static belongsTo = [TaskProcedure]
47
48    static constraints = {
49    }
50
51    String toString() {
52        "${this.id}"
53    }
54
55    def getRevisionDateString() {
56        "${this.revision} -- ${dateCreated.format('EEE, dd-MMM-yyyy')}"
57    }
58
59    def getFullRevisionString() {
60        "${this.revision} -- ${createdBy} on ${dateCreated.format('EEE, dd-MMM-yyyy @ HH:mm')}"
61    }
62}
Note: See TracBrowser for help on using the repository browser.