Ignore:
Timestamp:
Feb 16, 2011, 8:10:39 PM (14 years ago)
Author:
gav
Message:

Domain change, first draft of TaskProcedureRevisions.

Location:
trunk/grails-app/domain
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/domain/DocumentReference.groovy

    r798 r809  
    1010//     static hasMany = []
    1111
    12     static belongsTo = [TaskProcedure]
     12    static belongsTo = [TaskProcedure, TaskProcedureRevision]
     13
     14    static mapping = {
     15        batchSize 10
     16    }
    1317
    1418    static constraints = {
  • trunk/grails-app/domain/MaintenanceAction.groovy

    r798 r809  
    11class MaintenanceAction {
    22
    3     TaskProcedure taskProcedure
    43    MaintenancePolicy maintenancePolicy
    54    Section section
     
    1716//     static hasMany = []
    1817
    19     static belongsTo = [TaskProcedure]
     18    static mapping = {
     19        batchSize 10
     20    }
     21
     22    static belongsTo = [TaskProcedure, TaskProcedureRevision]
    2023
    2124    static constraints = {
     
    2629        procedureStepNumber(nullable:true)
    2730        description(blank:false,maxSize:100)
    28         pageRef(maxSize:100)
     31        pageRef(maxSize:25)
    2932    }
    3033
  • trunk/grails-app/domain/Task.groovy

    r807 r809  
    1313    AssetSubItem assetSubItem
    1414    TaskRecurringSchedule taskRecurringSchedule
    15     TaskProcedure taskProcedure
     15    TaskProcedureRevision taskProcedureRevision
    1616
    1717    String description
     
    6161        assetSubItem(nullable:true)
    6262        taskRecurringSchedule(nullable:true)
    63         taskProcedure(nullable:true)
     63        taskProcedureRevision(nullable:true)
    6464
    6565    }
  • trunk/grails-app/domain/TaskProcedure.groovy

    r798 r809  
    55
    66    Task linkedTask
    7     Person createdBy
    8     Person lastUpdatedBy
    9     Date dateCreated = new Date() // autoTimestamp
    10     Date lastUpdated = new Date() // autoTimestamp
    117
    128    def getDescription() { linkedTask.description }
     
    1511    List maintenanceActions = new ArrayList()
    1612    List documentReferences = new ArrayList()
     13    List revisions = new ArrayList()
    1714
    18     static hasMany = [tasks: Task,
    19                                     maintenanceActions: MaintenanceAction,
    20                                     documentReferences: DocumentReference]
     15    static hasMany = [maintenanceActions: MaintenanceAction,
     16                                    documentReferences: DocumentReference,
     17                                    revisions: TaskProcedureRevision]
    2118
    2219    def getMaintenanceActionLazyList() {
     
    2825    }
    2926
    30     static mappedBy = [tasks:"taskProcedure"]
     27    // The current revision number is equal to the count of the revisions created.
     28    // More efficient than loading the entire revisions list and using size().
     29    // WithTransaction is used to allow calling in a transaction however objects
     30    // in the current transaction must not trigger DataIntegrityViolationException.
     31    def getRevision() {
     32        def revision
     33        TaskProcedure.withTransaction {
     34            revision = TaskProcedureRevision.countByTaskProcedure(this)
     35        }
     36        return revision
     37    }
     38
     39    // Get a specific revision.
     40    def getRevision(revision) {
     41        def taskProcedureRevision
     42        TaskProcedure.withTransaction {
     43            taskProcedureRevision = TaskProcedureRevision.findByTaskProcedureAndRevision(this, revision)
     44        }
     45        return taskProcedureRevision
     46    }
     47
     48    // Get the latest revision of this procedure.
     49    def getLatestRevision() {
     50        def taskProcedureRevision
     51        TaskProcedure.withTransaction {
     52            taskProcedureRevision = TaskProcedureRevision.findByTaskProcedureAndRevision(this, this.revision)
     53        }
     54        return taskProcedureRevision
     55    }
    3156
    3257    static mapping = {
     58        linkedTask lazy:false
     59        revisions batchSize: 10
    3360        maintenanceActions cascade:"all-delete-orphan"
    3461        documentReferences cascade:"all-delete-orphan"
     62        revisions cascade:"all-delete-orphan"
    3563    }
    3664
Note: See TracChangeset for help on using the changeset viewer.